SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top