Lecture 05
Lecture 05
Lecture 05
Lecture 5:
Interpolation
1
Introduction to Interpolation
Introduction
Interpolation Problem
Existence and Uniqueness
Linear and Quadratic Interpolation
Newton’s Divided Difference Method
Properties of Divided Differences
Lagrange Interpolation 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
4
Example
Temperature Resistance
An experiment is used to determine (degree)
the resistance of a semi-conductor
as a function of temperature. The
0 1.792
following table is generated:
5 1.519
10 1.308
Problem: Estimate the resistance
when the temperature is 8 degrees.
15 1.140
5
Interpolation Problem
Find a polynomial that fits the data
points exactly.
R : Resistance
n
R(T) ak T k T : Temperature
k 0 ak : Polynomial
Ri R(Ti ) coefficients
Linear Interpolation: R(T)= 1.73 − 0.0422 T
R(8)= 1.3924
6
Existence and Uniqueness
Given a set of n+1 points:
x0 , f ( x0 ) , x1, f ( x1 ) , ...., xn , f ( xn )
Assumption: x0 , x1 ,..., xn are distinct
Theorem:
There is a unique polynomial fn(x) of order ≤ n
such that:
f n ( xi ) f ( xi ) for i 0 ,1,...,n
7
Examples of Polynomial Interpolation
Linear Interpolation Quadratic Interpolation
8
Linear Interpolation
Given any two points, x0 , f ( x0 ) , x1 , f ( x1 )
42
f1 ( x) 2 x 1 2 x
2 1
9
Quadratic Interpolation
Given any three points: x0 , f ( x0 ) , x1 , f ( x1 ) , and x2 , f ( x2 )
The polynomial that interpolates the three points is:
f 2 ( x) b0 b1 x x0 b2 x x0 x x1
where :
b0 f ( x0 )
f ( x1 ) f ( x0 )
b1 f [ x0 , x1 ]
x1 x0
f ( x2 ) f ( x1 ) f ( x1 ) f ( x0 )
x2 x1 x1 x0
b2 f [ x0 , x1 , x2 ]
x2 x0
10
General nth Order Interpolation
Given any n+1 points: x0 , f ( x0 ) , x1 , f ( x1 ) , ..., xn , f ( xn )
The polynomial that interpolates all points is:
11
Newton Divided Differences
f [ xk ] f ( xk ) 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
12
Newton 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]
i 1
x x j
n
f n ( x) F [ x0 , x1 ,..., xi ]
i 0 j 0
13
Newton 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.
14
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
16
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
11
f [ x2 ] f [ x1 ]
f [ x1 , x2 ]
x2 x1
17
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
18
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)
x y x y
1 0 2 3
2 3 1 0
3 8 3 8
20
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)
x 1
2 x2 1
21
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 ]
22
Example
Find a polynomial to x f(x)
interpolate the data.
2 3
4 5
5 1
6 6
7 9
23
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)
24
Summary
Interpolating Condition : f ( xi ) f n ( xi ) for i 0, 1, 2, ..., n
* The interpolating Polynomial is unique.
* Different methods can be used to obtain it
- Newton Divided Difference [Section 18.1 ]
- Lagrange Interpolation [Section 18. 2]
- Other methods
25
Lagrange Interpolation
26
The Interpolation Problem
Given a set of n+1 points:
27
Lagrange Interpolation
Problem: xi x0 x1 …. xn
Given
yi y0 y1 …. yn
f n ( xi ) f ( xi ) for i 0,1,..., n
n
Lagrange Interpolation Formula: f n ( x) f xi i ( x)
i 0
x x
n
i ( x) x x
j 0, j i
j
i j
28
Lagrange Interpolation
29
Lagrange Interpolation Example
P2 ( x) f ( x0 ) 0 ( x) f ( x1 ) 1 ( x) f ( x2 ) 2 ( x) x 1/3 1/4 1
0 ( x)
x x1 x x2
x 1 / 4 x 1 y 2 -1 7
x0 x1 x0 x2 1 / 3 1 / 4 1 / 3 1
1 ( x)
x x0 x x2 x 1 / 3 x 1
x1 x0 x1 x2 1 / 4 1 / 3 1 / 4 1
2 ( x)
x x0 x x1 x 1 / 3 x 1 / 4
x2 x0 x2 x1 1 1 / 3 1 1 / 4
P2 ( x) 2 18( x 1 / 4)( x 1) 116( x 1 / 3)( x 1)
72( x 1 / 3)( x 1 / 4)
30
Example
Find a polynomial to interpolate: x y
0 1
Both Newton’s interpolation
method and Lagrange 1 3
interpolation method must
give the same answer. 2 2
3 5
4 4
31
Newton’s Interpolation Method
0 1 2 -3/2 7/6 -5/8
1 3 -1 2 -4/3
2 2 3 -2
3 5 -1
4 4
32
Interpolating Polynomial
3 7
f 4 ( x ) 1 2( x ) x ( x 1) x ( x 1)( x 2)
2 6
5
x ( x 1)( x 2)( x 3)
8
115 95 2 59 3 5 4
f4 ( x) 1 x x x x
12 8 12 8
33
Interpolating Polynomial Using
Lagrange Interpolation Method
4
f4 ( x) f ( xi ) i 0 31 2 2 5 3 4 4
i 0
( x 1) ( x 2) ( x 3) ( x 4) ( x 1)( x 2)( x 3)( x 4)
0
(0 1) ( 0 2) (0 3) ( 0 4) 24
( x 0) ( x 2) ( x 3) ( x 4) x ( x 2)( x 3)( x 4)
1
(1 0) (1 2) (1 3) (1 4) 6
( x 0) ( x 1) ( x 3) ( x 4) x ( x 1)( x 3)( x 4)
2
( 2 0) ( 2 1) ( 2 3) ( 2 4) 4
( x 0) ( x 1) ( x 2) ( x 4) x ( x 1)( x 2)( x 4)
3
( 3 0) (3 1) ( 3 2) ( 3 4) 6
( x 0) ( x 1) ( x 2) ( x 3) x ( x 1)( x 2)( x 3)
4
( 4 0) ( 4 1) ( 4 2) ( 4 3) 24
34
Coefficients of an Interpolating
Polynomial
Although both the Newton and Lagrange
polynomials are well suited for determining
intermediate values between points, they do not
provide a polynomial in conventional form:
f ( x) a0 a1 x a2 x a x x
2 n
35
Coefficients of an Interpolating
Polynomial
f ( x0 ) a0 a1 x0 a x a x
2
2 0
n
n 0
f ( x1 ) a0 a1 x1 a x a x
2
2 1
n
n 1
f ( xn ) a0 a1 xn a x a x
2
2 n
n
n n
Where “x”s are the knowns and “a”s are the unknowns.
36
Example
37
Inverse Interpolation
Error in Polynomial Interpolation
38
Inverse Interpolation
Problem : Given a table of values
Find x such that : f ( x ) yk , where yk is given
xi x0 x1 …. xn
yi y0 y1 …. yn
One approach:
Use polynomial interpolation to obtain fn(x) to interpolate the
data then use Newton’s method to find a solution to x
fn ( x ) yk
39
Inverse Interpolation
Inverse interpolation: xi x0 x1 …. xn
1. Exchange the roles
yi y0 y1 …. yn
of x and y.
2. Perform polynomial
Interpolation on the yi y0 y1 …. yn
new table.
xi x0 x1 …. xn
3. Evaluate
x fn ( yk )
40
Inverse Interpolation
x
y
x y
41
Inverse Interpolation
Question:
42
Inverse Interpolation
Example
x 1 2 3
Problem : y 3.2 2.0 1.6
BE CAREFUL
44
10th Order Polynomial Interpolation
2
0.5
true function
-0.5
-5 -4 -3 -2 -1 0 1 2 3 4 5
45
Errors in polynomial Interpolation
Theorem
Let f ( x ) be a function such that :
f ( n 1) ( x ) is continuous on [a, b], and f ( n 1) ( x ) M .
Let P(x) be any polynomial of degree n
that interpolates f at n 1 equally spaced points
in [a, b] (including the end points). Then :
n 1
M ba
f ( x )-P ( x )
4( n 1) n
46
Example
f(x) sin (x)
We want to use 9 th order polynomial to interpolate f(x)
(using 10 equally spaced points) in the interval [0,1.6875].
f ( n 1) 1 for n 0
M 1, n 9
n 1
M ba
f(x)-P(x)
4(n 1) n
10
1 1.6875 9
f(x)-P(x) 1.34 10
4(10) 9
47
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.
48