Académique Documents
Professionnel Documents
Culture Documents
plot(t,y1,'o-r')
hold on
f2=inline('(t-y2)/2');
a=0;
b=6;
h=0.1;
N=floor((b-a)/h);
t=[a:h:b];
y2=zeros(1,N); y2(1)=1;
for i=1 : N
k1=f2(t(i),y2(i));
k2=f2(t(i)+h/2,y2(i)+k1*h/2);
k3=f2(t(i)+h/2,y2(i)+k2*h/2);
k4=f2(t(i)+h,y2(i)+k3*h);
y2(i+1)=y2(i)+(h/6)*(k1+2*k2+2*k3+k4);
end
plot(t,y2,'o-g')
hold on
Application2 avec méthode de heun:
f3=inline('(t-y3)/2');
a=0;
b=6;
h=0.1;
N=floor((b-a)/h);
t=[0:0.1:6];
y3=zeros(1,N); y3(1)=1;
for i=1 :N
y3(i+1)=y3(i)+h/2*(f3(t(i),y3(i))+f3(t(i+1),y3(i)+h*f3(t(i),y3(i))))
end
plot(t,y3,'o-b')
Maintenant, On va essayer une nouvelle commande qui donne le résultat d'Algorithme de Runge
kutta ordre 3(ODE23) ou Runge kutta ordre 4(ODE 45):
a=0;
b=6;
h=0.1;
N=floor((b-a)/h);
t=[a:h:b];
eqs=@(t,y3)[(t-y3)/2]
[t,y3]=ode45(eqs,[0;6],1)
plot(t,y3,'o-r')
Application 3: soit le problème de Cauchy :
Y'=y-2x/y
Y(0)=1
plot(t,y1,'o-r')
hold on
f2=inline('y2-2*t/y2');
a=0;
b=1;
h=0.02;
N=floor((b-a)/h);
t=[a:h:b];
y2=zeros(1,N); y2(1)=1;
for i=1 : N
k1=f2(t(i),y2(i));
k2=f2(t(i)+h/2,y2(i)+k1*h/2);
k3=f2(t(i)+h/2,y2(i)+k2*h/2);
k4=f2(t(i)+h,y2(i)+k3*h);
y2(i+1)=y2(i)+(h/6)*(k1+2*k2+2*k3+k4)
end
plot(t,y2,'o')
hold on
f3=inline('y3-2*t/y3');
a=0;
b=1;
h=0.02;
N=floor((b-a)/h);
t=[0:0.02:1];
y3=zeros(1,N); y3(1)=1;
for i=1 :N
y3(i+1)=y3(i)+h/2*(f3(t(i),y3(i))+f3(t(i+1),y3(i)+h*f3(t(i),y3(i))))
end
plot(t,y3,'o-r')
a=0; b=1;
h=0.02;
t=[a:h:b];
plot(t,sqrt(2*t+1),'g')
grid on
Maintenant, Avec la commande qui donne le résultat d'Algorithme de Runge kutta ordre 3(ODE23)
ou Runge kutta ordre 4(ODE 45):
a=0;
b=1;
h=0.1;
N=floor((b-a)/h);
t=[a:h:b];
eqs=@(t,y4)[y4-2*t/y4]
[t,y4]=ode45(eqs,[0;1],1)
plot(t,y4,'o-y')
CONCLUSION :
On constate que les 3 méthodes nous donnent un bon approchement à la solution
exacte, Mais cette hypothèse peut être partiellement fausse si on commence à
varier les intervalles ou les nombres d’itérations, et aussi que le cout et la
précision de chacune de ces trois méthodes dépend des paramètres qu’on a
mentionnés
FIN DU COMPTE-RENDU