You are on page 1of 9

1 HERMITE INTERPOLATION

Again start with a table of values of a function f :

x x0 x1 x2 ... xn
f (x) f (x0 ) f (x1 ) f (x2 ) ... f (xn )

The points x0 , x1 , ..., xn are assumed to be distinct.

• Hermite interpolation constructs an interpolant based not only on equa-


tions for the function values, but also for the derivatives.

Hermite Polynomials

Definition 1 Suppose f ∈ C 1 [a, b]. Let x0 , x1 , ..., xn be n + 1 distinct numbers


in [a, b], the Hermite polynomial H(x) approximating f is that:

1. H(xi ) = f (xi ) for i = 0, 1, ..., n.


dH(xi ) df (xi )
2. dx = dx for i = 0, 1, ..., n.

Remark

1. H(x) and f (x) agree not only function values but also 1st derivative values
at x0 , x1 , ..., xn .
2. The degree of H(x) is at most 2n + 1 because the number of conditions
to be satisfied is 2n + 2 and a polynomial of degree 2n + 1 has 2n + 2
coefficients that can be used to satisfy these conditions.

Theorem If f ∈ C 1 [a, b] and x0 , x1 , ..., xn ∈ [a, b] are distinct, the unique


polynomial of least degree agreeing with f and f 0 at x0 , x1 , ..., xn is the Hermite
polynomial of degree at most 2n + 1 given by
n
X n
X a
H2n+1 (x) = f (xj )Hn,j (x) + f 0 (xj )H n,j (x) (1)
j=0 j=0

where
Hn,j (x) = 1 − 2(x − xj )L0n,j (xj ) L2n,j (x)
 

and
a
H n,j (x) = (x − xj )L2n,j (x)
Here Ln,j (x) denoting the jth Lagrange coefficient polynomial of degree n.

1
Moreover, if f ∈ C 2n+2 [a, b], then

(x − x0 )2 ...(x − xn )2 (2n+2)
f (x) = H2n+1 (x) + f (ξ (x))
(2n + 2)!

for some (generally unknown) ξ (x) in the interval (a, b).

Remark
(x−x0 )2 ...(x−xn )2 (2n+2)
1. (2n+2)! f (ξ (x)) is the error term.

Example Consider the following table. Find an approximation of f (1.5)


by using the Hermite polynomial.

x 0 0.5 1
f (x) 0.6 0.4 0.2
f 0 (x) -0.5 -0.6 -1

Solution We first compute the Lagrange polynomials and their derivatives.

This gives

(x − x1 )(x − x2 ) (x − 0.5)(x − 1)
L2,0 (x) = = = 2x2 − 3x + 1
(x0 − x1 )(x0 − x2 ) (0 − 0.5)(0 − 1)
L02,0 (x) = 4x − 3
(x − 0)(x − 1)
L2,1 (x) = = −4x2 + 4x
(0.5 − 0)(0.5 − 1)
L02,1 (x) = −8x + 4
(x − 0)(x − 0.5)
L2,2 (x) = = 2x2 − x
(1 − 0)(1 − 0.5)
L02,2 (x) = 4x − 1

2
a
The polynomials H2,j (x) and H 2,j (x) are then
2
H2,0 (x) = [1 − 2(x − 0)(−3)] 2x2 − 3x + 1
2
= (6x + 1) 2x2 − 3x + 1
2
H2,1 (x) = [1 − 2(x − 0.5)(0)] −4x2 + 4x
2
= −4x2 + 4x
2
H2,2 (x) = [1 − 2(x − 1)(3)] 2x2 − x
2
= (−6x + 7) 2x2 − x
a 2
H 2,0 (x) = x 2x2 − 3x + 1
a 2
H 2,1 (x) = (x − 0.5) −4x2 + 4x
a 2
H 2,2 (x) = (x − 1) 2x2 − x

Hence

H5 (x) = 0.6H2,0 (x) + 0.4H2,1 (x) + 0.2H2,2 (x)


a a a
−0.5H 2,0 (x) − 0.6H 2,1 (x) − 1H 2,2 (x)
2 2 2
= 0.6(6x + 1) 2x2 − 3x + 1 + 0.4 −4x2 + 4x + 0.2(−6x + 7) 2x2 − x
2 2 2
−0.5x 2x2 − 3x + 1 − 0.6(x − 0.5) −4x2 + 4x − 1(x − 1) 2x2 − x
= −6x5 + 2x4 − 1.2x3 + 0.2x2 − 0.5x + 0.6

and

H5 (1.5) = 0.6 (10) + 0.4 (9) + 0.2 (−18)


   
3 9
−0.5 − 0.6 (9) − 1
2 2
= −4.65

Using this, f (1.5) ≈ H5 (1.5) = −4.65.

Example Let f (x) = sin(πx). Approximate f ( 14 ) by the Hermite interpo-


lating polynomial of degree at most three using x0 = 0 and x1 = 12 and compare
the error.
Solution

f (x) = sin(πx), f 0 (x) = π cos(πx)


f (x0 ) = f (0) = 0, f 0 (x0 ) = f 0 (0) = π
1 1
f (x1 ) = f ( ) = 1, f 0 (x1 ) = f 0 ( ) = 0
2 2

3
Since n = 1 (2n + 1 = 3) , we seek

H3 (x) = a0 + a1 x + a2 x2 + a3 x3

H3 (x) must satisfy the following conditions:

H3 (0) = f (0) = 0 ⇒ a0 = 0
 
1 1 1 1 1
H3 = f( ) = 1 ⇒ a0 + a1 + a2 + a3 = 1
2 2 2 4 8
H30 (0) = f 0 (0) = π ⇒ a1 = π
 
1 1 3
H30 = f 0( ) = 0 ⇒ a1 + a2 + a3 =0
2 2 4

The above system can be solved and the unknown coefficients can be evalu-
ated as

a0 = 0, a1 = π, a2 = 12 − 4π, a3 = 4π − 16
Therefore,
H3 (x) = πx + (12 − 4π) x2 + (4π − 16) x3
This gives
 
1 1 π (12 − 4π) (4π − 16)
f ( ) ≈ H3 = + + ≈ 0.6963
4 4 4 16 64

Error analysis:

From the theorem we know that

f (x) = H3 (x) + R(x)

where
(x − x0 )2 (x − x1 )2 (4)
 
1
R(x) = f (ξ (x)) , ξ (x) ∈ 0,
(2n + 2)! 2
f (4) (ξ (x)) 2 1
= x (x − )2
24 2
π 4 sin(πξ) 2 1
= x (x − )2
24 2
4
π4

1 π sin(πξ) 1 1
R( ) = ≤ ≈ 0.0159
4 24 42 42 24.16.16
Note:

4
 
1
f ( ) − H3 1 = R( 1 ) ≤ 0.0159

4 4 4
   
1 1 1
H3 − 0.0159 ≤ f ( ) ≤ H3 + 0.0159
4 4 4
1
0.6963 − 0.0159 ≤ f ( ) ≤ 0.6963 + 0.0159
4 
π
0.6804 ≤ sin ≤ 0.7122
4

2 SPLINE INTERPOLATION

The previous sections concerned the approximation of arbitrary functions on


closed intervals using a single polynomial.
An alternative approach is to divide the approximation interval into a col-
lection of subintervals and construct a different approximating polynomial on
each subinterval. This is called piecewise-polynomial approximation.
Such piecewise-polynomial approximations are called splines and the end-
points of the subintervals are known as the knots. A spline function is a
function that consists of polynomial pieces joined together with certain smooth-
ness conditions.

5
Splıne of Degree k

Definition: A function S is called a spline of degree k if:

1. The domain of S is an interval [a, b].


2. S, S 0 , S 00 , ..., S (k−1) are all continuous functions on [a, b].
3. There are points xi (the knots of S) such that a = x0 < x1 <···< xn = b
and such that S is a polynomial of degree at most k on each subinterval
[xi , xi+1 ].

NOTE

• The first- and second-degree splines, though useful in certain applications,


their low-order derivatives are discontinuous. In the case of the first-
degree spline, there is likely no differentiability at the endpoints of the
subintervals, which, in a geometrical context, means that the interpolating
function is not “smooth.”. For the quadratic spline, the discontinuity is
in the second derivative. The curvature of the quadratic spline changes
abruptly at each knot, and the curve may not be pleasing to the eye.
• Higher-degree splines are used whenever more smoothness is needed in the
approximating function.
• The choice of degree most frequently made for a spline function is 3. The
resulting splines are termed cubic splines. Experience has shown that
using splines of degree greater than 3 seldom yields any advantage.

2.1 Cubic Spline

Start with a table:


x x0 x1 x2 ... xn
y y0 y1 y2 ... yn

The xi ’s are the knots and are assumed to be arranged in ascending order.

The function S that we wish to construct consists of n cubic polynomial


pieces:


 S0 (x) , a = x0 ≤ x ≤ x1
 S1 (x) , x1 ≤ x ≤ x2

S (x) = ..


 .
Sn−1 (x) , xn−1 ≤ x ≤ xn = b

6
In this formula,
2 3
Si (x) = ai + bi (x − xi ) + ci (x − xi ) + di (x − xi ) , i = 0, 1, ..., n − 1
denotes the cubic polynomial that will be used on the subinterval [xi , xi+1 ].
The interpolation conditions are
S(xi ) = yi , 0≤i≤n (2)
The continuity conditions are written as
lim S (k) (xi ) = lim+ S (k) (xi ), k = 0, 1, 2 (3)
x→x−
i x→xi

There are n+1 knots and hence n subintervals. On each of these subintervals,
we shall have a different cubic polynomial. Since a cubic polynomial has four
coefficients, a total of 4n coefficients are available. we have specified that within
each interval the interpolating polynomial must go through two points, which
gives 2n conditions.. The first and second derivatives must be continuous at the
n − 1 interior points, for 2(n − 1) more conditions.
It turns out that two more conditions must be imposed.
00
1. If the choice that we make for these two extra conditions is S (x0 ) =
00
S (xn ) = 0, the resulting spline function is then termed a natural cubic
spline.
0
2. If the choice that we make for these two extra conditions is S (x0 ) =
0
f 0 (x0 ) and S (xn ) = f 0 (xn ) , the resulting spline function is then termed
a clamped cubic spline.

Example Construct a natural cubic spline that passes through the points
(1, 2), (2, 3), and (3, 5).

Solution We have a table

x 1 2 3
y 2 3 5

S0 (x) = a0 + b0 (x − 1) + c0 (x − 1)2 + d0 (x − 1)3 ,



1≤x≤2
S (x) =
S1 (x) = a1 + b1 (x − 2) + c1 (x − 2)2 + d1 (x − 2)3 , 2≤x≤3

Four conditions come from the fact that the splines must agree with the data
at the nodes. Hence
S0 (1) = 2 =⇒ a0 = 2
S0 (2) = 3 =⇒ a0 + b0 + c0 + d0 = 3
S1 (2) = 3 =⇒ a1 = 3
S1 (3) = 5 =⇒ a1 + b1 + c1 + d1 = 5

7
Taking the first derivatives, we obtain

S00 (x) = b0 + 2c0 (x − 1) + 3d0 (x − 1)2 ,



1≤x≤2
S 0 (x) =
S10 (x) = b1 + 2c1 (x − 2) + 3d1 (x − 2)2 , 2≤x≤3

From the continuity of S 0 , we have

S00 (2) = S10 (2) =⇒ b0 + 2c0 + 3d0 = b1

Next taking the second derivatives, we obtain


 00
00 S0 (x) = 2c0 + 6d0 (x − 1), 1≤x≤2
S (x) =
S100 (x) = 2c1 + 6d1 (x − 2), 2≤x≤3
From the continuity of S 00 , we have

S000 (2) = S100 (2) =⇒ c0 + 3d0 = c1

For S to be a natural cubic spline, we must have

S000 (1) = 0 =⇒ c0 = 0
S100 (3) = 0 =⇒ 2c1 + 6d1 = 0

From all of these equations, we obtain


3 1
a0 = 2, b0 = , c0 = 0, d0 =
4 4
3 3 1
a1 = 3, b1 = , c1 = , d1 = −
2 4 4
Therefore,

S0 (x) = 2 + 34 (x − 1) + 14 (x − 1)3 ,

1≤x≤2
S (x) =
S1 (x) = 3 + 23 (x − 2) + 43 (x − 2)2 − 41 (x − 2)3 , 2 ≤ x ≤ 3

Example A clamped cubic spline S for a function f is defined on [1, 3] by

S0 (x) = 3(x − 1) + 2(x − 1)2 − (x − 1)3 ,



1≤x≤2
S (x) =
S1 (x) = a + b(x − 2) + c(x − 2)2 + d(x − 2)3 , 2 ≤ x ≤ 3

Given f 0 (1) = f 0 (3), find a, b, c, and d.

Solution The splines must agree with the data at the nodes. Hence

S0 (2) = S1 (2) =⇒ a = 4

Taking the first derivatives, we obtain

8
S00 (x) = 3 + 4(x − 1) − 3(x − 1)2 ,

1≤x≤2
S 0 (x) =
S10 (x) = b + 2c(x − 2) + 3d(x − 2)2 , 2≤x≤3
From the continuity of S 0 , we have

S00 (2) = S10 (2) =⇒ 4 = b

Next taking the second derivatives, we obtain


 00
00 S0 (x) = 4 − 6(x − 1), 1≤x≤2
S (x) =
S100 (x) = 2c + 6d(x − 2), 2≤x≤3
From the continuity of S 00 , we have

S000 (2) = S100 (2) =⇒ −1 = c

For S to be a clamped cubic spline, we must have

S00 (1) = f 0 (1)


S10 (3) = f 0 (3)

Given f 0 (1) = f 0 (3),


1
S00 (1) = S10 (3) =⇒ 3 = b + 2c + 3d =⇒ d =
3

You might also like