Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import math
  2. import numpy as np
  3. from matplotlib import pyplot as plt
  4. X=[40,40]
  5. def f(X,t):
  6. x=X[0]
  7. y=X[1]
  8. R=math.sqrt(x**2+y**2)
  9. T=24*60*60
  10. factor=2*math.pi/T
  11. Y=[x,y]
  12. Y[0]+=t*factor*(-y)
  13. Y[1]+=t*factor*x
  14. x=Y[0]
  15. y=Y[1]
  16. R=math.sqrt(x**2+y**2)
  17. return Y,R
  18. def plotThing(X,h):
  19. R=math.sqrt(X[0]**2+X[1]**2)
  20. R2=0
  21. x,y=X[0],X[1]
  22. Y=[x,y]
  23. for i in range(2*24*60*60//(h)):
  24. Y,R2=f(Y,h)
  25. error=abs(R-R2)
  26. return error
  27. times=[30,60,4*60,8*60,15*60,30*60,3600,2*3600,4*3600,8*3600]
  28. errorArr=[]
  29. print("X:",X)
  30. for h in times:
  31. print(plotThing(X,h))
  32. errorArr.append(plotThing(X,h))
  33. print("X:",X)
  34. X=[40,40]
  35. h0=1
  36. while plotThing(X,h0)<10:
  37. print("error:",plotThing(X,h0),"må være sant",plotThing(X,h0)<10)
  38. X=[40,40]
  39. h0+=1
  40. print("for å få en error større enn 10 meter må tidssteget være",h0,"sekunder")
  41. plt.loglog(times,errorArr)
  42. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement