Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib
- import matplotlib.pyplot as plt
- import math
- e = math.exp(1)
- k = 8000
- h = 0.00001
- y0 = 0
- z0 = 0
- w0 = 16
- w = [w0]
- z = [z0]
- y = [y0]
- Y = [y0]
- n = 1000000
- x = [0]
- for i in range(1, n):
- x.append(i*h)
- t = x[-1]
- Y.append(e**(-5*t) -e**(-t) + 4*t*e**(-t))
- Delta = -1
- for i in range(1,n):
- y.append(y[-1] + h*z[-1])
- z.append(z[-1] + h*w[-1])
- w.append(w[-1] + h*(-7*w[-1] - 11*z[-1] - 5 *y[-1]))
- if (i > k):
- Delta = max(Delta, abs(Y[i] - y[i])/Y[i])
- print(Delta * 100)
- plt.plot(x,y)
- plt.plot(x,Y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement