Documentos de Académico
Documentos de Profesional
Documentos de Cultura
INTERPOLACIO
N
f 2 x b0 b1 x x0 b2 x x0 x x1
4.54
f x a0 a1 x a2 x
4.55
Donde:
a0 b0 b1 x0 b2 x0 x1
4.56
a1 b1 b2 x0 b2 x
4.57
a2 b2
4.58
f 2 x0 b0 b1 x0 x0 b2 x0 x0 x0 x1
f 2 x0 b0
4.59
4.60
Para b1
f 2 x b0 b1 x x0 b2 x x0 x x1
f 2 x1 f 2 x0 b1 x1 x0 b2 x1 x0 x1 x1
f 2 x1 f 2 x0 b1 x1 x0
b1
f 2 x1 f 2 x0
x1 x0
4.63
4.64
4.61
4.62
Para b2
f 2 x1 f 2 x0
x2 x0 b2 x2 x0 x2 x1
f 2 x2 f 2 x0
x1 x0
4.65
Ejemplo
a.- Encuentre el valor del logaritmo de 4 mediante un polinomio
de interpolacin de segundo orden. Use los valores del ejemplo
anterior
b.- Calcule el error relativo porcentual y comprelo con el que se
obtuvo con el polinomio de primer orden.
b2 = -0.012940
f 2 x b0 b1 x x0 b2 x x0 x x1
0.602060 0.600985
ep
*100 0.178550%
0.602060
b1 f x1 , x0
b2 f x2 , x1 , x0
.
.
bn f xn , xn 1 ,...., x1 , x0
9
4.7
0
4.7
1
4.7
2
n 1
Ejemplo
a).- Calcule el valor del logaritmo de 4, por medio de un
polinomio de interpolacin de diferencias divididas de
newton de tercer orden
b).-Compara el error porcentual que se obtuvo con los
polinomios de primer, segundo y tercer orden. Use el
valor de log 4 = 0.602060 como el valor verdadero y los
siguientes datos:
NUMERO
LOGARITMO10
0.477121
3.5
0.544068
4.5
0.653212
0.698970
x0 3 f x0 0.477121
x1 3.5 f x1 0.544068
x2 4.5 f x2 0.653212
x3 5 f x3 0.698979
Mediante la ecuacin (4.69) se calcula b 0
b0 f x0
b0 0.47712
Mediante la ecuacin (4.70) se calcula b 1
f x1 f x0 0.544068 0.477121
b1 f x1 , x0
x1 x0
3 .5 3
b1 0.133894
f x2 , x1 f x1 , x0
b2 f x2 , x1 , x0
x2 x0
f x2 f x1 0.653212 0.544068
f x2 , x1
0.109144
x2 x1
4 .5 3 .5
f x1 , x0 0.133894
0.109144 0.133894
b2 f x2 , x1 , x0
4 .5 3
b2 0.016499
0.011753 (0.016499)
b3 f x3 , x2 , x1 , x0
53
b3 0.002373
=LOG10(B
4)
=(C15-C14)/(B15B14)
=(D15-D14)/(B16B14)
=(E15-E14)/(B17B14)
Valor
interpolado
=$A$21B14
=$A$21B15
=$A$21B$16
=$A$21B17
C24 = $C$14+($D$14*$B$21)+($E$14*$B$21*$C$21)+
($F14*$B$21*$C$21*$D$21)
C25 = ABS(((0.60206C24)/C24)*100)
if n==2
b(ii)=f(ii);
b(ii+1)=(f(ii+1)-f(ii))/(x(ii+1)-x(ii));
b(ii+2)=(((f(ii+2)-f(ii+1))/(x(ii+2)-x(ii+1)))b(ii+1))/(x(ii+2)-x(ii));
f2=b(ii)+b(ii+1)*(xd-x(ii))+b(ii+2)*(xd-x(ii))*(xdx(ii+1));
ep=abs((freal-f2)/freal)*100;
fprintf('Interpolacion de segundo orden %6.4f Error
%6.2f\n',f2,ep)
end
if n==3
b(ii)=f(ii);
b(ii+1)=(f(ii+1)-f(ii))/(x(ii+1)-x(ii));
b(ii+2)=(((f(ii+2)-f(ii+1))/(x(ii+2)-x(ii+1)))-b(ii+1))/(x(ii+2)-x(ii));
bb=(((f(ii+3)-f(ii+2))/(x(ii+3)-x(ii+2)) - (f(ii+2)-f(ii+1))/(x(ii+2)x(ii+1))))/(x(ii+3)-x(ii+1));
bb1=((f(ii+2)-f(ii+1))/(x(ii+2)-x(ii+1)) - ((f(ii+1)-f(ii))/(x(ii+1)x(ii))))/ (x(ii+2)-x(ii));
b(ii+3)=(bb-bb1)/(x(ii+3)-x(ii));
f3=b(ii)+b(ii+1)*(xd-x(ii))+b(ii+2)*(xd-x(ii))*(xd-x(ii+1))+b(ii+3)*(xd-x(ii))*(xdx(ii+1))*(xd-x(ii+2));
ep=abs((freal-f3)/freal)*100;
fprintf('Interpolacion de tercer orden %6.4f Error %6.2f\n',f3,ep)
end
f n x Li x f xi
4.78
i 0
Donde:
Li x
j 0
j i
x xj
xi x j
producto de
4.79
Para n=1
f1 x L 0 x f x0 L1 f x1
4.80
x x0
x x1
f1 x
f x0
f x1
x0 x1
x1 x0
4.81
Para n=2
f 2 x L 0 x f x0 L1 f x1 L2 f x2
x x1
x0 x1
f 2 x
x x2
x x0
f x0
x0 x2
x1 x0
4.82
x x0
x x2
f x1
x1 x2
x2 x0
x x1
f x2
x2 x1
4.83
Para n=3
x x1
x0 x1
f 3 x f x0
x x0
f x2
x2 x0
x x2
x0 x2
x x1
x2 x1
x x3
x x0
f x1
x0 x3
x1 x0
x x3
x x0
f x3
x2 x3
x3 x0
x x2
x1 x2
x x1
x3 x1
x x3
x1 x3
x x2
x3 x2
4.84
Para n=4
x x1
x0 x1
f 4 x f x0
x x2
x0 x2
x x3
x0 x3
x x4
x x0
f x1
x0 x4
x1 x0
x x0
x
2 0
x x1
x
2 1
x x3
x
2 3
x x0
x x4
f x3
x
x
x
x
2 4
3 0
x x0
x
4 0
x x1
x
4 1
x x2
x
4 2
x x3
x
4 3
f x2
f x4
x x2
x1 x2
x x1
x
3 1
x x3
x1 x3
x x2
x
3 2
x x4
x1 x4
x x4
x
3 4
4.85
Ejemplo
a).- Calcule el valor del logaritmo de 4, por medio de diferentes
polinomios de interpolacin de Lagrange
b).-Compara el error porcentual que se obtuvo con los
polinomios de primer, segundo y tercer orden. Use el valor de
log 4 = 0.602060 como el valor verdadero y los siguientes
datos:
NUMERO
LOGARITMO10
3
3.5
0.477121
0.544068
4.5
5
0.653212
0.698970
x0 3 f x0 0.477121
x1 3.5 f x1 0.544068
x2 4.5 f x2 0.653212
x3 5 f x3 0.698979
Para n=1
x x0
x x1
f1 x
f x0
f x1
x0 x1
x1 x0
4 3 .5
43
f1 4
(0.477121)
(0.544068) 0.611132
3 3.5
3 .5 3
Para n=2
x x1
x
0 1
f 2 x
x x2
x x0
f x0
x
x
x
2
0
1 0
x x0
x x2
f x1
x
x
x
x
1 2
2 0
x x1
f x2
x
x
2 1
4 3 .5 4 4 .5
4 3 4 4 .5
4 3 4 3 .5
(0.477121)
(0.544068)
(0.653212)
3 3 .5 3 4 .5
3 .5 3 3 .5 4 .5
4 3 .5 4 .5 3 .5
f2 x
f 2 4 0.602823
= (E18-B15)/(B14-B15)*C14+(E18-B14)/(B15-B14)*C15
B22 = ((($E$18-B15)*($E$18-B16))/((B14B15)*(B14-B16)))*C14+((($E$18-B14)*($E$18B16))/((B15-B14)*(B15-B16)))*C15+((($E$18B14)*($E$18-B15))/((B16-B14)*(B16-B15)))*C16
B23 = ((($E$18-B15)*($E$18-B16)*($E$18B17))/((B14-B15)*(B14-B16)*(B14-B17))*C14+
((($E$18-B14)*($E$18-B16)*($E$18-B17))/
((B15-B14)*(B15-B16)*(B15-B17)))*C15+
((($E$18-B14)*($E$18-B15)*($E$18-B17))/
((B16-B14)*(B16-B15)*(B16-B17)))*C16+
((($E$18-B14)*($E$18-B15)*($E$18-B16))/
((B17-B14)*(B17-B15)*(B17-B16)))*C17)
clear all
clc
x_datos=input('Ingrese valores de x: ');
y_datos= log10(x_datos);
x=input('Ingrese valor de x a interpolar: ');
n_datos=length(x_datos);
sum=0;
for i=1:n_datos
producto=y_datos(i);
for j=1:n_datos
if i~=j
producto=producto*(x-x_datos(j))/(x_datos(i)x_datos(j));
end
end
sum=sum+producto;
end
yi=sum
Ejemplos
18.2
APLICACIN
>> x=0:1.0:5;
>> y=[1.0 -0.6242 -1.4707 3.2406 -0.7366
-6.3717];
>> xi=0:0.1:5;
>> ylin=interp1(x,y,xi,'linear');
>> yispline=interp1(x,y,xi,'spline');
>> yipch=interp1(x,y,xi,'pchip');
>> yfuncion=1.5.^xi.*cos(2*xi);
>> plot(x,y,'o',xi,yfuncion,xi,ylin,'--')
>> title('INTERPOLACION LINEAL FUNCION')
>> plot(x,y,'o',xi,yfuncion,xi,yispline,'--')
>> title('INTERPOLACION SPLINE vs.
FUNCION')