Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(t,y): return np.sin(t)+np.exp(-t)
- def f_t(t,y): return np.cos(t)-np.exp(-t)
- def f_y(t,y): return 0
- t,y,h=0,0,0.5;
- while t < 1+0.1*h:
- t, y = t+h, y + h*( (1+0.5*h*f_y(t,y))*f(t,y) + 0.5*h*f_t(t,y) );
- print t,y
- 0.5 0.5
- 1.0 1.0768595869306357
- 1.5 1.7030876580073921
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement