Skip to content

Instantly share code, notes, and snippets.

@Dabsunter
Created February 21, 2021 13:19
Show Gist options
  • Save Dabsunter/83d1cc46b5ac88dd935ffbc66f394109 to your computer and use it in GitHub Desktop.
Save Dabsunter/83d1cc46b5ac88dd935ffbc66f394109 to your computer and use it in GitHub Desktop.
# marche que pour le 2nd ordre
def euler2(F, a,b, y0, yp0, n):
h = (b-a)/n
T = np.linspace(a,b,n+1)
Yp = np.zeros(n+1)
Y = np.zeros(n+1)
Y[0] = y0
Yp[0] = yp0
for i in range(n):
Y[i+1] = Y[i] + h*Yp[i]
Yp[i+1] = Yp[i] + h*F(Y[i], Yp[i], T[i])
return Y,Yp,T
def euleryoussranicolazo(F,a,b,y0,h):
Y = [y0]
T = [a]
t = a;
while t < b:
y = Y[-1] + h*F(Y[-1], t)
t += h
Y.append(y)
T.append(t)
return Y,T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment