ee3561_unit 5(c)al-dhaifallah14361 ee 3561 : computational methods unit 5 : interpolation dr....
TRANSCRIPT
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 1
EE 3561 : Computational MethodsUnit 5:
Interpolation
Dr. Mujahed AlDhaifallah (Term 351)
Read Chapter 18, Sections 1-5
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 2
Introduction to Interpolation
IntroductionInterpolation problemExistence and uniquenessLinear and Quadratic interpolation Newton’s Divided Difference methodProperties of Divided Differences
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 3
Introduction Interpolation was used for
long time to provide an estimate of a tabulated function at values that are not available in the table.
What is sin (0.15)?
x sin(x)
0 0.0000
0.1 0.0998
0.2 0.1987
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
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 4
The interpolation Problem Given a set of n+1 points,
find an nth order polynomial that passes through all points
)(,....,,)(,,)(, 1100 nn xfxxfxxfx
)(xfn
niforxfxf iin ,...,2,1,0)()(
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 5
Example An experiment is used to determine
the viscosity of water as a function of temperature. The following table is generated
Problem: Estimate the viscosity when the temperature is 8 degrees.
Temperature(degree)
Viscosity
0 1.792
5 1.519
10 1.308
15 1.140
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 6
Interpolation ProblemFind a polynomial that fit the data points
exactly.
)V(TV
TaV(T)
ii
n
k
kk
0
tscoefficien
polynomial:
eTemperatur:
viscosity:
ka
T
V
Linear Interpolation V(T)= 1.73 − 0.0422 T
V(8)= 1.3924
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 7
Existence and Uniqueness Given a set of n+1 points
Assumption are distinct
Theorem:There is a unique polynomial fn(x) of order ≤ n
such that
niforxfxf iin ,...,1,0)()(
nxxx ,...,, 10
)(,....,,)(,,)(, 1100 nn xfxxfxxfx
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 8
Examples of Polynomial InterpolationLinear Interpolation
Given any two points, there is one polynomial of order ≤ 1 that passes through the two points.
Quadratic Interpolation
Given any three points there is one polynomial of order ≤ 2 that passes through the three points.
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 9
Linear InterpolationGiven any two points,
The line that interpolates the two points is
Example :find a polynomial that interpolates (1,2) and (2,4)
)(,,)(, 1100 xfxxfx
001
0101
)()()()( xx
xx
xfxfxfxf
xxxf 2112
242)(1
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 10
Quadratic Interpolation Given any three points, The polynomial that interpolates the three points is
)(,)(,,)(, 221100 xfxandxfxxfx
02
01
01
12
12
2102
01
01101
00
1020102
)()()()(
],,[
)()(],[
)(
)(
xx
xx
xfxf
xxxfxf
xxxfb
xx
xfxfxxfb
xfb
where
xxxxbxxbbxf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 11
General nth order InterpolationGiven any n+1 points, The polynomial that interpolates all points is
)(,,...,)(,,)(, 1100 nn xfxxfxxfx
],...,,[
....
],[
)(
......)(
10
101
00
10102010
nn
nnn
xxxfb
xxfb
xfb
xxxxbxxxxbxxbbxf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 12
Divided Differences
0
1102110
02
1021210
01
0110
],...,,[],...,,[],...,,[
............
DDorder Second],[],[
],,[
DDorder first ][][
],[
DDorder zeroth )(][
xx
xxxfxxxfxxxf
xx
xxfxxfxxxf
xx
xfxfxxf
xfxf
k
kkk
kk
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 13
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
i
jjin xxxxxFxf
0
1
010 ],...,,[)(
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 14
Divided Difference Table
f(xi)
0 -5
1 -3
-1 -15
ixx F[ ] F[ , ] F[ , , ]
0 -5 2 -4
1 -3 6
-1 -15
Entries of the divided difference table are obtained from the data table using simple operations
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 15
Divided Difference Table
f(xi)
0 -5
1 -3
-1 -15
ixx F[ ] F[ , ] F[ , , ]
0 -5 2 -4
1 -3 6
-1 -15
The first two column of the
table are the data columns
Third column : first order differences
Fourth column: Second order differences
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 16
Divided Difference Table
0 -5
1 -3
-1 -15
iyixx F[ ] F[ , ] F[ , , ]
0 -5 2 -4
1 -3 6
-1 -15
201
)5(3
01
0110
][][],[
xx
xfxfxxf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 17
Divided Difference Table
0 -5
1 -3
-1 -15
iyixx F[ ] F[ , ] F[ , , ]
0 -5 2 -4
1 -3 6
-1 -15
611
)3(15
12
1221
][][],[
xx
xfxfxxf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 18
Divided Difference Table
0 -5
1 -3
-1 -15
iyixx F[ ] F[ , ] F[ , , ]
0 -5 2 -4
1 -3 6
-1 -15
4)0(1
)2(6
02
1021210
],[],[],,[
xx
xxfxxfxxxf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 19
Divided Difference Table
0 -5
1 -3
-1 -15
iyixx F[ ] F[ , ] F[ , , ]
0 -5 2 -4
1 -3 6
-1 -15
)1)(0(4)0(25)(2 xxxxf
f2(x)= F[x0]+F[x0,x1] (x-x0)+F[x0,x1,x2] (x-x0)(x-x1)
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 20
Two Examples
x y
1 0
2 3
3 8
Obtain the interpolating polynomials for the two examples
x y
2 3
1 0
3 8
What do you observe?
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 21
Two Examples
1
)2)(1(1)1(30)(2
2
x
xxxxP
x Y
1 0 3 1
2 3 5
3 8
x Y
2 3 3 1
1 0 4
3 8
1
)1)(2(1)2(33)(2
2
x
xxxxP
Ordering the points should not affect the interpolating polynomial
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 22
Properties of divided Difference
],,[],,[],,[ 012021210 xxxfxxxfxxxf
Ordering the points should not affect the divided difference
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 23
Example Find a polynomial to
interpolate the data.x f(x)
2 3
4 5
5 1
6 6
7 9
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 24
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
)6)(5)(4)(2(6750.0
)5)(4)(2(5417.1)4)(2(6667.1)2(134
xxxx
xxxxxxf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 25
Summary
polynomial inginterpolat affect thenot should points theOrdering
methodsOther -
2] 18. [Section ionInterpolat Lagrange-
] 18.1 [Section e Differenc DividedNewton-
it obtain toused be can methodst Differen*
unique. is l Polynomiainginterpolat The *
,...,2,1,0)()( that such
)( polynomialorder n an Findpoints, 1)(n ofset a Given
: ProblemionInterpolatth
niforxfxf
xf
ini
in
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 26
Inverse interpolation
Error in polynomial interpolation
Dr. Mujahed Al-Dhaifallah (Term 351)
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 27
Inverse Interpolation
ggg
g
yxfx
y
)(such that Find
and tableGiven the
:Problem 0x ….
….
1x nx
0y 1y nyix
iy
One approach:
Use polynomial interpolation to obtain fn(x) to interpolate the data then use Newton’s method to find a solution to
ggn yxf )(
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 28
Inverse InterpolationAlternative Approach
0x ….
….
1x nx
0y 1y ny
ix
iy
Inverse interpolation:
1. Exchange the roles
of x and y
2. Perform polynomial
Interpolation on the
new table.
3. Evaluate
)( gn yf
….
….
iy 0y 1y ny
ix 0x 1x nx
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 29
Inverse Interpolation
x
y
y
x
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 30
Inverse Interpolation
Question:
What is the limitation of inverse interpolation
• The original function has an inverse
• y1,y2,…,yn must be distinct.
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 31
Inverse Interpolation Example
5.2)(such that Find table.Given the
:Problem
gg xfx
x 1 2 3
y 3.2 2.0 1.6
3.2 1 -.8333 1.0416
2.0 2 -2.5
1.6 3
2187.1)5.0)(7.0(0416.1)7.0(8333.01)5.2(
)2)(2.3(0416.1)2.3(8333.01)(
2
2
f
yyyyf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 32
Errors in polynomial Interpolation Polynomial interpolations may lead to large
error (especially when high order polynomials are used)
BE CAREFUL
When an nth order interpolating polynomial is used, the error is related to the (n+1) th order derivative
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 33
10 th order Polynomial Interpolation
-5 -4 -3 -2 -1 0 1 2 3 4 5-0.5
0
0.5
1
1.5
2
true function
10 th order interpolating polynomial
21
1)(
xxf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 34
Error in polynomial interpolation
Dr. Mujahed Al-Dhaifallah (Term 351)
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 35
Errors in polynomial InterpolationTheorem
1
)1(1)(n
)1(4P(x)-f(x)
Then points). end the(including b][a, in
points spacedequally 1nat f esinterpolatthat
n degree of polynomialany beLet P(x)
b],[a, on continuous is (x)f
thatsuch functiona be f(x)Let
n
n
n
ab
n
M
Mf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 36
Example 1
910
1
)1(
1034.19
6875.1
)10(4
1P(x)-f(x)
)1(4P(x)-f(x)
9,1
01
[0,1.6875] interval in the points) spacedequally 01 (using
f(x) einterpolat topolynomialorder th 9 use want toWe
sin(x)f(x)
n
n
n
ab
n
M
nM
nforf
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 37
Interpolation Error
0 1
0 10
If (x) is the polynomial of degree n that interpolates
the function f(x) at the nodes , ,..., then for any x
not a node
( ) [ , ,..., , ]
n
n
n
n n ii
f
x x x
f(x) f x f x x x x x x
Not useful. Why?
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 38
Approximation of the Interpolation Error
0 1
1 1
0
If (x) is the polynomial of degree n that interpolates
the function f(x) at the nodes , ,...,
( , ( )) an additional point
The interpolation error is approximated by
( ) [ ,
n
n
n n
n
f
x x x
Let x f x be
f(x) f x f x x
1 10
,..., , ]n
n n ii
x x x x
Example Given the following table of data
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 39
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 40
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 41
Divided Difference Theorem
)(10
10)(
!
1],...,,[
b][a, somefor thenb][a, in pointsdistinct 1nany are
,...,, if and b][a, on continuous is
nn
nn
fn
xxxf
xxxfIf
10],...,,[
then
n order of polynomial a s )(
10 nixxxf
ixfIf
i
1 4 1 0 0
2 5 1 0
3 6 1
4 7
xxf 3)(
EE3561_Unit 5 (c)AL-DHAIFALLAH1436 42
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