Vous êtes sur la page 1sur 24

AITEUR

UEF 23

Analyse numérique et
statistiques appliquées à
l’électrotechnique
Programmes

Bessection
xa=0
xb=3
eps=10^-3
f=inline('(x/2)-cos(x)')
%if abs((xb-xa)/2)<eps
f(xa)*f(xb)<0
while abs((xb-xa)/2)>eps
xmoy=(xa+xb)/2
if f(xmoy)*f(xb)<0
xa=xmoy
else
xb=xmoy
end
end.

………………………………………………………………………….
Euler

%INTRODUIRE LE PAS (h) et les valeurs de x et y

h=0.0001;
x=0:h:4;
y=exp(x);

%CALCUL NUMERIQUE

for i=2:length(x)-1
I(1)=h*y(2);
I(i)=h*y(i+1)+I(i-1);
end

%AFFICHAGE
I(end)
…………………………………………………………………………………………………
Jacobi
clc;clear all;close all
%%metode de jacobi
a=[5 -1 -1;1 6 2;1 -1 4];
b=[5;-3;6];
ep=0.0001;
x0=b./diag(a);
x1=x0-(a*x0-b)./diag(a);
while max(abs(x1-x0))>ep
x0=x1;
x1=x0-(a*x0-b)./diag(a);
end
X=x1
……………………………………………………………………………………………..
Newton
clc;clear all;
x0=0;
eps=0.5;
y=inline('cos(x)-x');
dy=inline('-sin(x)-1');
x1=x0-y(x0)/dy(x0);
while abs(x1-x0)>eps;
x0=x1;
x1=x0-y(x0)/dy(x0);
end
x1
abs(x1-x0)
…………………………………………………………………………………………………..
Simpsone
%méthode de simpsone
h=1
x=[0:h:4];
y=exp(x);
z=exp(x)-1;
for i=2:length(x)
I(1)=h/3*y(1);
if rem(i,2)==0 & i<length(x)
I(i)=4/3*h*y(i)+I(i-1);
else if rem(i,2)~=0 & i<=length(x)-1
I(i)=2/3*h*y(i)+I(i-1);
else
I(i)=h/3*y(i)+I(i-1);
end
end
end
I(i)
plot(x,I,x,z)

………………………………………………………………………………………………………
Trapez

%INTRODUIRE LE PAS (h) et les valeurs de x et y


h=0.0001;
x=0:h:4;
y=exp(x);

%CALCUL NUMERIQUE

for i=2:length(x)-1
I(1)=h/2*(y(2)+y(1));
I(i)=h/2*(y(i+1)+y(i))+I(i-1);
end

%AFFICHAGE
I(end)
……………………………………………………………………………………………

Vous aimerez peut-être aussi