Vous êtes sur la page 1sur 3

Exemple 1

( ) ( )

Solution par la méthode d’Euler Explicite

( )

Solution par recul en arrière (Euler Explicite)

( )

%% solution pour x>1


clear
clc

n=20
a=1;
b=2;
dx=(b-a)/n;
y(1) = 0;
x(1) = 1;
for i=1:n
x(i+1) = x(i) + dx;
y(i+1) = y(i) + (dx/x(i))*(2*y(i) + x(i)^2);
end
3
ye = x.^2.*log(x);
ezplot('x^2*log(x)',[a,b])
hold on 2.5
plot(x,y,'r.')
2

1.5

0.5

1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2


x
% ----------------------------------------------
% solution pour 0 < x < 1
% ----------------------------------------------
clear
clc

n=100
a=1;
b=0;
dx=abs((b-a)/n);
y(n) = 0;
x(n) = a;
for i=n:-1:2
x(i-1) = x(i) - dx;
y(i-1) = y(i) - (dx/x(i))*(2*y(i) + x(i)^2);
end
ye = x.^2.*log(x);
ezplot('x^2*log(x)',[a,b])
hold on
plot(x,y,'r.')
0

-0.02

-0.04

-0.06

-0.08

-0.1

-0.12

-0.14

-0.16

-0.18

-0.2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
Exemple 2

( )

Explicite

Implicite

√ ( )

Second ordre

( )
( )

Script MATLAB

% équation : 2*y*Dy=1-x avec y(0)=1 (3/2 - (t - 1)2/2)1/2


1.4
clear
clc 1.2

n=10 1
a=0;
b=3; 0.8
y0=1
y(x)

Exacte
dx=(b-a)/n; 0.6 Explicite
x(1) = a; Implicite
ye(1) = y0; % explicite 2nd Ordre
0.4
yi(1) = y0; % implicite Moy (Exp+Imp)/2
ys(1) = y0; % second ordre
0.2

0
fe = @(x,y) y + dx*(1-x)/(2*y); 0 0.5 1 1.5 2 2.5 3
x
fi = @(x,y) 0.5*(y + sqrt(y^2 + 2*dx*(1-x)));
fs = @(x,y) fe(x,y)-0.5*(dx^2)*( 1/(2*y) + ((1-x)^2)/(4*y^3));

for i=1:n
x(i+1) = x(i) + dx;
ye(i+1) = fe(x(i),ye(i));
yi(i+1) = fi(x(i+1),yi(i));
ys(i+1) = fs(x(i),ys(i));
end
ezplot(z(1),[a,b],,'LineWidth',2)
hold on
plot(x,ye,'k -.')
plot(x,yi,'k --')
plot(x,ys,'k -.o')
plot(x,0.5*(yi+ye),'k -.+')

Vous aimerez peut-être aussi