Você está na página 1de 3

October 09

M.Sc. in Applied Computing for Technologists

S. Mulligan

First Order Hermite Interpolation.


Frequently we may want to interpolate not only the values of a function at the points xi, but also the values of the derivatives (slopes) at the points xi, i =1,,n as well. So we wish to find a polynomial p(x) such that, P( xi ) = f i , and P '( xi ) = f 'i , i =1,,n (1)

So we have 2n conditions to satisfy. We can do this with a polynomial of degree 2n-1. Hermites formula, exhibits a polynomial of degree 2n-1 which interpolates both the values of f and its first derivative at the points xi. It has the form
P ( x ) = U i ( x ) f i + Vi ( x ) f i '
i =1 i =1 n n

(2)

The functions U i ( x) and Vi ( x ) are polynomials having properties similar to those of the Lagrange multipliers li ( x ) presented earlier. In fact, U i ( x) = [1 2( x xi ) li ' ( xi )][ li ( x)]2 Vi ( x ) = ( x xi )[li ( x )]2 The polynomials U i ( x) and Vi ( x ) satisfy the following conditions: U i ( x k ) = i ,k ,
Vi ( x k ) = 0

and

(3a) (3b)

U 'i ( x k ) = 0

(4a) by construction. (4b)

V ' i ( x k ) = i ,k

Clearly also U i ( x) and Vi ( x ) are polynomials of degree 2n-1, and satisfy equation (1).
P ( x j ) = U i ( x j ) f i + Vi ( x j ) f i ' = i , j f i + 0 f
i =1 n i =1 i =1 i =1 n n n ' n n n n ' i

= fj
' i

P ' ( x j ) = U 'i ( x j ) f i + V 'i ( x j ) f i = 0 f i + i , j f


i =1 i =1 i =1 i =1

= f

' j

So for 2 points we get cubic polynomials for U i ( x) and Vi ( x ) . Example n=2, i.e. nodes {0,1}, show that U 1 ( x ) = (1 + 2 x )(1 x ) 2 and U 2 ( x ) = ( 3 2 x )( x ) 2 V1 ( x ) = ( x )(1 x ) 2 and V2 ( x ) = ( x ) 2 ( x 1) (5) (6)

Cubic Spline Interpolation.


One technique that is becoming increasingly important is the so-called spline fitting of a curve. The conditions for a cubic spline are that we pass a set of cubics through the points, using a new cubic in each interval. To correspond to the idea of the draughtsmans spline, we require that both the slope and the curvature be the same for

Computing Dept., DIT Bolton St.

Page 1

October 09

M.Sc. in Applied Computing for Technologists

S. Mulligan

the pair of cubics that join at each point. We now develop the equations subject to these conditions. We write the cubic for the ith interval, which lies between the points (xi,yi) and (xi+1,yi+1) in the form:
y i ( x ) = ai ( x xi ) 3 + bi ( x xi ) 2 + ci ( x xi ) + d i

(7)

Since it fits at the two endpoints of the interval: y i = y i ( xi ) = ai ( xi xi ) 3 + bi ( xi xi ) 2 + ci ( xi xi ) + d i = d i


y i +1 = y i ( xi +1 ) = ai ( xi +1 xi ) + bi ( xi +1 xi ) + ci ( xi +1 xi ) + d i
3 2

(8)

(9) = ai hi 3 + bi hi 2 + ci hi + d i In the last equation we use hi = xi +1 xi , for x in the ith interval. We need the first and second derivatives to relate the slopes and curvatures of the joining polynomials
y i ' ( x ) = 3a i ( x xi ) 2 + 2bi ( x xi ) + ci

(10)

yi ' ' ( x ) = 6ai ( x xi ) + 2bi (11) The mathematical procedure is simplified if we write the equations in terms of the second derivatives of the interpolating cubics. Let Si = y' ' ( xi ) represent the second derivative at the point (xi,yi) and Si +1 at the point (xi+1,yi+1). From (11) we have Si = 6ai ( xi xi ) + 2bi

Si = 2bi Si +1 = 6ai ( xi +1 xi ) + 2bi = 6ai hi + 2bi Hence we can write (12) bi = Si / 2, (13) ai = ( Si +1 Si ) / 6hi , We substitute the relations for ai, bi, di given by eqns. (8), (12), (13) into equation (9) and then solve for ci: S Si 3 Si 2 yi +1 = ( i +1 )hi + hi + ci hi + yi 6hi 2 y y 2h S + hi Si +1 (14) ci = i +1 i i i 6 hi We now invoke the condition that the slopes of the two cubics that join at (xi,yi) are the same. For the equation in the ith interval, eqn. (10) becomes, with x=xi, y i ' ( xi ) = 3ai ( xi xi ) 2 + 2bi ( xi xi ) + ci = ci
In the previous interval, from (xi-1,xi), the slope at its right end will be yi 1 ' ( xi ) = 3ai 1 ( xi xi 1 ) 2 + 2bi 1 ( xi xi 1 ) + ci 1

= 3ai 1hi 12 + 2bi 1hi 1 + ci 1


Equating these and substituting for a, b, c, d their relationships in terms of S and y, we get

Computing Dept., DIT Bolton St.

Page 2

October 09

M.Sc. in Applied Computing for Technologists

S. Mulligan

yi ' =

y i +1 yi 2hi S i + hi S i +1 6 hi S S S y y 2h S + h S = 3( i i 1 )hi 12 + 2( i 1 )hi 1 + i i 1 i 1 i 1 i 1 i 6hi 1 2 hi 1 6

On simplifying this equation we get

y y y yi 1 hi 1Si 1 + (2hi 1 + 2hi ) Si + hi Si +1 = 6 i +1 i i i=2,,n-1 (15) hi 1 hi Equation (15) applies at each internal point, from i=2 to i=n-1; n being the total number of points. This gives n-2 equations relating the n values of Si . We get two additional equations involving S1 and S n , when we specify conditions pertaining to the end intervals of the whole curve. To some extent these end conditions are arbitrary. Three possible choices are often used: 1. Take S1 = 0, S n = 0 . This is called the natural cubic spline and is equivalent to assuming that the end cubics approach linearity at their extremities. 2. Take S1 = S 2 , S n = S n 1 . This is equivalent to assuming that the end cubics approach parabolas at their extremities. 3. Take S1 as a linear extrapolation from S 2 and S 3 , and S n as a linear extrapolation from S n1 and S n2 .
Relation 1 is called the natural spline, and it is frequently used. Equations (15) written in matrix form give n-2 equations , but n unknowns. We can eliminate two unknowns S1 and S n using choice 1 above. We solve this system for the unknown Si , i = 2,... n . After the Si values are calculated , we get the values of ai , bi , ci , d i for each interval if we want to interpolate for new values of the function:
ai = ( Si +1 Si ) / 6hi , bi = Si / 2, y y 2h S + hi Si +1 , ci = i +1 i i i 6 hi d i = yi

Computing Dept., DIT Bolton St.

Page 3

Você também pode gostar