Hi I wrote the following script, but it hangs right after plt.show(). I would
really appreciate it if someone could take a look and let me know where I'm
messing up. Thanks in advance

from numpy import *
import matplotlib.pyplot as plt

#H=p^2/2-cosq
#p=dp=-dH/dq
#q=dq=dH/dp

t = 0
h = 0.5
pfa = []                        #Create arrays that will hold pf,qf values
qfa = []

while t < 10:
  q = 1+t
  p = -sin(q+t)

  p1 = p
  q1 = q
  p2 = p + h/2*q1
  q2 = q + h/2*p1
  p3 = p+ h/2*q2
  q3 = q+ h/2*p2
  p4 = p+ h/2*q3
  q4 = q+ h/2*p4
  pf = (p +(h/6)*(p1+2*p2+3*p3+p4))
  qf = (q +(h/6)*(q1+2*q2+3*q3+q4))
  #pf = log10(pf)                  #Convert to log scale
  #qf = log10(qf)
  pfa.append(pf)                   #append arrays
  qfa.append(qf)
  t += h                          #increase time step                        
                                  
  print("test")
  plt.plot(pfa,qfa)
  print("test1")
  plt.show()
  print("tes2t")
  
 


-- 
View this message in context: 
http://old.nabble.com/Script-hanging-during-plot-of-Runge-Kutta-tp33354840p33354840.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to