Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Splines
Splines
lisis Nume
rico
Tutorial de Ana
Interpolaci
on : Splines c
ubicos
tica
Informa
Pagina Web
Jes
us Garca Quesada
Departamento de Inform
atica y Sistemas
Universidad de Las Palmas de Gran Canaria
Pagina de Inicio
Contenido
JJ
II
Pagina 1 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
Indice General
POR SPLINES CUBICOS
1 INTERPOLACION
2 PROBLEMAS
Soluciones a los Problemas
3
16
tica
Informa
19
Pagina Web
Pagina de Inicio
Contenido
JJ
II
Pagina 2 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
1. INTERPOLACION
Supongamos que tenemos los n + 1 puntos:
Pk (xk , yk ), donde yk = f (xk ), k = 0, 1, . . . , n
tica
Informa
en los cuales se quiere interpolar la funcion f . Las abcisas no es necesario que sean
equidistantes, pero se suponen ordenados, o sea,
Pagina Web
Pagina de Inicio
para k = 0, 1, . . . , n 1
Para que s(x) interpole en los puntos P0 , P1 , . . . , Pn los qk (x) han de verificar :
(
qk (xk ) = yk
qk (xk+1 ) = yk+1 , k = 0, 1, . . . , n 1
Contenido
JJ
II
Pagina 3 de 22
Volver
(1)
Pantalla completa
Cerrar
Salir
ULPGC
tica
Informa
q (x)
q (x)
qn-1
(x)
Pagina Web
Pn-1
P1
P2
Pagina de Inicio
Pk
P0
P3
Contenido
Pk+1
Pn
JJ
II
Pagina 4 de 22
x0
x1
x2
x3
. . . . . .
xk
xk+1
. . . . . . . . .
xn-1
xn
Volver
ULPGC
lo cual supone 2n condiciones. Llamaremos a s(x) spline c
ubico, o simplemente spline,
si los polinomios qk (x) tienen la misma pendiente y la misma concavidad en los nodos
que las unen, o sea :
(
0
qk1
(xk ) = qk0 (xk )
(2)
00
qk1
(xk ) = qk00 (xk ), k = 1, 2, . . . , n 1
lo cual supone 2(n 1) condiciones a cumplir. Al tener que verificar las condiciones
(1) y (2) se asegura que s(x) tiene su primera y segunda derivadas continuas en [x0 , xn ].
En este caso se dice que s(x) es un spline interpolador para P0 , P1 , . . . , Pn .
Si s(x) es c
ubica a trozos en el intervalo [x0 , xn ], su derivada segunda s00 (x) es lineal en
el mismo intervalo e interpola en los puntos (xk , s00 (xk )) y (xk+1 , s00 (xk+1 )) en [xk , xk+1 ].
Por tanto, qk (x) es un polinomio de grado uno que interpola en los puntos (xk , s00 (xk )) y
(xk+1 , s00 (xk+1 )):
qk00 (x) = s00 (xk )
x xk
x xk+1
+ s00 (xk+1 )
,
xk xk+1
xk+1 xk
para k = 0, 1, . . . , n 1
Denotando con
tica
Informa
Pagina Web
Pagina de Inicio
Contenido
JJ
II
Pagina 5 de 22
hk = xk+1 xk ,
k = 0, 1, . . . , n 1
y
k = s00 (xk ),
Volver
k = 0, 1, . . . , n
tenemos :
Pantalla completa
qk00 (x) =
k
k+1
(xk+1 x) +
(x xk ),
hk
hk
para k = 0, 1, . . . , n 1
(3)
Cerrar
Salir
ULPGC
donde hk y k son constantes (k a determinar). Integrando dos veces :
k (xk+1 x)3 k+1 (x xk )3
+
+ Ck + Dk x
hk
6
hk
6
donde el termino lineal lo podemos escribir como :
qk (x) =
(4)
tica
Informa
Ck + Dk x = Ak (x xk ) + Bk (xk+1 x)
Pagina Web
qk (x) =
k (xk+1 x)
k+1 (x xk )
+
+ Ak (x xk ) + Bk (xk+1 x)
hk
6
hk
6
(5)
Contenido
k+1 3
k+1 2
hk + Ak hk =
h + Ak hk
hk
6 k
JJ
II
(6)
(7)
Pagina 6 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
y despejando de aqu Ak y Bk y sustituyendo en (5) resulta :
"
#
k (xk+1 x)3
qk (x) =
hk (xk+1 x)
6
hk
"
#
k+1 (x xk )3
+
hk (x xk )
6
hk
i
hx x i
hx
k
k+1 x
+ yk
+ yk+1
, para k = 0, 1, . . . , n 1
hk
hk
tica
Informa
(8)
Pagina Web
Pagina de Inicio
i h 3(x x)2
i y
k h 3(xk+1 x)2
k+1
k
k+1 yk
+ hk +
hk +
6
hk
6
hk
hk
Por tanto :
qk0 (xk ) =
k
k+1
yk+1 yk
(2hk ) +
(hk ) +
6
6
hk
qk0 (xk+1 ) =
k
k+1
yk+1 yk
(hk ) +
(2hk ) +
6
6
hk
(9)
(10)
Contenido
JJ
II
Pagina 7 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
0
Reemplazando k por k 1 en (10) para obtener qk1
(xk ) e igualando a (9) nos da :
y
yk yk yk1
, para k = 1, 2, . . . , n 1
hk
hk1
(11)
k+1
tica
Informa
o tambien
Pagina Web
y
hk
yk1
, para k = 1, 2, . . . , n 1
hk1
(12)
o incluso
hk1 k1 + 2 (hk1 + hk ) k + hk k+1 = 6 f [xk , xk+1 ] f [xk1 , xk ] , para k = 1, 2, . . . , n 1
(13)
Como el ndice k vara de 1 a n 1, se producen n 1 ecuaciones lineales con n + 1
incognitas 0 , 1 , . . . , n , lo cual produce un sistema subdeterminado que tiene infinitas
soluciones.
Existen varias estrategias para eliminar 0 de la primera ecuacion y n de la (n-1)esima produciendo un sistema tridiagonal de orden (n-1) en las variables 1 , 2 , . . . , n1 .
Pagina de Inicio
Contenido
JJ
II
Pagina 8 de 22
Volver
ALTERNATIVA I Especificar el valor de s00 (x) en los puntos extremos : 0 = s00 (x0 )
y n = s00 (xn ). Si se pone 0 = 0, n = 0 se denomina spline c
ubico natural.
Pantalla completa
Cerrar
Salir
ULPGC
ALTERNATIVA III Suponer que s00 (x) es lineal cerca de los extremos : 0 =
h1 )1 h0 2 y
1
n = hn2
hn1 )n2 + (hn2 + hn1 )n1
1
h1
(h0 +
tica
Informa
Pagina Web
Pagina de Inicio
Si hay que calcular muchas veces s(z) entonces es preferible hacer la sustitucion :
xk+1 z = (xk+1 xk ) (z xk ) = hk (z xk )
en qk (z) y entonces expresar este en potencias de z xk para obtener :
qk (z) = yk + 1 (z xk ) + 2 (z xk )2 + 3 (z xk )3
= yk + (z xk )(1 + (z xk )(2 + (z xk )3 ))
Contenido
JJ
II
Pagina 9 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
2 (h0 + h1 )
h1
0
h1
2 (h1 + h2 )
0
0
h2
0
..
..
.
.
2 (hn3 + hn2 )
hn2
0
0
hn2
2 (hn2 + hn1 )
=6
f [x1 , x2 ] f [x0 , x1 ]
f [x2 , x3 ] f [x1 , x2 ]
f [x3 , x4 ] f [x2 , x3 ]
..
.
f [xn1 , xn ] f [xn1 , xn2 ]
1
2
3
..
.
n1
tica
Informa
Pagina Web
Pagina de Inicio
Contenido
o tambien
2 (h0 + h1 )
h1
0
h1
2 (h1 + h2 )
0
0
h2
0
..
..
.
.
2 (hn3 + hn2 )
hn2
0
0
hn2
2 (hn2 + hn1 )
1
2
..
.
n1
= 6
y1
h1
y2
h2
y3
h3
..
.
y0
h0
y1
h1
y2
h2
yn1
hn1
yn2
hn2
JJ
II
Pagina 10 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
Ejemplo.
Interpolar por splines c
ubicos la funcion f (x) = 1/x en x = 1.5 tomando los puntos
(0.1, 10.0), (0.2, 5.0), (0.5, 2.0), (1.0, 1.0), (2.0, 0.5), (5.0, 0.2), (10.0, 0.1).
Soluci
on:
tica
Informa
h0 = 0.2 0.1 = 0.1 h3 = 2.0 1.0 = 1.0
h1 = 0.5 0.2 = 0.3 h4 = 5.0 2.0 = 3.0
h2 = 1.0 0.5 = 0.5 h5 = 10.0 5.0 = 5.0
Pagina de Inicio
Pagina Web
25
0.5 0.2
12
1.0 0.5
0.5 1.0
2.0 1.0
0.2 0.5
5.0 2.0
0.1 0.2
1.0 5.0
5 10
0.2 0.1
25
0.5 0.2
12
1.0 0.5
0.5 1.0
2.0 1.0
0.2 0.5
5.0 2.0
Contenido
JJ
II
Pagina 11 de 22
Volver
Pantalla completa
Poniendo 0 = 6 = 0 tenemos
Cerrar
Salir
ULPGC
0.8 0.3 0
0
0
0.3 1.6 0.5 0
0
0 0.5 3.0 1.0 0
0
0 1.0 8.0 3.0
0
0
0 3.0 16.0
1
2
3
4
5
=6
40
8
1.5
0.4
0.08
de donde se obtienen
1 = 311.65398570643 2 = 31.077295217152
3 = 8.4549532710280 4 = .82621220450797
5 = 0.18491478834524
tica
Informa
Pagina Web
Pagina de Inicio
Contenido
q3 (x) =
3
6
(2.0 x)3
4 (x 1.0)3
1.0 (2.0 x) +
1.0 (x 1.0) +1.0(2.0x)+0.5(x1.0)
1.0
6
1.0
JJ
II
Pagina 12 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
Los diferentes splines que resultan son:
q0 (x) =519.423309x3 155.826993x2 39.611534x + 15
q1 (x) = 190.406267x3 + 270.070753x2 124.791083x + 20.678637
q2 (x) =13.177416x3 35.304772x2 + 27.896679x 4.769324
q3 (x) = 1.546861x3 + 8.868059x2 16.276152x + 9.954953
q4 (x) = + 0.0561737x3 0.750148x2 + 2.960264x 2.869324
q5 (x) = 0.00616383x3 + 0.1849148x2 1.715052x + 4.922870
q0 (x) ,
q1 (x) ,
q (x) ,
2
s(x) =
q3 (x) ,
q4 (x) ,
q5 (x) ,
si
si
si
si
si
si
tica
Informa
Pagina Web
Pagina de Inicio
Contenido
JJ
II
Pagina 13 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
1
1/x
8.4575/6*((2-x)**3-(2-x))-0.8334/6*((x-1)**3-(x-1))+(2-x)+0.5*(x-1)
0.9
tica
Informa
Pagina Web
0.8
Pagina de Inicio
0.7
0.6
Contenido
0.5
JJ
II
0.4
0.3
0.2
Pagina 14 de 22
1.2
1.4
1.6
1.8
2
Volver
Pantalla completa
Cerrar
Salir
ULPGC
y0 = 1.00000000 y3 = 0.73529412
y1 = 0.96153846 y4 = 0.60975610
y2 = 0.86206896 y5 = 0.50000000
y es h0 = h1 = h2 = h3
ambas partes por 6/h :
4 1 0 0
1 4 1 0
0 1 4 1
0 0 1 4
tica
Informa
Pagina Web
y2 2 y1 + y0
9.151194
1
6
2
y3 2 y2 + y1 = 4.095801
=
3 h2 y4 2 y3 + y2 0.185523
y5 2 y4 + y3
2.367288
4
Pagina de Inicio
Contenido
JJ
II
Pagina 15 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
2. PROBLEMAS
Problema 1. Construir el spline c
ubico natural que interpola a partir de los datos:
x
y
0
1.4
1
0.6
2
1.0
2.5
3
0.65 0.6
4
1.0
0.15
0.76
0.89
1.07
1.73
2.11
0.3495 0.2989 0.2685 0.2251 0.0893 0.0431
obtener el spline c
ubico natural que interpola en dichos puntos.
tica
Informa
Pagina Web
Pagina de Inicio
Contenido
JJ
II
Pagina 16 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
Referencias
[Act90] F.S. Acton. Numerical Methods That (Usually) Work. The Mathematical Association of America, Washington, 1990.
[Atk89] K. E. Atkinson. An Introduction to Numerical Analysis. John Wiley, New York,
2nd. edition, 1989.
[BF80]
[CC89]
tica
Informa
Pagina Web
Pagina de Inicio
S.C. Chapra and R.P. Canale. Numerical Methods for Engineers. McGraw-Hill
International, New York, second edition, 1989.
Contenido
JJ
II
[DB74]
Pagina 17 de 22
Volver
[Fro79]
[GW89] C.F. Gerald and P.O. Wheatley. Applied Numerical Analysis. AddisonWesley
Publishing Co., Reading, Massachusets, fourth edition, 1989.
Pantalla completa
Cerrar
Salir
ULPGC
[Hen72] P. Henrici. Elementos de Analisis Numerico. Ed. Trillas, Mexico, 1972.
[Hil74]
[KC94]
tica
Informa
Pagina Web
Pagina de Inicio
Contenido
[RR78]
JJ
II
[Sch89]
H.R. Schwarz. Numerical Analysis. John Wiley & Sons, Chichester, 1989.
Pagina 18 de 22
[YG73a] David M. Young and R.T. Gregory. A Survey of Numerical Mathematics, volume I. Dover Publications, New York, 1973.
Volver
[YG73b] David M. Young and R.T. Gregory. A Survey of Numerical Mathematics, volume II. Dover Publications, New York, 1973.
Pantalla completa
Cerrar
Salir
ULPGC
4 1
0
0
1 3 0.5 0
0 0.5 2 0.5
0 0 0.5 3
1
7.2
2
= 6.6
3
3.6
4
3
de donde se obtienen
tica
Informa
Pagina Web
Pagina de Inicio
1 = 2.6788381742739 2 = 3.5153526970954
3 = 2.5344398340249 4 = 0.57759336099585
Los diferentes splines son:
Contenido
JJ
II
Pagina 19 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
q0 (x) ,
q1 (x) ,
s(x) = q2 (x) ,
q3 (x) ,
q (x) ,
4
si
si
si
si
si
tica
Informa
Pagina Web
J
Pagina de Inicio
Contenido
JJ
II
Pagina 20 de 22
Volver
Pantalla completa
Cerrar
Salir
ULPGC
Problema 2. El sistema es
1.48 0.13
0.13 0.62
0 0.18
0
0
ahora:
1
0
0
2
0.18 0
1.68 0.66 3
0.66 2.08
4
0.905372005
= 0.0435897436
0.212121212
0.50507177
obteniendose:
tica
Informa
Pagina Web
1 = 0.61616885710569 2 = 0.050445411325263
3 = 0.029089182290732 4 = 0.23359274520339
Los diferentes splines son:
q0 (x) = 0.16835215x3 + 0.075758466x2 0.0316707558x + 0.35311424
q1 (x) = + 0.85463368x3 2.25664921x2 + 1.74095908x 0.095951989
q2 (x) = 0.019774286x3 + 0.078020050x2 0.33689656x + 0.52047852
q3 (x) = + 0.051642314x3 0.15122724x2 0.091601967x + 0.43299011
q4 (x) = 0.10245296x3 + 0.64852723x2 1.47517719x + 1.23085182
Pagina de Inicio
Contenido
JJ
II
Pagina 21 de 22
Volver
Pantalla completa
Cerrar
Salir