You are on page 1of 77

Numerical Methods

Interpolation

1
Lecture 3
Introduction to Interpolation
Introduction
Interpolation Problem
Existence and Uniqueness
Linear and Quadratic Interpolation
Newton’s Divided Difference Method
Properties of Divided Differences

2
Introduction
Interpolation was used for x sin(x)
long time to provide an
0 0.0000
estimate of a tabulated
function at values that are 0.1 0.0998
not available in the table.
0.2 0.1987

What is sin (0.15)? 0.3 0.2955


0.4 0.3894

Using Linear Interpolation sin (0.15) ≈ 0.1493


True value (4 decimal digits) sin (0.15) = 0.1494
3
The Interpolation Problem
Given a set of n+1 points,

x0 , f ( x0 ) , x1, f ( x1 ) , ...., xn , f ( xn )


Find an nth order polynomial f n (x )
that passes through all points, such that:

f n ( xi )  f ( xi ) for i  0,1, 2,..., n

4
Example
Temperature Viscosity
An experiment is used to determine (degree)
the viscosity of water as a function
of temperature. The following table
0 1.792
is generated:
5 1.519

10 1.308
Problem: Estimate the viscosity
when the temperature is 8 degrees.
15 1.140

5
The Difference Table
To find a function y(x) at given values of x, a
calculation may be:

 Exact as

y ( x)  x 7  6 x 6  6 x 5  21x 4  36 x 3  3 x 2  13x  3

 Tabulated as

y ( x)  e x sin x

6
The Difference Table
Suppose that y(x) is a given numerical function
tabulated at equal interval in x
x y
x0 y0
y1-y0
x1 y1 y2-2y1+y0
y2-y1
y3-2y2+y1
x2 y2
y3-y2
x3 y3
. .
.
yn-yn-1 7
xn yn
The Difference Table
introducing some difference operators:

 Forward Difference Operator (Δ)


y ( x)  y ( x  h)  y ( x)
y0  y1  y0 y1  y2  y1

 Backward difference Operator (  )

y ( x )  y ( x )  y ( x  h )
y1  y1  y0 y2  y2  y1

8
The Difference Table
 Central Difference Operator

h h
y ( x)  y ( x  )  y ( x  )
2 2
h
y ( x  )  y ( x  h)  y ( x)
2

y1 / 2  y1  y0  y 0  y1 y3 / 2  y2  y1  y1  y 2

9
The Difference Table
 Forward Differences y ( x)  y ( x  h)  y ( x)

x y Δy Δ 2y Δ 3y Δ 4y Δ5y
x0 y0
Δy0
x1 y1 Δ 2 y0
Δy1 Δ 3 y0
x2 y2 Δ 2 y1 Δ 4 y0
Δy2 Δ 3 y1 Δ 5 y0
x3 y3 Δ 2 y2 Δ 4 y1
Δy3 Δ 3 y2
x4 y4 Δ 2 y3
Δy4
x5 y5
10
The Difference Table
 Backward Differences y ( x )  y ( x )  y ( x  h )

11
The Difference Table
 Central Differences h
y ( x  )  y ( x  h)  y ( x)
2
x y δy δ 2y δ 3y δ 4y δ 5y
x0 y0
δy 1/2
x1 y1 δ 2 y1
δy 3/2 δ3y3/2
x2 y2 δ 2 y2 δ 4 y2
δy 5/2 δ3y5/2 δ5y5/2
x3 y3 δ 2 y3 δ 4 y3
δy 7/2 δ3y7/2
x4 y4 δ 2 y4
δy 9/2
x5 y5
12
Properties of The Difference Table
 For an nth order polynomial, the nth differences
are constant. x y 2 3 4
Δy Δy Δy Δy
-2 -11
9
-1 -2 -6
3 6
0 1 0 0
3 6
3
y  x  2x  1 1 4 6 0
9 6
2 13 12 0
21 6
3 34 18 0
39 6
4 73 24
63 13
5 136
Properties of The Difference Table
 For all other smooth functions, the differences
will gradually decrease and become constant
x y Δy (10-5) Δ2y Δ3y Δ4y Δ5y Δ6y
3.0 0.33333
-1075
for small 3.1 0.32258 67
-1008 -6
enough 3.2 0.31250 61 +1
h !!! -947 -5 -2
3.3 0.30303 56 -1 7
-891 -6 -5
3.4 0.29412 50 +4 -13
-841 -2 -8
3.5 0.28571 48 -4
-793 -6
14
3.6 0.27778 42
Properties of The Difference Table
 The effect of rounding
0 0 0 1
0 0 1
0 0 1 -6
0 1 -5
0 1 -4 15
1 -3 10
1 -2 6 -20
-1 3 -10
0 1 -4 15
0 -1 5
0 0 1 -6
0 0 -1
0 0 0 1
15
Properties of The Difference Table
 Effect of number of significant figures
x y Δy (10-5) Δ2y Δ3y Δ4y Δ5y Δ6y
3.0 0.333333
-10752
3.1 0.322581 671
-10081 -60
3.2 0.312500 611 7
-9470 -53 -4
3.3 0.303030 558 3 11
-8912 -50 +7
3.4 0.294128 508 10 -17
-8404 -40 -10
3.5 0.285714 468 0
-7936 -40
3.6 0.277778 428 16
Properties of The Difference Table
 The behavior of a difference table for a
well-behaved numerical function

 Higher order differences should eventually


become smaller

 At some point in the table, the differences


will become approximately constant

17
Properties of The Difference Table
 The Reasons of Behaving Improper Tables
y  (1  x 2 ) 1
o The interval is too large y  (1  x 2 ) 1
x y x10-4 x y x 10-4
0.0 1.0000 0.0 1.0000
-385 -99
0.2 0.9615 -609 0.1 0.9901 -187
-994 335 -286 32
0.4 0.8621 -274 -48 0.2 0.9615 -155 11
-1268 287 -95 -441 43 -10
0.6 0.7353 13 -143 0.3 0.9714 -112 1
-1255 144 -553 44
0.8 0.6098 157 0.4 0.8621 -68
-1098 -621
1.0 0.5000 0.5 0.8000
18
Properties of The Difference Table
 The function or its derivative has a
singularity

Unacceptably
slow decay !!

19
Difference Operators
Consider first the Taylor Series,
h h2 h3
y ( x  h)  y ( x)  y( x)  y( x)  y( x)  ......
1! 2! 3!
d
using D
dx
hD h2 D2 h3 D 3
y ( x  h)  y ( x )  y ( x)  y ( x)  y ( x)  ......
1! 2! 3!

x x x 2 x3 y ( x  h)  e hD y ( x)
e  1     ......
1! 2! 3!
20
Difference Operators
Defining E as
hD
Ee
yields
y ( x  h)  e hD y ( x) y ( x  h)  Ey( x)

y ( x  ph)  E p y ( x)

Difference operators Δ ,  and δ

h
y ( x  h)  y ( x)  y ( x)  y ( x  h)  y ( x  )
2
21
Difference Operators
These may be related to E;

y ( x  h)  y ( x)  y ( x) y ( x  h )  y ( x )  y ( x  h )
Ey( x)  y ( x)  y ( x) Ey ( x)  y ( x)  Ey ( x)
E 1   E  1  E
  1  E 1
h
y ( x  h)  y ( x)  y ( x  )
2
Ey ( x )  y ( x)  E 1 / 2 y ( x)
E  1  E1 / 2
  E1 / 2  E 1 / 2
22
Difference Operators
We define the averaging operator μ ;
1 1/ 2
  ( E  E 1 / 2 )
2
It follows 1
y0  ( y1 / 2  y1 / 2 )
2
1 1
y0  ( E1 / 2  E 1 / 2 )( E 1 / 2  E 1 / 2 ) y0  ( E  E 1 ) y0
2 2
1
y0  ( y ( x  h)  y ( x  h)
2
3 21
 y0   ( ) y0  (y1  y1 ) 23
2
Difference Operators
 Homework

  1  e  hD    (  2 )1 / 2
hD 
  2 sinh( ) E1 / 2   
2 2
hD 2 2
  cosh( )  1
2 4

prove the above identities !


24
Interpolation (Equal Intervals)
Formulae for interpolation are of two types

Finite Difference Methods

• These methods make direct use of the


difference table

Lagrangian Methods

• Truncated version of finite difference


methods which assume that higher order
differences are negligible
25
Interpolation (Equal Intervals)
 Finite Difference Methods
• The Newton-Gregory Forward Formula:

y ( x  ph)  E p y ( x)  (1  ) p y ( x)
recall that
2
x
(1  x)  1  x   (  1)  ......
2
so

p ( p  1) 2
y ( x  ph)  y ( x)  py ( x)   y ( x)
2!
p ( p  1)( p  2) 3
  y ( x)  ........
3!
26
Interpolation (Equal Intervals)
 Find y(3.15) for x=3.1 h=0.1 p=1/2
x y Δy (10-5) Δ2y Δ3y Δ4 y Δ5y Δ6y
3.0 0.33333
-1075
3.1 0.32258 67
-1008 -6
3.2 0.31250 61 +1 1
-947 -5 -2 y ( x) 
3.3 0.30303 56 -1 7 x
-891 -6 -5
3.4 0.29412 50 +4 -13
-841 -2 -8
3.5 0.28571 48 -4
-793 -6
3.6 0.27778 42 27
Interpolation (Equal Intervals)
 y(3.15) for x=3.1 h=0.1 p=1/2

p ( p  1) 2
y ( x  ph)  y ( x)  py ( x)   y ( x)
2!
p ( p  1)( p  2) 3
  y ( x)  ........
3!
1 1 1
y (3.15)  0.32258  (0.01008)  (0.00061)  (0.00005)
2 8 16
 0.31746
The exact value is 0.31746 (5 significant figures)

28
Interpolation (Equal Intervals)
 Finite Difference Methods
• The Newton-Gregory Backward Formula:

y ( x  ph)  E p y ( x)  (1  )  p y ( x)

Consequently,

p ( p  1) 2
y ( x  ph)  y ( x)  py ( x)   y ( x)
2!
p( p  1)( p  2) 3
  y ( x)  ........
3!

29
Interpolation (Equal Intervals)
 Find y(3.54) for x=3.5 h=0.1 p=0.4
x y Δy (10-5) Δ2y Δ3y Δ4 y Δ5y Δ6y
3.0 0.33333
-1075
3.1 0.32258 67
-1008 -6
3.2 0.31250 61 +1 1
-947 -5 -2 y ( x) 
3.3 0.30303 56 -1 7 x
-891 -6 -5
3.4 0.29412 50 +4 -13
-841 -2 -8
3.5 0.28571 48 -4
-793 -6
3.6 0.27778 42 30
Interpolation (Equal Intervals)
 y(3.54) for x=3.5 h=0.1 p=0.4
p ( p  1) 2
y ( x  ph)  y ( x)  py ( x)   y ( x)
2!
p( p  1)( p  2) 3
  y ( x)  ........
3!

(1.4) 0.4(1.4)(2.4)
y (3.54)  0.28571  0.4(0.0841)  0.4 (0.00050)  (0.00006)
2 6
 0.28247

The exact value is 0.28248 (4 significant figures)


31
Interpolation (Equal Intervals)
 Finite Difference Methods
• The Gauss Central Difference Formula:

y ( x  ph)  E p y ( x)  (1  E1 / 2 ) p y ( x)

Consequently,

1/ 2 p ( p  1) 2
y ( x  ph)  y ( x)  pE y ( x)   Ey ( x)
2!
p ( p  1)( p  2) 3 3 / 2
  E y ( x)  ........
3!

32
Interpolation (Equal Intervals)
Re-arranging yields
h p ( p  1) 2
y ( x  ph)  y ( x)  py ( x  )   y ( x  h)
2 2!
p ( p  1)( p  2) 3 3h
  y( x  )
y(x-2h) 2
δ y(x-2h) 3 ! 2
δy(x-3h/2) δ3y(x-3h/2)  .......
y(x-h) δ2 y(x-h) δ4 y(x-h)
δy(x-h/2) δ3y(x-h/2)
y(x) δ2 y(x) δ4 y(x)
Same as Newton-
δy(x+h/2) δ3y(x+h/2) Gregory Formula !!
y(x+h) δ2 y(x+h) δ4 y(x+h)
δy(x+3h/2) δ3y(x+3h/2)
y(x+2h) δ2 y(x+2h)
33
Interpolation (Equal Intervals)
The third term in below equation;
p( p  1) 2
y ( x  ph)  y ( x)  pE 1 / 2 y ( x )   Ey ( x)
2!
p ( p  1)( p  2) 3 3 / 2
  E y ( x)  ........
3!
 2 E   2 (1  E1 / 2 )
 2 Ey( x)   2 (1  E1 / 2 ) y ( x)   2 y ( x)   3 y ( x  h / 2)
 3 E 3 / 2   3 EE1 / 2   3 (1  E1 / 2 ) E1 / 2   3 E1 / 2   4 E
  3 E1 / 2   4 (1  E1 / 2 )   3 E1 / 2   4   5 E1 / 2

34
Interpolation (Equal Intervals)
 3 E 3 / 2 y ( x)   3 y ( x  h / 2)   4 y( x)   5 y ( x  h / 2)
1/ 2
The process continues replacing E with (1  E )
until only E 1 / 2 ‘s remain in the formula;

h p( p  1) 2
y ( x  ph)  y ( x)  py ( x  )   y ( x)
2 2!
p( p 2  1) 3 h p( p 2  1)( p  2) 4
  y( x  )   y ( x)  ....
3! 2 4!
so called the Gauss Forward Formula !!

35
Interpolation (Equal Intervals)
The pattern of differences:
y(x-2h) δ2 y(x-2h)
δy(x-3h/2) δ3y(x-3h/2)
y(x-h) δ2 y(x-h) δ4 y(x-h)
δy(x-h/2) δ3y(x-h/2)
y(x) δ2 y(x) δ4 y(x)
δy(x+h/2) δ3y(x+h/2)
y(x+h) δ2 y(x+h) δ4 y(x+h)
δy(x+3h/2) δ3y(x+3h/2)
y(x+2h) δ2 y(x+2h)

36
Interpolation (Equal Intervals)
A similar backward formula may be obtain as;
First show that

E 1  1  E 1 / 2 E p  (1  E 1 / 2 )  p

with similar manipulations;


h p( p  1) 2
y ( x  ph)  y ( x)  py ( x  )   y ( x)
2 2!
p( p 2  1) 3 h
  y( x  ) 
3! 2
so called the Gauss Backward Formula !!
37
Interpolation (Equal Intervals)
The pattern of differences:
y(x-2h) δ2 y(x-2h)
δy(x-3h/2) δ3y(x-3h/2)
y(x-h) δ2 y(x-h) δ4 y(x-h)
δy(x-h/2) δ3y(x-h/2)
y(x) δ2 y(x) δ4 y(x)
δy(x+h/2) δ3y(x+h/2)
y(x+h) δ2 y(x+h) δ4 y(x+h)
δy(x+3h/2) δ3y(x+3h/2)
y(x+2h) δ2 y(x+2h)

38
Interpolation (Equal Intervals)
The Stirling Formula:
Adding two formula;

h p ( p  1) 2
y ( x  ph)  y ( x)  py ( x  )   y ( x)
2 2!
p( p 2  1) 3 h p( p 2  1)( p  2) 4
  y( x  )   y ( x)  ....
3! 2 4!

h p( p  1) 2
y ( x  ph)  y ( x)  py ( x  )   y ( x)
2 2!
p( p 2  1) 3 h
  y( x  ) 
3! 2
39
Interpolation (Equal Intervals)
yields;
p2 2
y ( x  ph)  y ( x)  py ( x)   y ( x)
2!
p ( p 2  1) 3
  y ( x)  ........
3!
the second term :
 h h 
2 y ( x  ph)  2 y ( x)  py ( x)  p y ( x  )  y ( x  ) 
 2 2 
 2 y ( x)  2 py ( x) 

1 1/ 2 1 / 2 1 h h 
where   ( E  E )   y ( x  )  y ( x  )
2 2 2 2  40
Interpolation (Equal Intervals)
The pattern of differences:
y(x-2h) δ2 y(x-2h)
δy(x-3h/2) δ3y(x-3h/2)
y(x-h) δ2 y(x-h) δ4 y(x-h)
δy(x-h/2) δ3y(x-h/2)
y(x) δ2 y(x) δ4 y(x)
δy(x+h/2) δ3y(x+h/2)
y(x+h) δ2 y(x+h) δ4 y(x+h)
δy(x+3h/2) δ3y(x+3h/2)
y(x+2h) δ2 y(x+2h)

p2 2
y ( x  ph)  y ( x)  py ( x)   y ( x)
2!
p( p 2  1) 3
  y ( x)  ........ 41
3!
Interpolation (Equal Intervals)
 Find y(3.32) for x=3.3 h=0.1 p=0.2
x y Δy (10-5) Δ2y Δ3y Δ4 y Δ5y Δ6y
3.0 0.33333
-1075
3.1 0.32258 67
-1008 -6
3.2 0.31250 61 +1 1
-947 -5 -2 y ( x) 
3.3 0.30303 56 -1 7 x
-891 -6 -5
3.4 0.29412 50 +4 -13
-841 -2 -8
3.5 0.28571 48 -4
-793 -6
3.6 0.27778 42 42
Interpolation (Equal Intervals)
 Find y(3.32) for x=3.3 h=0.1 p=0.2
p2 2
y ( x  ph)  y ( x)  py ( x)   y ( x)
2!
p( p 2  1) 3
  y ( x)  ........
3!
0.2 2 1
y (3.32)  0.30303  (0.00891  0.00947)  0.2 (0.00056)
2 2
0.2(0.96)
 (0.00005  0.00006)  0.30120496
12

The exact value is 0.30120481 (6 significant figures)


43
Interpolation (Equal Intervals)
 The Bessel Formula:
We replace E in
p ( p  1) 2
y ( x  ph)  y ( x)  pE 1 / 2 y ( x)   Ey ( x)
2!
p ( p  1)( p  2) 3 3 / 2
  E y ( x)  ........
3!
wherever appears by

E  (  )2
2
2
2 1
and then μ2 by 4
until only δ’s and μ to the first power remain
44
Interpolation (Equal Intervals)
for the first few operators, we have
 2 2 2
E  (   )       
2  4 
 2  2 2  2 2  2
E  (   )         1       1    
2  4   4 4   2 

3/ 2 1/ 2   2  3 1 
E E E  (   )1            2  3 

2  4   2 2 

carrying out these substitutions in


p ( p  1) 2
y ( x  ph)  y ( x)  pE 1 / 2 y ( x)   Ey ( x)
2!
p ( p  1)( p  2) 3 3 / 2
  E y ( x)  ........
3! 45
Interpolation (Equal Intervals)
which then can be re-arranged into

h p ( p  1) 2 h
y ( x  ph)  y ( x)  py ( x  )   y ( x  )
2 2! 2
p ( p  1)( p  1 / 2) 3 h p ( p 2  1)( p  2) 4 h
  y( x  )   y ( x  )  ...
3! 2 4! 2
we observe that
1 1/ 2
2 1 / 2 2 1 2 h 2 h 
 y  ( E  E ) y    y ( x  )   y ( x  ) 
2 2 2 2 

h 1 1/ 2 h 1 2
2 2
1 / 2 2
2 2

 y ( x  )  ( E  E ) y ( x  )   y ( x  h)   2 y ( x)
2

46
Interpolation (Equal Intervals)
similarly,
h 1 h 1 4
 4 y ( x  )  ( E 1 / 2  E 1 / 2 ) 4 y ( x  ) 
2 2 2 2

 y ( x  h)   4 y ( x ) 
The pattern of differences:
y(x-2h) δ2 y(x-2h)
δy(x-3h/2) δ3y(x-3h/2)
y(x-h) δ2 y(x-h) δ4 y(x-h)
δy(x-h/2) δ3y(x-h/2)
y(x) δ2 y(x) δ4 y(x)
δy(x+h/2) δ3y(x+h/2)
y(x+h) δ2 y(x+h) δ4 y(x+h)
δy(x+3h/2) δ3y(x+3h/2)
y(x+2h) δ2 y(x+2h)
47
Interpolation (Equal Intervals)
 Find y(3.34) for x=3.3 h=0.1 p=0.4
x y Δy (10-5) Δ2y Δ3y Δ4 y Δ5y Δ6y
3.0 0.33333
-1075
3.1 0.32258 67
-1008 -6
3.2 0.31250 61 +1 1
-947 -5 -2 y ( x) 
3.3 0.30303 56 -1 7 x
-891 -6 -5
3.4 0.29412 50 +4 -13
-841 -2 -8
3.5 0.28571 48 -4
-793 -6
3.6 0.27778 42 48
Interpolation (Equal Intervals)
 Find y(3.34) for x=3.3 h=0.1 p=0.4
h p ( p  1) 2 h
y ( x  ph)  y ( x)  py ( x  )   y ( x  )
2 2! 2
p ( p  1)( p  1 / 2) 3 h p ( p 2  1)( p  2) 4 h
  y( x  )   y ( x  )  ...
3! 2 4! 2
(0.6)
y (3.32)  0.30303  0.4(0.00891)  0.4 (0.00056
4
0.4(0.6)(0.1)
 0.00050)  (0.00006)  0.29941
6
The exact value is 0.29940 (~5 significant figures)
49
Interpolation (Equal Intervals)
Summary
 Generally, the choice of formula depends on where we wish to
interpolate in the table.
 Near the ends of the table, we must use one of the Newton-
Gregory formulas.
 In all other situation ( in the mid ranges of the table) we will
prefer the central difference formulae, namely the Stirling or
Bessel formula. This is for two reasons:
 Coefficients of those formulas decrease much more
rapidly
 Information will usually be more reliable than the
results based on information on one side only
 In all cases, the value of p should always be taken as small as
possible
50
Inverse Interpolation (Equal Int.)
 Find y(3.3+p*0.1)=0.3 for p=?

h p ( p  1) 2 h
y ( x  ph)  y ( x)  py ( x  )   y ( x  )
2 2! 2
p ( p  1)( p  1 / 2) 3 h p ( p 2  1)( p  2) 4 h
  y( x  )   y ( x  )  ...
3! 2 4! 2

p ( p  1) 0.00056  0.00050
0.3  0.30303  p(0.00891)  ( )
2! 2
p( p  1)( p  1 / 2)
 (0.00006)
3!

51
Inverse Interpolation (Equal Int.)
 Starting with initial guess of p0=0.1

0.00891 p  0.00303  0.000265 p ( p  1)  0.00001 p ( p  1)( p  1 / 2)

0.00891 p1  0.00303  0.00002385 p1  0.3374


0.00891 p2  0.00303  0.00005920 p 2  0.3334
0.00891 p3  0.00303  0.00005920 p3  0.3334
x  0.3  0.1(0.3334)  0.33334
The exact value of p=0.3333
x  0.3  0.1(0.3333)  0.33333
52
Lagrangian Formulae
2
 If we assume that y ( x) and all high order

differences are negligibly, we obtain;

y ( x  h)
y ( x  ph)  y ( x)  py ( x)
 y(x)  py(x  h) - y(x)
y ( x  ph)
0  p 1
y (x)

53
Lagrangian Formulae
 It is worthwhile to retain a further term in
p ( p  1) 2
y ( x  ph)  y ( x)  py ( x)   y ( x)
2!
p ( p  1)( p  2) 3
  y ( x)  ........
3!

p ( p  1)
y ( x  ph)  y ( x)  p y ( x  h)  y ( x)   y ( x  2h)  2 y ( x  h)  y ( x )
2!

p ( p  1)  p ( p  1) 
y ( x  ph)  y ( x  2h)   p  p ( p  1)y ( x  h)    p  1 y ( x)
2!  2 

54
Lagrangian Formulae
 We obtain;
1
y ( x  ph)   p( p  1) y ( x  2h)  2 p(2  p) y ( x  h)  ( p  1)( p  2) y ( x)
2

y ( x  2h)
0 p2
y ( x  ph) y ( x  h)

y (x)

55
Lagrangian Formulae
 The Stirling formula truncated after three term
is;
p p2
y ( x  ph)  y ( x)   y ( x  h)  y ( x  h)   y ( x  h )  2 y ( x )  y ( x  h )
2 2

p ( p  1) p ( p  1)
y ( x  ph)  y ( x  h)  ( p 2  1) y ( x)  y ( x  h)
2 2
y ( x  h)

y (x) 1  p  1

y ( x  h)
56
Lagrangian Formulae
 The four-point formula;
( p  1)( p  21) ( p 2  1)( p  2)
y ( x  ph)   y ( x  2h)  y ( x)
6 2
p ( p  1)( p  2) y ( x  h) p ( p 2  1)
  y ( x  2 h)
2 6
 Five-point formula
p ( p 2  1)( p  2) p ( p  1)( p 2  4)
y ( x  ph)   y ( x  2h)  y ( x  h)
24 6
( p 2  1)( p 2  4) y ( x) p( p  1)( p 2  4)
  y ( x  h)
4 6
p ( p 2  1)( p  2)
 y ( x  2h)
24
57
Interpolation (Unequal Intervals)
 Lagrangian Formula

Let us suppose that we have (n+1) pivotal values; then an


nth order polynomial passing exactly through each of
these points is,

Pn ( x )  l0 ( x ) f 0  l1 ( x ) f1  ..........  ln ( x) f n

Where f i  f ( xi ) are the pivotal function values and are


nth degree polynomial defined according to

58
Lagrange Interpolation
Problem: xi x0 x1 …. xn
Given
yi y0 y1 …. yn

Find the polynomial of least order f n (x) such that:

f n ( xi )  f ( xi ) for i  0,1,..., n
n
Lagrange Interpolation Formula: Pn ( x)   f  xi   i ( x)
i 0

 i ( x)  
n x  xj 
j  0 , j  i xi  x j 
59
Lagrange Interpolation

 i ( x) are called the cardinals.


The cardinals are n th order polynomials :
0 i  j
i (x j )  
1 i  j

 ( x)  ( x  x0 )( x  x1 )....( x  xi 1 )( x  xi 1 )....( x  xn )
i

60
Lagrange Interpolation Example
P2 ( x)  f ( x0 ) 0 ( x)  f ( x1 ) 1 ( x)  f ( x2 ) 2 ( x) x 1/3 1/4 1
x  x1  x  x2   x  1 / 4 x  1 y 2 -1 7
 0 ( x) 
x0  x1  x0  x2  1 / 3  1 / 4 1 / 3  1 n

 1 ( x) 
x  x0  x  x2   x  1 / 3 x  1 Pn ( x)   f  xi   i ( x)
x1  x0  x1  x2  1 / 4  1 / 3 1 / 4  1 i 0
n x  x j 
 2 ( x) 
x  x0  x  x1   x  1 / 3 x  1 / 4  i ( x)   x  x 
x2  x0  x2  x1  1  1 / 3 1  1 / 4 j 0, j  i i j

P2 ( x)  2 18( x  1 / 4)( x  1) 116( x  1 / 3)( x  1)


 72( x  1 / 3)( x  1 / 4)

61
Lagrange Interpolation
 In the case of high order polynomials

f (x)

x
62
10th Order Polynomial Interpolation
2

1.5 10 th order interpolating polynomial

0.5

true function

-0.5
-5 -4 -3 -2 -1 0 1 2 3 4 5

63
Divided Differences
f [ xk ]  f ( x k ) Zeroth order DD
f [ x1 ]  f [ x0 ]
f [ x0 , x1 ]  First order DD
x1  x0
f [ x1 , x2 ]  f [ x0 , x1 ]
f [ x0 , x1 , x2 ]  Second order DD
x2  x0
............
f [ x1 , x2 ,..., xk ]  f [ x0 , x1 ,..., xk 1 ]
f [ x0 , x1 ,..., xk ] 
xk  x0

64
Divided Difference Table
x F[ ] F[ , ] F[ , , ] F[ , , ,]
x0 F[x0] F[x0,x1] F[x0,x1,x2] F[x0,x1,x2,x3]
x1 F[x1] F[x1,x2] F[x1,x2,x3]
x2 F[x2] F[x2,x3]
x3 F[x3]

n i 1 
f n ( x)    F [ x0 , x1 ,..., xi ]  x  x j 
i 0  j 0 

65
Divided Difference Table
x F[ ] F[ , ] F[ , , ]
xi f(xi)
0 -5 2 -4
1 -3 6
0 -5
-1 -15 1 -3
-1 -15
Entries of the divided difference
table are obtained from the data
table using simple operations.

66
Divided Difference Table
x F[ ] F[ , ] F[ , , ] xi f(xi)
0 -5 2 -4 0 -5
1 -3 6 1 -3
-1 -15 -1 -15

The first two column of the


table are the data columns.
Third column: First order differences.
Fourth column: Second order differences.
67
Divided Difference Table
x F[ ] F[ , ] F[ , , ] xi yi
0 -5 2 -4 0 -5
1 -3 6
-1 -15 1 -3
-1 -15
 3  (5)
2
1 0
f [ x1 ]  f [ x0 ]
f [ x0 , x1 ] 
x1  x0

68
Divided Difference Table
x F[ ] F[ , ] F[ , , ] xi yi
0 -5 2 -4 0 -5
1 -3 6
-1 -15 1 -3
-1 -15
 15  (3)
6
1 1

f [ x2 ]  f [ x1 ]
f [ x1 , x2 ] 
x2  x1

69
Divided Difference Table
x F[ ] F[ , ] F[ , , ] xi yi
0 -5 2 -4 0 -5
1 -3 6
-1 -15 1 -3
-1 -15

6  ( 2)
 4
 1  ( 0)
f [ x1 , x2 ]  f [ x0 , x1 ]
f [ x0 , x1 , x2 ] 
x2  x0
70
Divided Difference Table
x F[ ] F[ , ] F[ , , ] xi yi
0 -5 2 -4 0 -5
1 -3 6
-1 -15 1 -3
-1 -15

f 2 ( x)  5  2( x  0)  4( x  0)( x  1)

f2(x)= F[x0]+F[x0,x1] (x-x0)+F[x0,x1,x2] (x-x0)(x-x1)


71
Two Examples
Obtain the interpolating polynomials for the two examples:

x y x y

1 0 2 3

2 3 1 0

3 8 3 8

What do you observe?

72
Two Examples
x Y
x Y
1 0 3 1 2 3 3 1
2 3 5 1 0 4
3 8 3 8

P2 ( x)  0  3( x  1)  1( x  1)( x  2) P2 ( x)  3  3( x  2)  1( x  2)( x  1)
2
 x 1  x2 1

Ordering the points should not affect the interpolating polynomial.

73
Properties of Divided Difference
Ordering the points should not affect the divided difference:

f [ x0 , x1 , x2 ]  f [ x1 , x2 , x0 ]  f [ x2 , x1 , x0 ]

74
Example
 Find a polynomial to x f(x)
interpolate the data.
2 3

4 5

5 1

6 6

7 9

75
Example
x f(x) f[ , ] f[ , , ] f[ , , , ] f[ , , , , ]
2 3 1 -1.6667 1.5417 -0.6750
4 5 -4 4.5 -1.8333
5 1 5 -1
6 6 3
7 9
f 4  3  1( x  2)  1.6667( x  2)( x  4)  1.5417( x  2)( x  4)( x  5)
 0.6750( x  2)( x  4)( x  5)( x  6)

76
Summary
 The interpolating polynomial is unique.
 Different methods can be used to obtain it.
 Newton’s divided difference
 Lagrange interpolation
 Others
 Polynomial interpolation can be sensitive to
data.
 BE CAREFUL when high order polynomials
are used.

77

You might also like