









Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!










Polinomio de Lagrange
El polinomio de Lagrange, llamado así en honor a Joseph Louis de Lagrange, sirve para interpolar
un conjunto de n datos siempre será de grado n- 1
0
1
2
2
3
3
𝑛
𝑛
𝑁
𝑖
𝑖
𝑛
𝑖= 0
Donde
N= es el grado del polinomio (N=n-1)
N=es el número de datos experimentales (n=N+1)
La interpolación consiste en encontrar un polinomio de grado n que pase pro los puntos
0
0
1
1
𝑛
𝑛
)), se construye un cociente 𝐿
𝑛
𝑖
) = 0 cuando
1
𝑛
𝑘
Se requiere entonces que el numerador contenga
0
1
𝑘− 1
𝑘+ 1
𝑛
El denominador debe coincidir cuando el numerador cuando 𝑥 = 𝑥 𝑘
𝑖
𝑗
𝑖
𝑗
𝑛
𝑗= 1
𝑖≠𝑗
Suponiendo experimentalmente que tenemos 2 datos experimentales n=
i=
1
= x
2
1
2
i=
2
1
2
1
x
𝑁
𝑖
𝑖
𝑛
𝑖= 0
1
1
1
2
2
3
1
3
1
2
3
2
x
4
3
4
i=
4
1
4
1
2
4
2
3
4
3
x
𝑃
1
(𝑥) = 𝑦
1
(
𝑥 − 𝑥
2
𝑥 1
− 𝑥 2
) (
𝑥 − 𝑥
3
𝑥 1
− 𝑥 3
) (
𝑥 − 𝑥
4
𝑥 1
− 𝑥 4
) + 𝑦
2
(
𝑥 − 𝑥
1
𝑥 2
− 𝑥 1
) (
𝑥 − 𝑥
3
𝑥 2
− 𝑥 3
) (
𝑥 − 𝑥
4
𝑥 2
− 𝑥 4
) + 𝑦
3
(
𝑥 − 𝑥
1
𝑥 3
− 𝑥 1
) (
𝑥 − 𝑥
2
𝑥 3
− 𝑥 2
) (
𝑥 − 𝑥
4
𝑥 3
− 𝑥 4
)
4
(
𝑥 − 𝑥
1
𝑥
4
− 𝑥
1
) (
𝑥 − 𝑥
1
𝑥
4
− 𝑥
1
) (
𝑥 − 𝑥
3
𝑥
4
− 𝑥
3
)
Ejemplo 1
Obtener el polinomio de Lagrange que pase por todos los datos que se encuentran en la siguiente
tabla.
Calcular, con el polinomio obtenido, el valor de Y cuando X=1.
1
2
1
2
3
1
3
2
2
1
2
1
3
2
3
2
3
1
3
1
2
3
2
2
2
2
2
2
2
2
2
2
𝑃
2
( 𝑥
) = − 0. 9 𝑥
2
2
2
2
Ejemplo 2
Obtener el polinomio de Lagrange que pasa por todos los puntos de la tabla anterior utilizando
Matlab y graficar en una misma figura los datos de la tabla y el polinomio encontrado. Estimar para
x=1.
clc;clear all; close all
x=[0 1 2];
y=[2.3 3.5 2.9];
syms X
L1=(X-x(2))/(x(1)-x(2))*(X-x(3))/(x(1)-x(3));
L2=(X-x(1))/(x(2)-x(1))*(X-x(3))/(x(2)-x(3));
L3=(X-x(1))/(x(3)-x(1))*(X-x(2))/(x(3)-x(2));
P2=y(1)L1+y(2)L2+y(3)*L3;
P2=vpa(expand(P2),5)
%interpolacion
x0=1.3;format short
i=double(subs(P2,x0))
%grafica
plot(x,y,'pm')
hold on
xg=0:0.01:2;
yg=subs(P2,xg);
plot(xg,yg,'c')
plot(x0,i,'dk')
legend('Datos experimentales')
Ejemplo 3
A partir de los datos anteriores obtener el polinomio de Lagrange de primer orden para interpolar el
valor de Y cuando X=1.3. comprar el resultado con el del ejercicio anterior.
1
1
%polinomio grado 3
x=5:5:20;
y=[102.5 204.1 198.3 101.0]
L1=(X-x(2))/(x(1)-x(2))(X-x(3))/(x(1)-x(3))(X-x(4))/(x(1)-x(4));
L2=(X-x(1))/(x(2)-x(1))(X-x(3))/(x(2)-x(3))(X-x(4))/(x(2)-x(4));
L3=(X-x(1))/(x(3)-x(1))(X-x(2))/(x(3)-x(2))(X-x(4))/(x(3)-x(4));
L4=(X-x(1))/(x(4)-x(1))(X-x(2))/(x(4)-x(2))(X-x(3))/(x(4)-x(3));
P3=y(1)L1+y(2)L2+y(3)L3+y(4)L4;
P3=vpa(expand(P3),5)
%interpolacion
i=double(subs(P3,x0))
%grafica
xg=5:0.01:20;
yg=subs(P3,xg);
plot(xg,yg,'g')
1
1
2
2
2
3
3
2
3
Tarea del Polinomio de Lagrange
x F(x)
clc, clear, close all
%Ejercicio 1. Tarea de Polinomios de Lagrange
%Definiendo las variables
x=[1 2.7 3.2 4.8 5.6];
y=[14.2 17.8 22 38.3 51.7];
%Definiendo la variable simbóica
syms X
%Coonstrucción del polinomio
L1=(X-x(2))/(x(1)-x(2))(X-x(3))/(x(1)-x(3))(X-x(4))/(x(1)-x(4))*(X-
x(5))/(x(1)-x(5));
L2=(X-x(1))/(x(2)-x(1))(X-x(3))/(x(2)-x(3))(X-x(4))/(x(2)-x(4))*(X-
x(5))/(x(2)-x(5));
L3=(X-x(1))/(x(3)-x(1))(X-x(2))/(x(3)-x(2))(X-x(4))/(x(3)-x(4))*(X-
x(5))/(x(3)-x(5));
L4=(X-x(1))/(x(4)-x(1))(X-x(2))/(x(4)-x(2))(X-x(3))/(x(4)-x(3))*(X-
x(5))/(x(4)-x(5));
L5=(X-x(1))/(x(5)-x(1))(X-x(2))/(x(5)-x(2))(X-x(3))/(x(5)-x(3))*(X-
x(4))/(x(5)-x(4));
%Polinomio de grado 4
P4=y(1)L1+y(2)L2+y(3)L3+y(4)L4+y(5)*L5;
P4=vpa(expand(P4),5)
%Comprobación
xi=3.2;
i=double(subs(P4,xi))
%Gráfica de los datos experimentales y el polinomio ajustado
plot(x,y,'*r')
grid on
hold on
xg=0:0.01:6;
yg=subs(P4,xg);
plot(xg,yg,'b')
title('Gráfica de los datos proporcionados y el polinomio ajustado de
grado 4°')
xlabel('x')
ylabel('F(x)')
legend('Datos experimentales','Polinomio ajustado de grado 4')
𝟐
2
2
0
1
2
%p3 tarea
clc;clear all; close all
x=[0 1 0.9];
y=sqrt(1+(x.^2)+(3*x));
syms X
L1=(X-x(2))/(x(1)-x(2))*(X-x(3))/(x(1)-x(3));
L2=(X-x(1))/(x(2)-x(1))*(X-x(3))/(x(2)-x(3));
L3=(X-x(1))/(x(3)-x(1))*(X-x(2))/(x(3)-x(2));
P2=y(1)L1+y(2)L2+y(3)*L3;
clc;clear;close all
%Ejercicio 4 tarea
%% %Polinomio grado 1
x=[20 30];
y=[38.6 30.1];
syms X
%Estableciendo términos
L1=(X-x(2))/(x(1)-x(2));
L2=(X-x(1))/(x(2)-x(1));
%Polinomio de grado 1
disp('Polinomio de Primer grado')
P1=y(1)L1+y(2)L2;
P1=vpa(expand(P1),5)
%Interpolación
x0=24;
i=double(subs(P1,x0))
%Gráfica de puntos dispersos
x=[0 5 10 20 30];
y=[31.2 34.8 43.6 38.6 30.1];
plot(x,y,'b*')
hold on
%Gráfica
xg=20:0.01:30;
yg=subs(P1,xg);
plot(xg,yg,'--r')
grid on
hold on
%% %Polinomio grado 2
x=[10 20 30];
y=[43.6 38.6 30.1];
%Estableciendo términos
L1=(X-x(2))/(x(1)-x(2))*(X-x(3))/(x(1)-x(3));
L2=(X-x(1))/(x(2)-x(1))*(X-x(3))/(x(2)-x(3));
1
2
2
3
3
2
http://test.cua.uam.mx/MN/Methods/Interpolacion/Lagrange/Lagrange.php
https://es.slideshare.net/KikePrieto1/an- 18 - interpolacionmetodo-de-lagrange