Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. def f(t,y): return np.sin(t)+np.exp(-t)
  2. def f_t(t,y): return np.cos(t)-np.exp(-t)
  3. def f_y(t,y): return 0
  4.  
  5. t,y,h=0,0,0.5;
  6. while t < 1+0.1*h:
  7. t, y = t+h, y + h*( (1+0.5*h*f_y(t,y))*f(t,y) + 0.5*h*f_t(t,y) );
  8. print t,y
  9.  
  10. 0.5 0.5
  11. 1.0 1.0768595869306357
  12. 1.5 1.7030876580073921
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement