Advertisement
gronke

sums

Jul 9th, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. import numpy
  2. import pylab
  3. import time
  4.  
  5. n = pylab.arange(1,10000,1)
  6.  
  7. J_left = numpy.zeros(n.size)
  8. J_right = numpy.zeros(n.size)
  9. t_run= numpy.zeros(n.size)
  10.  
  11. for i in range (1,n.size):
  12.     t0=time.time()
  13.    
  14.     w_left = numpy.arange(0,numpy.pi/2,(numpy.pi/2)/n[i])
  15.  
  16.     w_right = w_left + (numpy.pi/2)/n[i]
  17.  
  18.     area_left = numpy.sin(w_left)*(w_right-w_left)
  19.  
  20.     area_right = numpy.sin(w_right)*(w_right-w_left)
  21.  
  22.     J_left[i] = area_left
  23.     J_right[i] = area_right
  24.  
  25.     t1 = time.time()
  26.     t_run[i]=t1-t0
  27.  
  28. J_labs = numpy.abs(1-J_left)
  29. J_rabs = numpy.abs(1-J_right)
  30.  
  31. pylab.figure(1)
  32. pylab.plot(n,J_labs)
  33. pylab.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement