Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import math
- #load plotting library
- import matplotlib.pyplot as plt
- def phi(t):
- return np.exp(np.sin(-0.3*t**2+0.2))
- def a(t):
- return (10.*t)*np.cos(5*t)
- def b(t):
- return (5.*(10-t)-1.5)*np.sin(5*t)
- tmin = 2.
- tmax = 8.
- Nt = 128
- tgrid = np.linspace(tmin,tmax,Nt)
- phiv = phi(tgrid)
- psiv = np.zeros(Nt)
- av = a(tgrid)
- bv = b(tgrid)
- plt.plot(tgrid,av,label="a(t)")
- plt.plot(tgrid,bv,label="b(t)")
- plt.xlabel("t")
- plt.legend()
- plt.show()
- for it in range(Nt):
- psiv[it] = phiv[it] + math.atan2(bv[it],av[it])
- plt.plot(tgrid,phiv,label="$phi(t)$")
- plt.plot(tgrid,psiv,label="$psi(t)$")
- plt.xlabel("t")
- plt.legend()
- plt.show()
Add Comment
Please, Sign In to add comment