Advertisement
Infiniti_Inter

TAY

Apr 2nd, 2020
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import matplotlib
  2. import matplotlib.pyplot as plt
  3. import math
  4.  
  5. e = math.exp(1)
  6. k = 8000
  7. h =  0.00001
  8.  
  9. y0 = 0
  10. z0 = 0
  11. w0 = 16
  12.  
  13.  
  14. w = [w0]
  15. z = [z0]
  16. y = [y0]
  17. Y = [y0]
  18. n = 1000000
  19.  
  20. x = [0]
  21. for i in range(1, n):
  22.     x.append(i*h)
  23.     t = x[-1]
  24.     Y.append(e**(-5*t) -e**(-t) + 4*t*e**(-t))
  25.  
  26. Delta = -1
  27.  
  28. for i in range(1,n):
  29.     y.append(y[-1] + h*z[-1])
  30.     z.append(z[-1] + h*w[-1])
  31.     w.append(w[-1] + h*(-7*w[-1] - 11*z[-1] - 5 *y[-1]))
  32.     if (i > k):
  33.         Delta = max(Delta, abs(Y[i] - y[i])/Y[i])
  34.    
  35.  
  36. print(Delta * 100)
  37.  
  38.  
  39.  
  40. plt.plot(x,y)
  41. plt.plot(x,Y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement