0% found this document useful (0 votes)
64 views

ch1 PPT

The document summarizes interpolation methods. It defines the interpolation problem and discusses finding an approximate function g(x) to match known data points (xi, yi). It covers Lagrange interpolation, which uses basis polynomials li(x) to construct the Lagrange interpolating polynomial Ln(x). The remainder Rn(x) = f(x) - Ln(x) is also discussed, showing it depends on the (n+1)th derivative of the original function f(x).

Uploaded by

EFRA BINI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

ch1 PPT

The document summarizes interpolation methods. It defines the interpolation problem and discusses finding an approximate function g(x) to match known data points (xi, yi). It covers Lagrange interpolation, which uses basis polynomials li(x) to construct the Lagrange interpolating polynomial Ln(x). The remainder Rn(x) = f(x) - Ln(x) is also discussed, showing it depends on the (n+1)th derivative of the original function f(x).

Uploaded by

EFRA BINI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

Chapter1 Interpolation

§1 Interpolating Problem
§2 Lagrange Interpolation
§3 Newton’s Interpolation
§4 Interpolation on Equally Spaced Nodes
§5 Hermite Interpolation
§6 Cubic Spline Interpolation
§1.1 Interpolating Problem

Problem

How to Solve

Concept

Existence and Uniqueness


Problem
Suppose that x and y satisfies y=f(x)
1. The analytical expression of y=f(x) is known,
But it is very complicated.
2. The analytical expression of function y=f(x) is not
known, and we can only obtain (xi,yi) (i=0,1,……,n)
by experiments.
Example:Meteorological generally observe the
temperature four times daily

Time t (Hour) 2 8 14 20
Temperature -4.6 -5.7 6.8 2.6
T(℃)
How to solve?
Find the approximate function g(x)
of y=f(x)
Requirements of g(x) Algebraic Polynomial
 Simple, Easily calculate

At known points xi, g(xi) = f(xi) (i = 0,1, … n)

y=f(x)
g(x)  f(x)

y=g(x)

x0 x1 x2 x x3 x4
Polynomial Interpolation
Function f ( x) C[a, b] , and the values of f ( x) at n  1
different points x 0 , x1 ,, x n are yi  f ( xi )(i  0,1, , n) .
Determine a polynomial of degree no more than n
Pn ( x)  a0  a1x   an xn
to satisfy
Pn ( xi )  yi (i  0,1, , n) .

a, b is called the interpolating interval,


xi are called the interpolating nodes,
P ( x ) is called the interpolating polynomial.
n

Example
Time t (Hour) 2 8 14 20
Temperature T(℃) -4.6 -5.7 6.8 2.6
From the interpolating condition the parameters
a i  should satisfy the linear system
a 0  a1 x0  a x    a x  y 0
2
2 0
n
n 0

a 0  a1 x1  a 2 x1    a n x1  y1
2 n


 
a  a x  a x 2    a x n  y
 0 1 n 2 n n n n

Review:For the linear system Ax=b,A is an


square matrix, when the solution vector exists?
When is the solution vector unique?
Interpolating Polynomial Uniquely Exists

the determinant of the coefficient matrix is


n  1 order Vandermonde determinant
1 x0 x02 x0n
x12 x1n 
Vn 
1 x1

0  j i  n
( xi  x j )  0(different points)

1 xn xn2 xnn

Conclusion:The above linear system has unique


solution. The interpolating polynomial of degree n
uniquely exists.
Example Time t (Hour) 2 8 14 20

Temperature T(℃) -4.6 -5.7 6.8 2.6

810

6
5

4
0

2
TT

-5
0

-10
-2

-4
-15

-6
0
-20 5 10 15 20
0 5 10t 15 20
t
P3 (t )  4.0259  5.7194t  0.7500t 2  0.0234t 3
Remark:Data come from National Meteorological Center of CMA
§1.2 Lagrange Interpolation

 Interpolating basis functions

 Lagrange Interpolating Polynomial

 Interpolating Remainder

Find a polynomial of degree n, Pn(x) = a0 + a1x + … + anxn, such


that Pn(xi) = yi for all i = 0, …, n.

Note: for any i  j, we must have xi  xj .


Interpolating Basis Functions
n=1 Given x0 , x1 ; y0 , y1 , P1 ( x )  a0  a1 x satisfy
P1 ( x 0 )  y 0 , P1 ( x1 )  y1

P1(x) is the line passing through ( x0 , y0 ) and ( x1, y1 ) .


y1  y 0
P1 ( x )  y0  ( x  x0 )
x1  x 0
x  x1 x  x0
1

= y +
x 0  x1 0 x1  x 0
y 1
  l ( x) y
i 0
i i

l0(x) l1(x)
n  1 Determine li(x),i = 0, …, n to satisfy li(xj)=ij ;
n
Pn ( x )   l (x) y
i0
i i , and then we have Pn(xi) = yi .
First construct n  1 polynomials of n degree li (x )
to satisfy

0 j i
li ( x j )   i, j  0,1,, n
1 j i
n

 (x  x j )
j 0 n (x  x j )

j i
li ( x )  n
( xi  x j )
 (x
j 0
i  xj) j 0
j i

j i

which are called Lagrange interpolating basis functions.


n
Ln ( x)   yi li ( x)
i 0
Which is called Lagrange interpolating polynomial of n degree.
Linear Interpolation(n=1)
L1 ( x)  y0l0 ( x)  y1l1 ( x)
x  x1 x  x0
l0 ( x)  l1 ( x) 
x0  x1 x1  x0

Quadratic Interpolation(n=2)
L2 ( x)  y0l0 ( x)  y1l1 ( x)  y2l2 ( x)

( x  x1 )( x  x2 ) ( x  x0 )( x  x2 ) ( x  x0 )( x  x1 )
l0 ( x)  l1 ( x)  l2 ( x) 
( x0  x1 )( x0  x2 ) ( x1  x0 )( x1  x2 ) ( x2  x0 )( x2  x1 )
Example:100  10, 121  11, 144  12 are given.
Use the linear interpolation and the quadratic
interpolation to approximate 115.

Note:
The interpolating polynomial is NOT unique
unless its degree is constrained to be no greater
than n.A counterexample is n
P( x )  Ln ( x )  a( x ) ( x  xi )
i 0
where p(x) can be a polynomial of any degree.
Interpolating Remainder
Suppose a  x0  x1    xn  b and f  Cn + 1[a, b].
Consider the truncation error Rn ( x )  f ( x )  Pn ( x )
n
Rn(x) has
Rolle’s at least If
Theorem: (x)roots
n+1 Rnsmooth
is sufficiently ( x) K (with
x) (x
0 1

( x ) =xi)(x ) = 0, 
i 0
then therex exists
Fix any  all(xi0=, x0,1)…,
 xi for such
n. that  ’(the
Define ) =function
0. g for t in [a, b] by
In general, if (x0g(t)
) =  
n
(xR ) = (x ) = 0
1 ( t ) 2 K ( x )
n  (t  xi )
i  0 that  ( )   ( )  0
There exist  0  ( x0 , x1 ), 1  ( x1 , x2 ) such
g ( n1) ( x )  0,  x  (a, b)
0 1
g(x) has n+2 distinct roots x0 … xn x
There exists   ( 0 ,  1 ) such that  ( )  0
f((nx10) )(x
) P(nn( x1 )n()x )0 K ( x )( n  1) !  Rn( n 1 ) ( x )  K ( x ) ( n  1) !
  

( n 1 )
( x ) (a , b ) such thatf( n1)(( ) ) 0n
( n)
Theref exists
K ( x)  Rn ( x )  x
(x  x )
( n  1) ! ( n  1) ! i 0
i
Interpolating Remainder

Note:
 Since in most of the cases x cannot be determined, we obtain
the upper bound of f (n+1) instead. That is, estimate an Mn+1 such
M n 1 n
( n  1)! 
that f
( n 1 )
( x )  M n1 for all x(a,b) and take | x  xi |
i 0

as the upper bound of the total error.


 The interpolating polynomial is accurate for any polynomial
function f with degree  n since f (n+1)(x)  0.
Example The data table of function y  ln x is given
x 10 11 12 13 14

y  ln x 2.3026 2.3979 2.4849 2.5649 2.6391

Use Lagrange linear interpolation and quadratic interpolation


to approximate ln11.5and estimate the truncation error.
Solution. Linear interpolation
x 0  11 x1  12

11.5  12 11.5  11
ln11.5  P1 (11.5)  2.3979  2.4849  2.4414
11  12 12  11

(ln  )
R1 (11.5)  (11.5  11)(11.5  12)  1.09  103
2!
Quadratic interpolation x 0  11 x1  12 x 2  13

ln11.5  P2 (11.5)  2.442275

(ln  )(3)
R2 (11.5)  (11.5  11)(11.5  12)(11.5  13)
3!
 9.3938  105
Example There is a table of the values of f ( x )  sin x
at equally spaced nodes. Suppose the step size of the
function table is h , that is the distance between
adjacent nodes. Determine h so that the truncation
error is not more than 5  105 when using linear
interpolation to approximate sin x .
Solution. From equation (1.17), for arbitrary adjacent nodes xk , xk 1 the
linear interpolating remainder is
f "( k )
R1 ( x)  ( x  xk )( x  xk 1 ) ,  k  ( xk , xk 1 ) .
2!
So when x [ x , x ] , we have
k k 1

1 1
( x  xk )( x  xk 1 )  ( xk 1  xk ) 2  h 2
4 4 .
Furthermore,
f "(k ) M
R1 ( x)  ( x  xk )( x  xk 1 )  2 h2 ,
2! 8
where M 2  max f ( x) . When f ( x)  sin x , we have
M 2  max (sin x)  max  sin x  1 .
Therefore,
1 2
h  5  10 5 ,
8
that is,
h  0.02 .
The allowed maximum step size of the function table is 0.02. ■
§1.3 Divided Differences
and Newton’s Interpolation

 Divided differences

 Newton’s interpolation
Basic Idea of Newton’s Interpolation
It is easy to calculate the Lagrange polynomial.
When you want to take more interpolating
points into account. Then all the Lagrange
basis, li(x), will have to be re-calculated.

Change Pn(x) to a0  a1 ( x  x0 )  a2 ( x  x0 )( x  x1 )  ...


 an ( x  x0 )...( x  xn1 ) when increasing a point,
only one item is added.

Newton’s Nn ( x)  a0  a1 ( x  x0 )  a2 ( x  x0 )( x  x1 )  ...
Interpolation  an ( x  x0 )...( x  xn1 )
Divided Differences
f ( xi )  f ( x j ) The 1st divided difference
f [ xi , x j ]  ( i  j , xi  x j )
xi  x j of f w.r.t. xi and xj

f [ xi , x j ]  f [ x j , xk ] The 2nd divided difference


f [ xi , x j , xk ]  (i  k )
xi  xk of f w.r.t. xi , xj and xk

The k+1st divided difference of f w.r.t. x0 … xk+1

f [ x0 , x1 , ... , xk ]  f [ x1 , ... , xk , xk 1 ]
f [ x0 , ... , xk 1 ] 
x 0  x k 1
f [ x0 , ... , xk 1 , xk ]  f [ x0 , ... , xk 1 , xk 1 ]

x k  x k 1
Properties of Divided Differences
k
f ( xi )
f  x0 , x1 , , xk   
k
1. where  k 1 ( x i )   ( x i  x j )
i 0 k 1 ( xi ) j 0
j i

2. f  xi , x j , xk   f  x j , xi , xk   f  x j , xk , xi 

3. When k  n , the k th divided difference f [ x0 , x1 , , xk ] of

n -degree polynomial f ( x ) is a polynomial of degree n  k ,

while when k  n its value equals zero.

f ( )
(m)
4. f [ xi 0 , xi1 , , xim ] 
m!
Newton’s Interpolation
N n ( x )  a0  a1 ( x  x0 )  a2 ( x  x0 )( x  x1 )  ...  an ( x  x0 )...( x  xn1 )

f ( x )  f ( x0 )  ( x  x0 ) f [ x , x0 ] 1
f [ x , x0 ]  f [ x0 , x1 ]  ( x  x1 ) f [ x , x0 , x1 ] 2
…………
f [ x , x0 , ... , xn1 ]  f [ x0 , ... , xn ]  ( x  xn ) f [ x , x0 , ... , xn ] n1

1 + (x  x0)  2 + … … + (x  x0)…(x  xn1)  n1

f ( x )  f ( x0 )  f [ x0 , x1 ]( x  x0 )  f [ x0 , x1 , x2 ]( x  x0 )( x  x1 )  ...
 f [ x0 , ... , xn ]( x  x0 )...( x  xn1 )
 f [ x , x0 , ... , xn ]( x  x0 )...( x  xn1 )( x  xn )

Nn(x) ai = f [ x0, …, xi ]
Rn(x)
Note:
 Since the n-th interpolating polynomial is unique, Nn(x)  Pn(x).
 They must have the same truncation error. That is,
f ( n1) ( x )
f [ x , x0 , ... , xn ] k 1 ( x )   k 1 ( x )
( n  1) !
f ( k ) ( )
f [ x0 , ... , x k ]  ,   ( xmin , xmax )
k!
 The procedure is as follows.
f (x0)
f (x1) f [x0, x1]
f (x2) f [x1, x2] f [x0, x1 , x2]
… …… ……
f (xn1) …… ……
f (xn) f [xn1, xn] f [xn2, xn1, xn] f [x0, …, xn]
f (xn+1) f [xn, xn+1] f [xn1, xn, xn+1] f [x1, …, xn+1] f [x0, …, xn+1]
Use Newton’s interpolation to approximate ln11.5.

xi yi  ln xi First Second
Divided Divided
Differences Differences
11 2.3979 1

12 2.4849 0.0870
x 11
13 2.5649 0.0800 -0.0035 ( x  11)( x  12)
Linear Interpolation

ln11.5  N1 (11.75)
 2.3979  0.0870(11.5  11)  2.4414

Quadratic Interpolation

ln11.5  N 2 (11.75)
 N1 (11.75)  ( 0.0035)  (11.5  11)(11.5  12)
 2.4414  0.000875
 2.442275
§1.4 Difference and Interpolation on
Equally Spaced Nodes

 Difference

 Interpolation on equally spaced nodes


Difference
If the points are equally x i  x0  i h ( i  0, ... , n)
spaced:

Forward  f i  f i1  f i
k 1
Difference  f i  ( 
k  
f i )  k 1 f i1  k 1 f i

Backward  f i  f i  f i1
Difference  k fi   k  1 f i   k  1 f i  1

Central  k f i   k 1 f i    k 1 f i 
1 1
2 2
Difference where f i  1  f ( x i  h2 )
2
Properties of Difference
 Linearity:  ( a f ( x )  b g ( x ))  a f  b g
 If f (x) is a polynomial of degree m , then k f ( x ) (0  k  m ) is a
polynomial of degree m – k and k f ( x )  0 ( k  m )
 The values of the differences can be obtained from the function

n

n n
n
 fk  (  1) j  f k   (1) n j
n n
f n k  j f k  j n
j0 j j 0 j

where    n( n  1)...( n  j  1)


n
j! /* binomial coefficients */
 j
n
 And vice-versa f n  k   nj  j f k
j 0

k f 0 From Rn
 f [ x0 , ... , x k ] 
k! hk
 fn
k k f 0
( ) 
(k )
f [ xn , xn 1 , ... , xn  k ]  f
h
k
k ! hk
Newton’s
interpolation N n ( x )  f ( x0 )  f [ x0 , x1 ]( x  x0 )  ...  f [ x0 , ... , xn ]( x  x0 )...( x  xn1 )

 Newton Forward Difference Formula


n
t
Let x  x0  t h , then N n ( x )  N n ( x 0  t h )   k f ( x 0 )
k 0 k
f ( )
( n 1 )
Rn ( x )  t ( t  1)...( t  n)hn1 ,   ( x0 , xn )
( n  1)!

 Newton Backward Difference Formula


Reverse the order of the points
N n ( x )  f ( xn )  f [ xn , xn1 ]( x  xn )  ...  f [ xn , ... , x0 ]( x  xn )...( x  x1 )

n t
Let x  x n  t h , then N n ( x )  N n ( xn  t h)   (1)  k f ( xn )
k

k 0 k
f ( n 1) ( )
Rn ( x )  t (t  1)...( t  n )h n 1 ,   ( x0 , xn )
(n  1)!
Example: Find cubic interpolating polynomial by Newton
forward difference formula. And approximate f(2.8) by
Newton backward difference formula of degree 2.
xi 0 1 2 3
f(xi) 1 1.6487 2.7183 4.4871
§1.5 Hermite Interpolation

 Hermite Interpolation

 Interpolating Remainder

 Example
Not only the values of the approximate function are equal
to that of the primary function, but also the derivatives
are also equal. The interpolating function (x) satisfy
(xi) = f (xi), ’ (xi) = f ’ (xi)
,…, (mi) (xi) = f (mi) (xi).
Note:
 Given N conditions (and hence N equations), a polynomial of
degree N  1 can be determined.
The interpolating polynomial that agrees with f and all its
derivatives of order  m0 at one point x0 is just the Taylor
polynomial
f ( m0 ) ( x 0 )
P ( x )  f ( x0 )  f ( x0 )( x  x0 )  ...  ( x  x 0 ) m0
m0 !
f ( m0 1) ( )
with remainder R( x )  f ( x )   ( x )  ( x  x0 )( m0 1)
(m0  1)!
The case considering f and f’ gives the Hermite polynomials.
Hermite Interpolation

Problem : The values and the derivatives of f (x ) at


n  1 different points x 0 , x1 ,, x n are given, which are
y i  f ( x i ), y i  f ( x i ), (i  0,1,, n ) . Determine a
polynomial H ( x ) of degree no more than 2n  1 to satisfy

H ( xi )  y i , H ( xi )  y i, (i  0,1,, n)

The polynomial H ( x ) is called Hermite interpolating


polynomial of f ( x ) .
Method 1(Interpolating Basis Functions)

0 j  i
hi ( x j )  
1 j  i , hi( x j )  0 (i  0,1, , n)

0 j  i
hi ( x j )  0, hi( x j )  
1 j  i (i, j  0,1, , n)

n
H ( x)    yi hi ( x)  yihi ( x ) 
i 0

is the Hermite interpolating polynomial of f ( x ) .


Hermite Interpolating Polynomial
n
H ( x)    yi hi ( x)  yihi ( x) 
(x  xj )
i 0
li ( x )  
ji
( xi  x j )
hi(x) x0 , …, xn are all roots with multiplicity 2 except xi , 
hi ( x)   ai  bi ( x  xi ) li2 ( x)
From hi(xi) = 1 and hi’(xi) = 0 we have ai and bi 
hi ( x )  [1  2li( xi )( x  xi )]li2 ( x )

hi ( x ) x0 , …, xn are all roots with multiplicity 2 except xi , 


hi ( x)  Ci ( x  xi )li2 ( x)
hi( xi )  1  Ci  1 hi ( x)  ( x  xi )li2 ( x)

H ( x)  1  2( x  xi )li( xi ) l ( x) yi  ( x  xi )l ( x) yi


n
2 2
i i
i 0
x  x1
n 1
1
l0 ( x)  l0 ( x0 ) 
x0  x1 x0  x1
x  x0 1
l1 ( x)  l1( x1 ) 
x1  x0 x1  x0
Cubic Hermite interpolating polynomial on two points

x  x0 x  x1 2 x  x1 x  x0 2
H ( x)  (1  2 )( ) y0  (1  2 )( ) y1
x1  x0 x0  x1 x 0  x1 x1  x0
x  x1 2 x  x0 2
( x  x0 )( ) y0  ( x  x1 )( ) y1
x0  x1 x1  x0
Method 2(Method of Order Reducing)

Suppose
H ( x )  N n ( x )  Pn ( x )n 1 ( x ),
where N n ( x ) is the Newton's interpolating polynomial of
f ( x ) passing through points x0 , , xn , and we have
N n ( xi )  f ( xi ), i  0,1, , n.
Polynomial Pn ( x ) is of degree n and to be determined.
n
n 1 ( x )   ( x  xi )
i 0
Obvious H ( xi )  N n ( xi )  Pn ( xi )n1 ( xi )  yi

So Pn (x ) only needs to satisfy

H ( xi )  N n ( xi )  Pn ( xi ) n 1 ( xi )  y i

That is, Pn ( xi )  yi  N n ( xi )  n 1 ( xi ) (i  0,1,, n)


Example Determine a Hermite interpolating polynomial
according to the following data
xi 0 1

yi 0 1
y i 3 9

H ( x)  10 x  12 x  3x
3 2
Method of order reducing
1 0
N1 ( x)  0  ( x  0)  x
1 0

Suppose H ( x )  x  ( a  bx)( x  0)( x  1)

H ( x )  1  bx( x  1)  (a  bx)( x  1  x )
H (0)  1  a  3 H (1)  1  a  b  9
 a  2, b  10

∴ H ( x )  x  (10x  2) x( x  1)  10x  12x  3x


3 2
Uniqueness of Hermite Interpolation

x0 , x1 , , xn are n  1 different nodes.


Hermite interpolating polynomial H(x) of degree no
more than 2n+1 satisfying

H ( xi )  f ( xi ), H ( xi )  f '( xi ), (i  0,1, , n)

is unique.
Interpolating Remainder

Theorem Suppose x0 , x1 , , xn  [a, b] are different points.


And H ( x ) is the Hermite interpolating polynomial of
f ( x ) passing through these points. If f ( x )  C
( 2n2)
a, b , then for
any x  a, b we have
f (2 n  2) ( ) 2
R( x )  f ( x )  H ( x )  n 1 ( x ) ,   ( a , b)
(2n  2)!

Especially , the remainder of cubic Hermite interpolating


polynomial on two points is
f ( 4 ) ( )
R( x )  ( x  x 0 ) 2 ( x  x1 ) 2
4!
Example Suppose a  x0  x1  x2  b and f ( x )  C 4 [a , b]

Find interpolating polynomial P( x)

to satisfy the interpolating conditions

P( xi )  f ( xi ), i  0,1, 2
P( x1 )  f ( x1 )

and estimate its error.


§1.6 Cubic Spline Interpolation

 Disadvantage of Polynomial Interpolation

 Piecewise Interpolation

 Cubic Spline Interpolating Function

 Construction of Cubic Spline Interpolating Function

 Two Remarks
Disadvantage of Polynomial Interpolation
1
Example: Consider the Lagrange polynomial Ln(x) of f ( x)  on
1  x2
[5, 5]. Take xi  5  10 i ( i  0, ... , n)
n
2.5

2 Remember what I have said? 


Ln(x)  f (x)
Increasing the degree of interpolating polynomial
1.5
will NOT guarantee a good result,
since high-degree polynomials are
1
oscillating. n is larger,
0.5 the oscillation is larger.
0
Runge Phenomenon

-0.5
-5 -4 -3 -2 -1 0 1 2 3 4 5
Piecewise Linear Interpolation
Approximate f (x) by linear polynomials on each subinterval [ xi 1 , xi ] :

x  xi x  xi 1
f ( x )  Pi ( x )  yi 1  yi for x  [ xi 1 , xi ]
xi 1  xi xi  xi 1

uniform
Let h  max | xi 1  xi | . Then P h ( x ) 
 f ( x) as h  0.
y

y=f(x)

No longer smooth.

 Hermite piecewise polynomials O xi-1 xi xi+1


x

Given x0 , ... , x n ; y0 , ... , yn ; y0 , ... , yn


Construct the Hermite polynomial of degree 3 with y and y’ on the
two endpoints of [ x i , x i 1 ] .

It is not easy to obtain the derivatives.


1
f ( x)  , x i  i (i  0,1,,5)
EX. 1 x 2

Find the piecewise linear interpolating functions


and the approximating value of f (4.5) .
Solution:The values of f(x) at the interpolating nodes are

xi 0 1 2 3 4 5
f ( xi ) 1.00000 0.50000 0.20000 0.10000 0.05882 0.3846

For x  0,1 ,we have

x 1 x0
 ( x)   1.00000   0.50000  1  0.5 x
0 1 1 0
x 1 x0
 ( x)   1.00000   0.50000  1  0.5 x
0 1 1 0
Similarly,
1  0.5 x x  0,1
0.8  0.3 x x  (1,2]


 ( x )  0.4  0.1x x  ( 2,3]
0.22354  0.04118x x  (3,4]


0.14026  0.02036x x  ( 4,5]

f (4.5)   (4.5)  0.14026  0.02036  4.5  0.04864


Cubic Spline Interpolating Functions
Definition: Given a function f defined on [a, b] and a
set of nodes a = x0 < x1 < … < xn = b, a cubic spline
interpolating function S for f is a function that satisfies
the following conditions:
(1) S(x) is a cubic polynomial, denoted Si(x), on the
subinterval [ xi , xi+1] for each i = 0, 1, …, n – 1;
(2) S(x),S’(x), S”(x) are continuous on [a,b].
(3) S(xi) = f (xi) for each i = 0, 1, …, n;

f(x) H(x)
S(x)
Described by the first derivatives at nodes

Suppose S ( x j )  m j ( j  0,1,, n) , by piecewise cubic


Hermite interpolating polynomial on two points we have

x  x j 1 x  x j 2 x  x j x  x j 1 2
S j ( x)  (1  2 )( ) y j 1  (1  2 )( ) yj
hj hj hj hj
x  xj x  x j 1
( x  x j 1 )( ) m j 1  ( x  x j )(
2
)2 m j ()
hj hj
x   x j 1 , x j  ( j  1, , n)
6 x  2 xi 1  4 xi 6 x  4 xi 1  2 xi 6( xi 1  xi  2 x)
Si( x)  2
mi 1  2
mi  3
( f ( xi )  f ( xi 1 ))
hi hi hi
6 x  2 xi  4 xi 1 6 x  4 xi  2 xi 1 6( xi  xi 1  2 x)
Si1 ( x)  2
mi  2
mi 1  3
( f ( xi 1 )  f ( xi ))
hi 1 hi 1 hi 1

2 4 6
Si( xi )  mi 1  mi  2 ( f ( xi )  f ( xi 1 ))
hi hi hi
.

4 2 6
Si1 ( xi )  mi  mi 1  2 ( f ( xi 1 )  f ( xi ))
hi 1 hi 1 hi 1

S ( x)  C (2)
a, b, Si1( xi )  Si( xi )
Described by the first derivatives at nodes
2 4 4 2
mi 1  (  )mi  mi 1  6( f ( xi1 ) 2 f ( xi )  f ( xi )  f ( xi 1 )
2
)
hi hi hi 1 hi 1 hi 1 hi

hi 1 hi
i  , i  1  i 
hi  hi 1 hi  hi 1
gi  3( i f [ xi , xi 1 ]  i f [ xi 1 , xi ])

i mi 1  2mi  i mi 1  gi
n+1unknowns,n1 equations i  1, 2, , n 1
We still need 2 boundary conditions
Boundary Conditions (a)
(a) The first derivatives at two end points are given, that is,
m0  f ( x0 ) mn  f ( xn )

2 1   m1   g1  1 f ( x0 ) 
 2 2  m   g 
 2  2   2 
   
    
 n  2 2 n  2   mn  2   gn2 
 n 1 2   mn 1   g n 1  n 1 f ( xn ) 
Boundary Conditions (b)
(b) The second derivatives at two end points are given, that is,

S ( x0 )  f ( x0 ), S ( xn )  f ( xn ),

2 1   m0   g0 
 2 1  m   g 
 1  1   1 
   
    
 n 2 n   mn 1   g n 1 
 1 2   mn   g n 

f ( x1 )  f ( x0 ) h1 f ( xn )  f ( xn1 ) hn
g0  3  f ( x0 ) gn  3  f ( xn )
h1 2 hn 2
EX. Given the data table
x 0 1 2 3
f(x) 0 2 3 6
f′(x) 1 0
Determine the cubic spline interpolating
function according to the above data.

Solution.
For [0,1],
EX. Given the data table
x 0 1 2 3
f(x) 0 2 3 6
f′(x) 1 0
Determine the cubic spline interpolating
function according to the above data.
Described by the second derivatives at nodes
S ( x)  Si ( x) is a cubic polynomial on [ xi 1 , xi ],
so Si( x) is linear,by interpolation we have
x  xi 1 x  xi
Si( x)  M i  M i 1
hi hi
intergration
( x  xi 1 ) ( x  xi )
3 3
Si ( x )  M i  M i 1  C1 ( x  xi )  C2
6hi 6hi

M i hi2 M i hi2
Si ( xi )  yi , Si ( xi 1 )  yi 1   C 2  yi  C2  yi 
6 6
Described by the second derivatives at nodes
M i hi2 M i 1hi2
 C1hi  ( yi  )  yi
6 6
1  M i hi2 M i 1hi2 
 C1   yi   ( yi 1  )
hi  6 6 

( x  xi 1 )3
( x  xi ) 3
So Si ( x)  M i  M i 1
6hi 6hi
M h x  xi 1
2
M h x  xi 2
( yi  ) i i
 ( yi 1  ) i 1 i
(*)
6 hi 6 hi
i  1, n
( xi  x)2 ( x  xi 1 )2 f ( xi )  f ( xi 1 ) M i  M i 1
Si( x)   M i 1  Mi   hi
2hi 2hi hi 6

hi hi
Si( xi )  M i 1  M i  f [ xi 1 , xi ]
6 3

hi 1 hi 1
Si1 ( xi )   Mi  M i 1  f [ xi , xi 1 ]
3 6

S ( x)  C (2)
a, b , Si1 ( xi )  Si( xi )
.

hi hi  hi 1 hi 1
M i 1  Mi  M i 1  f [ xi , xi 1 ]  f [ xi 1 , xi ]
6 3 6
Described by the second derivatives at nodes

i M i 1  2M i  i M i 1  d i
i  1, 2, , n 1
hi 1 hi
i  , i  1  i 
hi 1  hi hi 1  hi
.
di  6 f [ xi 1 , xi , xi 1 ]

n+1unknowns,n1 equations

We still need 2 boundary conditions


Boundary Conditions (a)
(a) The first derivatives at two end points are given, that is,

S1( x0 )  f ( x0 ), Sn ( xn )  f ( xn )

2 1   M 0   d0 
 2 1  M   d 
 1  1   1 
   
    
 n 1 2 n 1   M n 1   d n 1 
 1 2   M n   d n 
6 6
2M 0  M1  ( f [ x0 , x1 ]  f ( x0 )) d0 M n1  2M n  ( f ( xn )  f [ xn1 , xn ]) dn
h1 hn
Boundary Conditions (b)
(b) The second derivatives at two end points are given, that is,

M 0  f ( x0 ) M n  f ( xn )

2 1   M 1   d1  1 f ( x0 ) 
 2 2  M   d 
 2  2   2 
   
    
 n  2 2 n  2   M n  2   d n 2 
 n 1 2   M n 1   d n 1  n 1 f ( xn ) 
EX Given the data table
x 2 4 6
f(x) 3 7 13
f′(x) 1 -1
Determine the cubic spline interpolating
function according to the above data.

Solution:boundary conditions (a),n=2,hi=h=2,


 2 1 0  M 0   d 0 
    

 1 2 1  M 1    d1 
 0 1 2  M   d 
  2   2 
h0 1 1
1   , 1 
h0  h1 2 2
6  y1  y0 ' 
d0    y0   3( f [ x0 , x1 ]  y0' )  3(2  1)  3
h0  h0 
6  ' y2  y1 
d 2   y2    3( y 2  f [ x1 , x2 ])  12
'

h1  h1 
3
d1  6 f [ x0 , x1 , x2 ] 
2

The system is
2 M0 + M 1 = 3
0.5 M0 + 2M1 +0.5 M2 = 1.5
M1 +2 M2 = -12
We have M0 =0.25 , M1 =2.5 M2 = -7.25
The cubic spline interpolating functions are

( x  x0 )3 ( x  x1 )3
S1 ( x)  M 1  M0 
6h0 6h0
y0 M 0 y1 M 1
(  h0 )( x  x1 )  (  h0 )( x  x0 )
h0 6 h0 6
1 5 17 8
  ( x  4)  ( x  2)  ( x  4)  ( x  2), x  [2,4]
3 3

48 24 12 3

Similarly,
5 29 3 8 107
S2 ( x)   ( x  6)  ( x  4)  ( x  6) 
3
( x  4), x  [4,6]
24 48 3 12
That is,
 1 5 3 17 8
 48 ( x  4)  24 ( x  2)  12 ( x  4)  3 ( x  2), x  [2, 4]
3

S ( x)  
 5 ( x  6)3  29 ( x  4)3  8 ( x  6)  107 ( x  4), x  [4,6]
 24 48 3 12
Convergence

Theorem 1.3: Suppose f ( x)  C [a, b] . S ( x) is the cubic spline


4

interpolating function for f ( x ) , satisfying


interpolating conditions and one of the two
types of boundary condition. Then

f ( m ) ( x)  S ( m ) ( x)  Cm h(4m ) f (4) ,

m  0,1, 2,3 ,

5 1 3    1 h
where C0  , C1  , C2  , C3  , h  max hi ,   ,
384 24 8 2 i min hi
i

and f (4)  max f (4) ( x) .


 a  x b
Unified Representation

 S1 ( x) x  [ x0 , x1 ]
S ( x)  
 S2 ( x) x  [ x1 , x2 ]

 S1 ( x) x  [ x0 , x1 ]
S ( x)  
 2
S ( x )  b1 ( x  x1 ) 3
x  [ x1 , x2 ]

0 x  x1
(x  x ) 3
1  
 ( x  x1 ) 3
x  x1
Summary
Lagrange : y0 … yn are given, basis functions are li(x),
n
Ln ( x )   li ( x ) yi
i 0

Newton  Ln(x): different form. Convenient adding points.

Hermite: not only yi =f(xi), but also yi ’=f’(xi) .

Spline:piecewise lower degree interpolation,


better smoothness.

You might also like