Académique Documents
Professionnel Documents
Culture Documents
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.
𝑥 − 𝑥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;
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