Professional Documents
Culture Documents
5-Interpolation and Polynomial Approximation
5-Interpolation and Polynomial Approximation
5-Interpolation and Polynomial Approximation
APPROXIMATION
Interpolation Methods
• Interpolation method are the basis for other procedures that we will deal with:
– Numerical differentiation
– Numerical integration
– Solution of ODE (ordinary differential equations) and PDE (partial differential
equations)
• These methods demonstrate some important theory about polynomials and the
accuracy of numerical methods.
• The interpolation of polynomials serve as an excellent introduction to some techniques
for drawing smooth curves.
Interpolation uses the data to approximate a function, which will fit all of the data points. All
of the data is used to approximate the values of the function inside the bounds of the data.
Interpolation is a process of finding a formula (often a polynomial) whose graph will pass
through a given set of points (x, y).
2
Input: A set S of data f( x0 , y0 )( x1 , y1 )( xn , yn )g( xi , yi ) 2
Output: A function () which interpolates the given set of data,
i.e., ( xi ) = yi , for 0 i n .
1
LAGRANGE INTERPOLATION
( x1 , y1 )
( x0 , y0 )
y1 y0
m
x1 x0
x x0
y y0 y1 y0 .......................(1)
x1 x0
P ( x0 ) y0
………………….(2)
P ( x1 ) y1
( x x1 ) ( x x0 )
y P1 ( x ) y0 y1 ………..(3)
( x0 x1 ) ( x1 x0 )
Each term on the right hand side of (3) involves linear factor . Hence the sum is a polynomial of
degree 1 . The quotients in (3) are denoted by
( x x1 ) ( x x0 )
L1,0 ( x ) , L1,1 ( x ) ……(4)
( x0 x1 ) ( x1 x0 )
2
which are called the Lagrange coefficients polynomials based on the nodes x0 and x1 . Using this
notation , (3) can be written in summation form
1
P1 ( x ) yk L1,k y0 L1,0 y1 L1,1 ……………..(5)
k 0
The generalization of (5) is the construction of a polynomial PN ( x ) of degree at most N that passes
through the N 1 points ( x0 , y0 ),( x1 , y1 ),...,( x N , y N ) and has the form
N
PN ( x ) yk LN ,k ( x) ……………..(6)
k 0
where
x xj
N
j 0
jk
LN ,k ( x ) …………..(7)
xk x j
N
j 0
jk
Using (6) and (7) , find 1st , 2nd, and 3rd Lagrange Interpolation polynomial.
1
P1 ( x ) yk L1,k y0 L1,0 y1 L1,1
k 0
where
( x x1 ) ( x x0 )
L1,0 ( x ) , L1,1 ( x )
( x0 x1 ) ( x1 x0 )
3
2nd order Lagrange interpolation polynomial
2
P2 ( x ) yk L2,k y0 L2,0 y1 L2,1 y2 L2,2
k 0
where
( x x1 )( x x2 ) ( x x0 )( x x2 ) ( x x0 )( x x1 )
L2,0 ( x ) , L2,1 ( x ) , L2,2 ( x )
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
3
P3 ( x ) yk L3,k y0 L3,0 y1 L3,1 y2 L3,2 y3 L3,3
k 0
where
( x x1 )( x x2 )( x x3 ) ( x x0 )( x x2 )( x x3 )
L3,0 ( x ) , L3,1 ( x )
( x0 x1 )( x0 x2 )( x0 x3 ) ( x1 x0 )( x1 x2 )( x1 x3 )
( x x0 )( x x1 )( x x3 ) ( x x0 )( x x1 )( x x2 )
L3,2 ( x ) , L3,3 ( x )
( x2 x0 )( x2 x1 )( x2 x3 ) ( x3 x0 )( x3 x1 )( x3 x2 )
f ( x) PN ( x) E N ( x) ………………..(1)
N
f ( x ) PN ( x ) yk LN ,k ( x) …………(2)
k 0
4
The error term E N ( x ) has the form
E N ( x)
x x0 x x1 ... x x N f ( N 1) (c ) ....................( 3)
N 1 !
x x0 x x1 ... x x N
E N ( x) M ..................( 4)
N 1 !
M max f ( N 1) (c )
x x x
0 N
The error terms corresponding the cases N=1,2,3 have the following useful bounds on their
magnitude.
h2 M 2
E1 ( x ) valid for x0 , x1
8
3
h M3
E2 ( x ) valid for x0 , x2
9 3
h4 M 4
E3 ( x ) valid for x0 , x3
24
5
Example : The function y sin x is tabulated as
x 0 4 2
y 0 0.707 1
Using lagrange interpolation polynomial, find its value at x estimate the error.
6
Solution
Given x0 0, x1 , x2 , y0 0, y1 0.707 , y2 1
4 2
Find P2 ( x ), P2 ( ) and E2 ( x )
6
2
P2 ( x ) yk L2,k y0 L2,0 y1 L2,1 y2 L2,2 0 y1 L2,1 y2 L2,2 (where, y0 0 then y0 L2,0 0)
k 0
x 0 x
( x x0 )( x x2 ) 2 16 2 x
L2,1 ( x ) x
( x1 x0 )( x1 x2 ) 2 2
0
4 4 2
( x x0 )( x x1 )
x 0 x 8 x
4
L2,2 ( x ) 2 x2
( x2 x0 )( x2 x1 ) 4
0
2 2 4
16 x 8 2 x
P2 ( x ) 0.707 2 x 2 1 2 x 1.146 x 1.8 x 0.81 x 0.636 x
2 2
2 4
P2 ( x ) 0.336 x 2 1.164 x
2
P2 0.336 1.164 0.517 P2 0.517
6 6 6 6
h3 M 3
E2 ( x ) where h
9 3 4
Find M 3 , f ( 3) ( x ) M 3 in 0,
2
f ( x ) cos x , f ( x ) sin x , f ( x ) cos x
f ( x ) cos x maximum value of f ( x ) in 0, M 3 cos 0 1 then
2
3
1
h3 M 3 4
E2 ( x ) 0.03
9 3 9 3
6
Exercise 1:
Find Lagrange interpolation polynomial which agrees with the following data and obtain a bound
x
for the errors in estimating the function f ( x ) sin .
2
x 0 0.5 1
y 0 0.707 1
Exercise 2:
Consider y cos x over 0, 1.2 . Determine the error bounds for the Lagrange polynomials
P1 ( x), P2 ( x) and P3 ( x) .
Exercise 3:
a) Find a second degree polynomial approximating the function f ( x) x ln x , and
passing from the points 1, f (1) , 2, f (2) and (4, f (4)) .
b) Approximate f (2.5) using the polynomial in part (a)
c) use the error formula
f ( N 1) (c)
E N ( x) x x0 x x1 x x2 ... x x N
N 1 !
To estimate the error at x=2.5
x 2 3 4
y 5 4 2
7
NEWTON POLYNOMIALS
If the Lagrange interpolation are used , there is no constructive relationship between
PN 1 ( x) and PN ( x) . Each polynomial has to be constructed individually and the work required
to compute the higher degree polynomials involves many computations.
We take the new approach and construct Newton’s polynomials that have the recursive pattern.
P1 ( x ) a0 a1 ( x x0 ) (1)
P2 ( x ) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) P1 ( x ) a2 ( x x0 )( x x1 ) ( 2)
P3 ( x ) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) a3 ( x x0 )( x x1 )( x x2 )
P2 ( x ) a3 ( x x0 )( x x1 )( x x3 ) ( 3)
.
.
.
PN ( x ) PN 1 ( x ) a N ( x x0 )( x x1 )( x x3 )...( x x N 1 ) (4)
The polynomial (4) is said to be Newton Polynomial with N centers x0 , x1 ,..., x N 1 . It involves
sums of products of linear factors up to
a N ( x x0 )( x x1 )( x x3 )...( x x N 1 )
The Newton interpolation uses a divided difference method. The technique allows one to
add additional points easily
P x a0 a1 x x0 a2 x x0 x x1
P2 ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 )
8
A simple procedure can be used to determine the values of the coefficients
x x0 a0 f ( x 0 )
f ( x1 ) f ( x0 )
x x1 a1
x1 x0
f ( x2 ) f ( x1 ) f ( x1 ) f ( x0 )
x2 x1 x1 x0
x x2 a2
x 2 x0
PN ( x ) f ( x0 ) ( x x0 ) f [ x1 , x0 ] ( x x0 )( x x1 ) f [ x2 , x1 , x0 ]
( x x0 )( x x1 ) ( x x N 1 ) f [ x N , x N 1 , , x0 ]
a0 f ( x 0 )
a1 f [ x1 , x0 ]
a2 f [ x2 , x1 , x0 ]
a N f [ x N , x N 1 , , x 1 , x0 ]
f ( xi ) f ( x j )
f [ xi , x j ]
xi x j
f [ xi , x j ] f [ x j , xk ]
f [ xi , x j , xk ]
xi xk
, x1 ] f [ x N 1 , x N 2 , , x0 ]
f [ x N , x N 1 ,
f [ x N , x N 1 , , x1 , x0 ]
x N x0
and use to construct the divided differences in the following table
xk f xk f , f ,, f ,,, f ,,,,
x0 f x0
x1 f x1 f x1 , x0
x2 f x2 f x2 , x1 f x2 , x1 , x0
x3 f x3 f x3 , x2 f x3 , x2 , x1 f x3 , x2 , x1 , x0
x4 f x4 f x4 , x3 f x4 , x3 , x2 f x4 , x3 , x2 , x1 f x4 , x3 , x2 , x1 , x0
9
Theorem : Newton Polynomial
Suppose that x0 , x1 ,..., x N 1 are N+1 distinct numbers in a, b . There exist a unique
polynomial PN ( x ) of degree at most N with the property that
f x j PN x j for j 0, 1,..., N
PN ( x) PN 1 ( x) a N ( x x0 )( x x1 )( x x3 )...( x x N 1 )
f ( x) PN ( x) E N ( x)
then
E N ( x)
x x0 x x1 ... x x N f ( N 1) (c)
N 1 !
10
EXAMPLE 1: Let f ( x ) x3 4 x
xk f xk f , f , , f , , , f , , , ,
x0 1 f (1) 3
x1 2 f (2) 0 0 (3)
3
2 1
x2 3 f (3) 15 15 0 15 3
15 6
3 2 3 1
x3 4 f (4) 48 48 15 33 15 96
33 9 1
43 42 4 1
Where a0 3 , a1 3, a2 6, a3 1, a4 0
P3 ( x) a0 a1 x x0 a2 x x0 x x1 a3 x x0 x x1 x x2
P3 ( x) 3 3 x 1 6 x 1 x 2 1 x 1 x 2 x 3
then add like terms
P3 ( x) x3 4 x
11
EXAMPLE 2: For the function y f ( x) , given the following table, use the divided difference
to determine highest possible order and use the Newton’s polynomial to determine the valu of
11
x if f ( x ) .
3
xk f xk f , f , ,
x0 0 f (0) 1
= a0
x1 1 f (1) 2 2 1
1 = a1
1 0
x2 3 f (3) 6 62 2 1 1
2 = a2
3 1 30 3
P2 ( x) a0 a1 x x0 a2 x x0 x x1
1
P2 ( x) 1 1 x 0 x 0 x 1
3
then add like terms
1 2 11
P2 ( x) x 2 x 1 find x where f ( x )
3 3 3
1 2 2 11 1 2 8
x x 1 x2 x 0 x2 2x 8 0
3 3 3 3 3 3
x 4 ( x 2) 0 then x 4 and x 2
x 2 0,3 , x 4 0,3
12
Exercise 1: Use the Newton divided-difference formula to compute the cubic interpolating
x
polynomial P3 ( x ) for the function f ( x ) sin( ) using interpolation points
2
x0 0 , x1 1 , x2 2 and x3 3 . What is an upper bound for the error at x=0.5 ?
X 0 1 2 3
f(x) 1 2 4 8
Exercise 3:For the function y f ( x) given the following table, use the divided differences to
determine highest possible order and use Newton’s polynomial to determine the value of x if
f ( x ) 0
x 0 1 2
y 0 -3 -4
13