Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 50 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top