Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Descripcin
Rejilla de datos
Lookup tabla 1D
Lookup tabla 2D
Con mtodo FFT
Tabla 4.1
El programa interpDemo de la figura 4.1, presenta el problema de interpolacin de una manera grfica (figura
4.2).
function InterpDemo()
% Demo Interpolacion
E. Raffo Lecca
x=[0 1 4 6];
y=[1 -1 1 -1];
x0=0:0.10:6;
ylin=interp1(x,y,x0,'linear');
yspline=interp1(x,y,x0,'spline');
ycubic=interp1(x,y,x0,'cubic');
% mostrando grafica
plot(x,y,'o');
% dato
hold on; %para colocar varios plot en una sola figura; por default es
off
plot(x0,ylin,x0,yspline,x0,ycubic); %comando plotear
legend('dato','lineal','spline','cubica',0); %legend('
',pos);
','
',...,'
Interpolacin Lineal
Los polinomios interpolantes, son los que
ms se usan en los clculos por computadora;
y se basan en plantear un polinomio de grado
n que pasa por los puntos x0, x1, x2,...., xn.
Existen dos mtodos difundidos: el de
Lagrange y de Newton.
( x ; a0 , a1 ,..., an )
( xi ; a0 , a1 ,..., an ) f i ,
i 0,..., n
( x ; a0 , a1 ,..., an ) a0 a1 x a2 x ... an x
Forma de Lagrange
Considere el par de puntos
(x0 , f (x0)) y (x1 , f (x1))
aproximado mediante una lnea recta (ver figura 4.3).
Fig. 4.3.
f ( x1 ) f ( x0 ) P( x) f ( x0 )
x1 x0
x x0
( x x0 )( f ( x1 ) f ( x0 ))
P ( x) f ( x0 )
( x1 x0 )
P ( x) f ( x0 )
x x0
x x1
f ( x1 )
x0 x1
x1 x0
Fig. 4.4
, i = 0, 1,...,n
ik
( x x0 )( x x1 )...( x x k 1 )( x x k 1 )...( x x n )
Adems de :
g k ( x k ) ( x k xi )
i 0
ik
i 0 x k x i
ik
ik
ik
f ( x k ) Lk ( x )
k 0
0 1 4 6
1 1 1 1
( x x1 )( x x 2 )( x x3 )
L0 ( x)
( x0 x1 )( x0 x 2 )( x0 x3 )
( x x0 )( x x 2 )( x x3 )
L1 ( x)
( x1 x0 )( x1 x 2 )( x1 x3 )
( x x0 )( x x1 )( x x3 )
L2 ( x )
( x 2 x0 )( x 2 x1 )( x 2 x3 )
( x x0 )( x x1 )( x x 2 )
L3 ( x)
( x3 x0 )( x3 x1 )( x3 x 2 )
P(x) = -1
f (xi)
Li (x)
0
1
2
3
1
-1
1
-1
-0.33333
1.06667
0.33333
-0.06667
Para x = 3
P(3) = 0
f (xi)
Li (x)
0
1
2
3
1
-1
1
-1
-0.25000
0.60000
0.75000
-0.10000
xi
yi
0
1
2
3
1.05
1.10
1.15
1.20
1.02470
1.04881
1.07238
1.09544
f (xi)
Li (x)
1.02470
1.04881
1.07238
1.09544
-0.064
0.672
0.448
-0.056
Forma de Newton
En la figura 4.5, se presenta el Algoritmo de
Lagrange, y en la figura 4.6 el programa
lagrange.m.
Lagrange
Suma = 0
for k = 0 to n
prod1 = 1
prod2 = 1
for i = 0 to n
if i k then
prod1 = prod1 * (x x[i])
prod2 = prod2 * (x[k] x[i])
L = prod1 / prod2
Suma = Suma + L * F[k]
Polinomio es igual a Suma
End Lagrange
Fig. 4.5: Algoritmo de Lagrange
haciendo Pn (xi) = fi
i = 0,1,..., n
f 0 Pn ( x0 ) b0
f1 Pn ( x1 ) b0 b1 ( x x0 )
f 2 Pn ( x 2 ) b0 b1 ( x x0 ) b2 ( x x0 )( x x1 )
luego
f 01
f1 f 0
x1 x0
f12
f 2 f1
x 2 x1
f 012
f12 f 01
x 2 x0
Pn ( x) f 0 f 01 ( x x0 ) f 012 ( x x0 )( x x1 ) ...
... f 012......k ( x x0 )( x x1 )...( x x k 1 )
bn f [ x0 , x1 ,...., x n ]
f [ xi , x j ]
f ( x j ) f ( xi )
x j xi
f [ xi , x j , x k ]
f [ x j , x k ] f [ xi , x j ]
x k xi
y en general :
f [ x1 , x 2 ,...., x k ] f [ x0 , x1 ,...., x k 1 ]
f [ x0 , x1 , x 2 ,..., x k ]
x k x0
El esquema para las diferencias divididas es
k 1 k 2
x0
f0
f 01
f 012 f 0123
x1
f1
f12
f123
x2
f2
f 23
4.2: Diferencias divididas
Tabla
xn
fn
xi
yi
1
4
6
5
0 1.3862944 1.7917595 1.6094379
f ( x1 ) f ( x0 ) 1.3862944
f [ x0 , x1 ]
0.46209813
x1 x0
4 1
1.7917595 1.3862944
f [ x1 , x 2 ]
0.20273255
64
1.6094379 1.7917595
f [ x 2 , x3 ]
0.18232160
56
f [ x1 , x 2 ] f [ x0 , x1 ]
f [ x0 , x1 , x 2 ]
0.05187312
6 1
f [ x 2 , x3 ] f [ x1 , x 2 ]
f [ x1 , x 2 , x3 ]
0.02041095
54
f [ x1 , x 2 , x3 ] f [ x0 , x1 , x 2 ]
f [ x0 , x1 , x 2 , x3 ]
0.00786554
5 1
xi
f (xi)
0
1
2
3
1
4
6
5
0
1.3862944
1.7917595
1.6094379
0.46209813 -0.05187312
0.20273255 -0.02041095
0.18232160
3
0.00786554
La forma de Newton es :
Pn ( x) 0 0.46209813 ( x 1) 0.05187312 ( x 1)( x 4) ....
.... 0.00786554 ( x 1)( x 4)( x 6)
Pn (2) 0.62877
0 1 2 3
0 1 4 6
1 1 1 1
xi
yi
0
1
2
3
0
1
4
6
1
-1
1
-1
-2.0
0.66666667
-1.0
0.66666667
-3.3333333
-0.16666667
Algoritmo de Neville
Una forma de resolver el problema de interpolacin
es considerar resolver el problema para un pequeo
conjunto de valores y despus actualizar estas
soluciones para obtener la solucin completa.
Sea por el conjunto de puntos (xi , fi ) , i = 0,1,....,n
se denota por
Pi0 i1 ...ik
al polinomio, donde
Pi0 i1 ...ik ( xi j ) f i j
j 0,1,...., k
Recursivamente se tiene :
Pi ( x) f i
Pi0 i1 ...ik ( x)
k 0
x0
k 1
f 0 P0 ( x)
P01 ( x)
x1
f1 P1 ( x)
P012 ( x)
P12 ( x)
x2
f 2 P2 ( x)
P0123 ( x)
P123 ( x)
P23 ( x)
x3
f 3 P3 ( x)
2 3
1
3
1
1
1
1
1
3
(2 0)( 1) (2 1)(1)
P01 (2)
3
1 0
(2 1)(1) (2 2)( 1)
P12 (2)
1
2 1
(2 2)( 1) (2 3)(1)
P23 (2)
1
32
(2 0)(1) (2 2)( 3)
P012 (2)
1
20
(2 1)(1) (2 3)(1)
P123 (2)
1
3 1
(2 0)(1) (2 3)(1)
P0123 (2)
1
30
Haciendo
Ti k , k Pi , i 1,..., i k
se tiene la tabla
x0
f 0 T00
T11
x1
f1 T10
T22
T21
x2
f 2 T20
T32
T31
x3
f 3 T30
T33
donde :
Ti 0 f i
Tik
( x xi k ) Ti , k 1 ( x xi ) Ti 1, k 1
Ti , k 1
( xi xi k )
Ti , k 1 Ti 1, k 1
x xi k
1
x xi
, 1 k i , i 0,1,..., n
Error en una
interpolacin polinomial
Sea la funcin f (x) y para sus valores
f i f ( xi ) , i 0,1,..., n
los cuales son interpolados. Una interpolacin polinomial
P(x)=P0...n (x) con
P ( xi ) f i
, i 0,1,..., n
f ( x) P ( x)
para valores xxi , i=0,1,...,n.
Bajo ciertas condiciones es posible acotar el error.
Teorema
Si una funcin f tiene (n+1) derivadas; entonces
para cada argumento X , existe un nmero en el
ms pequeo intervalo I [xo, ...., xn, X ] que contiene
a X y a todas las abscisas xi , satisfaciendo:
( X ) f ( n1) ()
f ( X ) P01...n ( X )
(n 1)!
donde
( x) ( x x0 )( x x1 )....( x x n )
As:
f ( x) cos x
i
xi
, i 0,1,2,3,4,5 o n 5
10
cos
sin x P ( x) ( x x0 )( x x1 )....( x x5 )
720
| ( x) |
sin x P( x)
, donde I [ x0 ,...., x n , x)
720
adicionan nuevos
incrementar el
puntos, se
grado del
La propiedad
L ( xi ) y i
, i 0,1,2,..., n
indica que
x xi 1
x xi
L( x) yi
yi 1
xi xi 1
xi 1 xi
, xi x xi 1
, i 0,1,2,...., n 1
1 1 1 1