Vous êtes sur la page 1sur 3

TP1-MATHEMATIQUE DE

L’INGENIEUR
SALHI ABDELLATIF

EXERCICE 1
Construire, selon la méthode de Lagrange, le polynôme d’interpolation
P2(X) de degré deux qui interpole les points :
(x0;y0) = (0;1) ; (x1;y1) = (1;2) et (x2;y2) = (2;5).
1. Déterminer d’abord ce polynôme de façon analytique.

le polynôme 𝑃2(𝑥) pour 𝑛 = 0, 1, 2, il vient :


𝑃2(𝑥) = 𝑦0 × 𝐿0(𝑥) + 𝑦1 × 𝐿1(𝑥) + 𝑦2 × 𝐿2(𝑥)

𝑥 − 𝑥1 𝑥 − 𝑥2
L0(x) = ×
𝑥0 − 𝑥1 𝑥0 − 𝑥2

𝑥 − 𝑥0 𝑥 − 𝑥2
L1(x) = ×
𝑥1 − 𝑥0 𝑥1 − 𝑥2

𝑥 − 𝑥0 𝑥 − 𝑥1
L2(x) = ×
𝑥2 − 𝑥0 𝑥2 − 𝑥1

⇒ 𝑃2(𝑥) = 𝑥 2 + 1
2. Écrire un algorithme Matlab permettant l’implémentation de la méthode
de Lagrange. Détermine ce polynôme.
close all;
clc;

x(1)=0; x(2)=1;x(3)=2; n=3;%?POLYNOME?DE?DEGRE?2


y(1)=1;y(2)=2;y(3)=5;interv=1000;dx=(x(3)-x(1))/interv;
xvar=x(1):dx:x(3);polyn=0;
col={'+k','+r','+m'};

for i=1:n

lag=1;
for j=1:n
if(i~=j)
lag=(xvar-x(j))./(x(i)-x(j)).*lag;
end
end
figure(1);
plot(x(i),y(i),col{i},'MarkerSize',12,'LineWidth',2);
hold on;
polyn=polyn+lag.*y(i);
end
hold on
plot(xvar,polyn,'LineWidth',1);
hold on;
xlabel('x');
ylabel('y')
axis([-0.5 2.5 -0.5 5.5])

title('Interpolation:selon Lagrange')

p=2;coeff=polyfit(xvar,polyn,p)%

2
3

Vous aimerez peut-être aussi