Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. def run(n):
  3.     # euler integratie
  4.     u = [
  5.         1
  6.     ]
  7.     t = 1
  8.     for h in range(0, n):
  9.         u.append(u[h] + ((u[h] / t) * t))
  10.     plt.plot(u)
  11.  
  12.     print(u)
  13.     for h in range(0, n):
  14.         # heuns integratie?
  15.         p = ((u[h] / 1) + (u[h + 1] / 2))
  16.         u[h + 1] = u[h] + (0.5 * p) * t
  17.         print(u)
  18.  
  19.     plt.plot(u)
  20.     plt.show()
  21.  
  22.  
  23. run(5)
  24. run(10)
  25. run(20)
  26. run(100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement