title: pendulum involving scipy ode
body: <p>I am using scipy ode to solve the pendulum problem.</p>
  
  <pre><code>from scipy import *
  import matplotlib.pyplot as plt
  from scipy.integrate import ode
  
  def pendulumdot(t, y,  gamma, omega0, Fd):
      theta, v = y[0], y[1]
      return array([v, -2*gamma*v-omega0**2*sin(theta)+Fd*cos(2*pi*t)])
  
  
  
  def pendulum_sample(theta0, thetadot0, gamma, omega0, Fd, t):
      Theta0 = array([theta0, thetadot0]) 
      r = ode(pendulumdot)
      r.set_integrator('dopri5')
      r.set_initial_value(Theta0)
      r.set_f_params( gamma, omega0, Fd)
      #r.set_jac_params()
      theta = zeros(len(t))
      thetadot = zeros(len(t))
      theta[0] = theta0
      thetadot[0] = thetadot0
      for n in range(1, len(t)):
          r.integrate(t[n])
          assert r.successful()
          theta[n] = (r.y)[0]
          thetadot[n] = (r.y)[1]
      return theta, thetadot
  def pendulum_demo():
      gamma = 0.1
      omega0 = 10.0
      theta0 = 0.0
      thetadot0 = 0.0
      Fd = 50.0
      t1 = linspace(0, 200, 10000)
      theta1, thetadot1 = pendulum_sample(theta0, thetadot0, gamma, omega0, Fd, t1)
      plt.plot(t1, theta1)
      t2 = linspace(0, 150, 10000)
      theta2, thetadot2 = pendulum_sample(theta0, thetadot0, gamma, omega0, Fd, t2)
      plt.plot(t2, theta2)
      plt.show()
  pendulum_demo()
  </code></pre>
  
  <p>I plot two figure of theta versus time for different time range, one is (0, 150) and one is (0, 200). What I expect is that the two figure should be same in the time range (0, 150), however, that is not what I observe. Anything wrong with my script? Thanks.<img src="https://i.stack.imgur.com/WkZpg.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/cuXca.png" alt="enter image description here"></p>