Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from scipy.integrate import odeint
- %matplotlib inline
- def F(t,k):
- x,y,z = k
- Q = np.empty(3)
- Q[0] = x + 3
- Q[1] = x + 3 *y +z
- Q[2] = x + y**2
- return Q
- def EulerMethod(a,b,c,N,F):
- H = (b-a)/N
- t = np.linspace(a,b,N+1)
- Z = np.zeros((N+1,len(c)))
- Z[0,:] = c
- for k in range(0,N):
- Z[k+1] = Z[k] + H*F(t[k],Z[k])
- return t,Z
- a = 0
- b = 1
- N = 100
- c = np.array([1,2,1])
- t,result = EulerMethod(a,b,c,N,F)
- result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement