# -*- coding: utf-8 -*- """ Created on Fri Mar 25 14:23:19 2022 @author: turinici Resolution avec Euler Explicite de l'equation z'= i z(t) avec i = sqrt(-1) """ import numpy as np import matplotlib.pyplot as plt #%matplotlib auto T=100.0*2*np.pi h = 2*np.pi/100 N=int(T/h) U0=np.array([1,0]) U = np.zeros((N+1,2)) U[0]=U0 def f(t,z):#pour rappel z'=iz s'ecrit (x,y)' = (-y,x) avec x=Re(z), y=Im(z) return np.array([-z[1],z[0]]) #implementation Euler Explicite for k in range(N): U[k+1]=U[k]+h*f(k*h,U[k]) plt.figure(1) plt.subplot(1,2,1) plt.plot(np.linspace(0,T,N+1),U[:,0],'-r') plt.legend(['Re(U)']) plt.subplot(1,2,2) plt.plot(np.linspace(0,T,N+1),U[:,1],'--b') plt.legend(['Im(U)'])