You are on page 1of 53

Numerical

Analysis
Lecture 25
Chapter 5
Interpolation
Finite
Finite Difference
Difference Operators
Operators
Newton’s
Newton’s Forward
Forward Difference
Difference
Interpolation
Interpolation Formula
Formula
Newton’s
Newton’s Backward
Backward Difference
Difference
Interpolation
Interpolation Formula
Formula
Lagrange’s
Lagrange’s Interpolation
Interpolation
Formula
Formula
Divided
Divided Differences
Differences
Interpolation
Interpolation in
in Two
Two Dimensions
Dimensions
Cubic
Cubic Spline
Spline Interpolation
Interpolation
Newton’s
Forward
Difference
Interpolation
Formula
f ( x0  ph)  f ( x0 )  pf ( x0 )
p ( p  1) 2 p ( p  1)( p  2) 3
  f ( x0 )   f ( x0 )
2! 3!
p ( p  1) ( p  n  1) n
   f ( x0 )  Error
n!
An alternate expression is
p ( p  1) 2
y x  y0  py0   y0
2!
p ( p  1)( p  2) 3
  y0  
3!
p ( p  1) ( p  n  1) n
  y0  Error
n!
NEWTON’S
BACKWARD
DIFFERENCE
INTERPOLATION
FORMULA
The formula is,
f ( xn  ph)  f ( xn )  pf ( xn )
p ( p  1) 2
  f ( xn )
2!
p ( p  1)( p  2) 3
  f ( xn )  
3!
p ( p  1)( p  2) ( p  n  1) n
  f ( xn )  Error
n!
Alternatively form
p( p  1) 2
y x  yn  pyn   yn
2!
p( p  1)( p  2) 3
  yn  
3!
p( p  1)( p  2)  ( p  n  1) n
  yn  Error
n!
x  xn
Here p
h
LAGRANGE’S
INTERPOLATION
FORMULA
The Lagrange Formula
for Interpolation
( x  x1 )( x  x2 ) ( x  xn ) ( x  x0 )( x  x2 ) ( x  xn )
y  f ( x)  y0  y1  
( x0  x1 )( x0  x2 ) ( x0  xn ) ( x1  x0 )( x1  x2 )  ( x1  xn )
( x  x0 )( x  x1 )  ( x  xi 1 )( x  xi 1 )  ( x  xn )
 yi  
( xi  x0 )( xi  x1 )  ( xi  xi 1 )( xi  xi 1 )  ( xi  xn )
( x  x0 )( x  x1 )( x  x2 ) ( x  xn 1 )
 yn
( xn  x0 )( xn  x1 )( xn  x2 ) ( xn  xn 1 )
Alternatively compact form
y  f ( x)  L0 ( x) y0  L1 ( x ) y1  Li ( x ) yi    Ln ( x) yn

n n
  Lk ( x) yk   Lk ( x) f ( xk )
k 0 k 0

( x  x0 )( x  x1 ) ( x  xi 1 )( x  xi 1 )  ( x  xn )
Li ( x) 
( xi  x0 )( xi  x1 )  ( xi  xi 1 )( xi  xi 1 )  ( xi  xn )

1, if i  j
Li ( x j )   ij  
0, if i  j
Also

Pk ( x) Pk ( x)
Lk ( x)  
Pk ( xk ) ( xk )
( x)

( x  xk ) ( xk )
Finally, the Lagrange’s
interpolation polynomial of
degree n can be written as

n
( x)
y ( x)  f ( x)   f ( xk )
k  0 ( x  xk ) ( xk )
n n
  Lk ( x) f ( xk )  Lk ( x) yk
k 0 k 0
DIVIDED
DIFFERENCES
Let us assume that the
function y = f (x) is known for
several values of x, (xi, yi), for
i=0,1,..n.
The divided differences of
orders 0, 1, 2, …, n are now
defined recursively as:
The zero-th order
divided difference

y[ x0 ]  y ( x0 )  y0
The first order divided
difference is defined as

y1  y0
y[ x0 , x1 ] 
x1  x0
Second order divided
difference

y[ x1 , x2 ]  y[ x0 , x1 ]
y[ x0 , x1 , x2 ] 
x2  x0
Generally

1  y[ x1 , x2 , , xn ] 
y[ x0 , x1 , , xn ]    y[ x , x , , x ]
xn  x0  0 1 n 1 
Standard format of the
Divided Differences
NEWTON’S
DIVIDED
DIFFERENCE
INTERPOLATION
FORMULA
Let y = f (x) be a function which
takes values y0, y1, …, yn
corresponding to x = xi, i = 0, 1,…, n.
We choose an interpolating
polynomial, interpolating at x = xi,
i = 0, 1, …, n in the following form
y  f ( x)  a0  a1 ( x  x0 )  a2 ( x  x0 )( x  x1 )
   an ( x  x0 )( x  x1 ) ( x  xn 1 )
Here, the coefficients ak are so
chosen as to satisfy above equation
by the (n + 1) pairs (xi, yi).
Thus, we have
y ( x0 )  f ( x0 )  y0  a0 
y ( x1 )  f ( x1 )  y1  a0  a1 ( x1  x0 ) 

y ( x2 )  f ( x2 )  y2  a0  a1 ( x2  x0 )  a2 ( x2  x0 )( x2  x1 ) 
 

yn  a0  a1 ( xn  x0 )  a2 ( xn  x0 )( xn  x1 )    an ( xn  x0 )  ( xn  xn1 ) 
The first equation gives

a0  y ( x0 )  y0
The second equation gives

y1  y0
a1   y[ x0 , x1 ]
x1  x0
Third equation yields
y2  y0  ( x2  x0 ) y[ x0 , x1 ]
a2 
( x2  x0 )( x2  x1 )

which can be rewritten as


  y1  y0  
 y2  y1    ( x1  x0 )   ( x2  x0 ) y[ x0 , x1 ]
  x1  x0  
a2 
( x2  x0 )( x2  x1 )

that is
y2  y1  y[ x0 , x1 ]( x1  x2 ) y[ x1 , x2 ]  y[ x0 , x1 ]
a2  
( x2  x0 )( x2  x1 ) x 2  x0
Thus, in terms of second order
divided differences, we have

a2  y[ x0 , x1 , x2 ]
Similarly, we can show that

an  y[ x0 , x1 ,..., xn ]
Newton’s divided difference
interpolation formula

y  f ( x )  y0  ( x  x0 ) y[ x0 , x1 ]
 ( x  x0 )( x  x1 ) y[ x0 , x1 , x2 ]
 
( x  x0 )( x  x1 )  ( x  xn 1 ) y[ x0 , x1 ,..., xn ]
Newton’s divided
differences can also be
expressed in terms of
forward, backward and
central differences.
Assuming equi-spaced values
of abscissa, we have
y1  y0 y0
y[ x0 , x1 ]  
x1  x0 h

y1 y0

y[ x1 , x2 ]  y[ x0 , x1 ] h h  2
y0
y[ x0 , x1 , x2 ]   
x2  x0 2h 2!h 2
By induction, we can in
general arrive at the result

 y0
n
y[ x0 , x1 , , xn ]  n
n !h
Similarly
y1  y0 y1
y[ x0 , x1 ]  
x1  x0 h

y2 y1

y[ x1 , x2 ]  y[ x0 , x1 ] h h  y2
2
y[ x0 , x1 , x2 ]   
x2  x0 2h 2!h 2
In general, we have

 yn
n
y[ x0 , x1 ,..., xn ]  n
n !h
Also, in terms of central
differences, we have
y1  y0  y1/ 2
y[ x0 , x1 ]  
x1  x0 h
 y3/ 2  y1/ 2

y[ x1 , x2 ]  y[ x0 , x1 ] h h  2
y1
y[ x0 , x1 , x2 ]   
x2  x0 2h 2!h 2
In general, we have the
following pattern
 ym2m

y[ x0 , x1 ,..., x2 m ]  2m 
(2m)!h 

 2 m 1
ym  (1/ 2) 
y[ x0 , x1 ,..., x2 m 1 ]  2 m 1 
(2m  1)!h 
Example
Find the interpolating polynomial
by (i) Lagrange’s formula and
(ii) Newton’s divided difference
formula for the following data.
Hence show that they represent
the same interpolating polynomial.
X 0 1 2 4
Y 1 1 2 5
Solution
The divided difference table for the
given data is constructed as follows:

X Y 1st divided 2nd divided 3rd divided


difference difference difference
0 1
1 1 0
2 2 1 1/2 -1/2
4 5 3/2 1/6
(i) Lagrange’s interpolation
formula gives
( x  1)( x  2)( x  4) ( x  0)( x  2)( x  4)
y  f ( x)  (1)  (1)
( 1)( 2)(4) (1  0)(1  2)(1  4)

( x  0)( x  1)( x  4) ( x  0)( x  1)( x  2)


 (2)  (5)
(2)(2  1)(2  4) 4(4  1)(4  2)

( x 3  7 x 2  14 x  8) x 3  6 x 2  8 x x 3  5 x 2  4 x
  
8 3 2
5( x3  3 x 2  2 x)

24

x3 3x 2 2
   x 1
12 4 3
(ii) Newton’s divided difference
formula gives
1  1
y  f ( x)  1  ( x  0)(0)  ( x  0)( x  1)    ( x  0)( x  1)( x  2)   
 2  12 

x3 3x 2 2
   x 1
12 4 3

We observe that the interpolating


polynomial by both Lagrange’s and
Newton’s divided difference formulae
is one and the same.
Note!
Newton’s formula
involves less number of
arithmetic operations
than that of Lagrange’s.
Example
Using Newton’s divided
difference formula, find the
quadratic equation for the
following data.
Hence find y (2).
X 0 1 4
y 2 1 4
Solution:
The divided difference table for
the given data is constructed as:
x y 1st divided 2nd divided
difference difference
0 2

1 1 -1 1/2

4 4 1
Now, using Newton’s
divided difference formula,
we have
1
y  2  ( x  0)(1)  ( x  0)( x  1)  
2
1 2
 ( x  3 x  4)
2
Hence, y (2) = 1.
Example
A function y = f (x) is given at
the sample points x = x0, x1 and
x2. Show that the Newton’s
divided difference interpolation
formula and the corresponding
Lagrange’s interpolation
formula are identical.
Solution
For the function y = f (x), we
have the data

( xi , yi ), i  0,1, 2.
The interpolation
polynomial using Newton’
divided difference formula
is given as
y  f ( x)  y0  ( x  x0 ) y[ x0 , x1 ]
( x  x0 )( x  x1 ) y[ x0 , x1 , x2 ]
Using the definition of divided
differences, we can rewrite the
equation in the form
( y1  y0 )  y0
y  y0 ( x  x0 )  ( x  x0 )( x  x1 ) 
( x1  x0 )  ( x0  x1 )( x0  x2 )
y1 y2 
  
( x1  x0 )( x1  x2 ) ( x2  x0 )( x2  x1 ) 

 ( x0  x) ( x  x0 )( x  x1 ) 
 1    y0
 ( x0  x1 ) ( x0  x1 )( x0  x2 ) 
 ( x  x0 ) ( x  x0 )( x  x1 )  ( x  x0 )( x  x1 )
   y1  y2
 ( x1  x0 ) ( x1  x0 )( x1  x2 )  ( x2  x0 )( x2  x1 )
On simplification, it reduces to
( x  x1 )( x  x2 ) ( x  x0 )( x  x2 ) ( x  x0 )( x  x1 )
y y0  y1  y2
( x0  x1 )( x0  x2 ) ( x1  x0 )( x1  x2 ) ( x2  x0 )( x2  x1 )

which is the Lagrange’s form of


interpolation polynomial.

Hence two forms are identical.


Newton’s Divided
Difference
Formula with
Error Term
Following the basic definition
of divided differences, we
have for any x
y ( x)  y0  ( x  x0 ) y[ x, x0 ] 
y[ x, x0 ]  y[ x0 , x1 ]  ( x  x1 ) y[ x, x0 , x1 ] 

y[ x, x0 , x1 ]  y[ x0 , x1 , x2 ]  ( x  x2 ) y[ x, x0 , x1 , x2 ] 


y[ x, x0 ,..., xn 1 ]  y[ x0 , x1 ,..., xn ]  ( x  xn ) y[ x, x0 ,..., xn ]
Multiplying the
second Equation by (x – x0),
third by (x – x0)(x – x1)
and so on,
and the last by
(x – x0)(x – x1) … (x – xn-1) and
adding the resulting
equations, we obtain
y ( x)  y0  ( x  x0 ) y[ x0 , x1 ]  ( x  x0 )( x  x1 ) y[ x0 , x1 , x2 ] 
( x  x0 )( x  x1 ) ( x  xn 1 ) y[ x0 , x1 ,..., xn ]   ( x)

Where
 ( x)  ( x  x0 )( x  x1 ) ( x  xn ) y[ x, x0 ,..., xn ]

Please note that for x = x0, x1, …, xn,


the error term  ( x) vanishes
Numerical
Analysis
Lecture 25

You might also like