TP 1 - Analyse Numrique
Encadr par : Monsieur M. El Hatri
DE RUNGE-KUTTA
: Matlab de Simulink.
On cre un nouveau fichier M-file qui porte le nom
Tp1cauchy dans lequel on met notre code :
Function [x,y] = Tp1cauchy (x0,y0,g,h)
Nx=9;
tx =x0:h:x0+h*Nx;
ty =y0;
for i =1:9
x= tx(i);
y= ty(i);
f1= eval(f);
x= tx(i)+(h/3);
y= ty(i)+f1*h/3;
f2= evaluer(f);
x=tx(i)+(2*h/3);
y= ty(i)+f2*2*h/3;
f3= evaluer(f);
ty(i+1)= ty(i)+h*(f1+4*f2+f3)/6;
end
x=tx;
1
y=ty;
x0=1;
y0=1;
xf=9;
h=[0,1 0,01];
sym b =['-',':'];
f='t/(1-t+ exp(-t))^2+(1+(1-t+exp(-t)))';
x=x0:xf;
y=2-1./x;
plot(x,y,'0');
title ('La solution thorique (0); Tp1cauchy pas = 0.1(-) pas
=1(:)');
for i= 1 : length (h);
[a,b]= Kutta3(x0,y0,h(i),f);
plot [a,b,sym b(i)];
hold on
end
grid ,hold off
u(0)=1/2
U(t)=1/(1-t+ e-t )
yi
Ei
0.0000
0.5000
0.0000
0.0100
0.5050
0.0000
0.0200
0.5101
0.0000
0.0300
0.5153
0.0000
0.0400
0.5206
0.0001
0.0500
0.5259
0.0001
0.0600
0.5313
0.0001
0.0700
0.5368
0.0001
0.0800
0.5424
0.0001
0.0900
0.5481
0.0001
0.1000
0.5539
0.0001
0.1100
0.5598
0.0002
0.1200
0.5658
0.0002
0.1300
0.5718
0.0002
0.1400
0.5780
0.0002
0.1500
0.5843
0.0002
0.1600
0.5907
0.0003
0.1700
0.5972
0.0003
0.1800
0.6038
0.0003