Guest User

Untitled

a guest
Mar 13th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import numpy as np
  2. import math
  3.  
  4. #load plotting library
  5. import matplotlib.pyplot as plt
  6.  
  7. def phi(t):
  8. return np.exp(np.sin(-0.3*t**2+0.2))
  9.  
  10. def a(t):
  11. return (10.*t)*np.cos(5*t)
  12.  
  13. def b(t):
  14. return (5.*(10-t)-1.5)*np.sin(5*t)
  15.  
  16. tmin = 2.
  17. tmax = 8.
  18. Nt = 128
  19.  
  20. tgrid = np.linspace(tmin,tmax,Nt)
  21. phiv = phi(tgrid)
  22. psiv = np.zeros(Nt)
  23. av = a(tgrid)
  24. bv = b(tgrid)
  25.  
  26. plt.plot(tgrid,av,label="a(t)")
  27. plt.plot(tgrid,bv,label="b(t)")
  28. plt.xlabel("t")
  29. plt.legend()
  30. plt.show()
  31.  
  32. for it in range(Nt):
  33. psiv[it] = phiv[it] + math.atan2(bv[it],av[it])
  34.  
  35. plt.plot(tgrid,phiv,label="$phi(t)$")
  36. plt.plot(tgrid,psiv,label="$psi(t)$")
  37. plt.xlabel("t")
  38. plt.legend()
  39. plt.show()
Add Comment
Please, Sign In to add comment