Professional Documents
Culture Documents
1. 2. 3. 4.
5.
Lagrange Interpolation and error Newton form of Interpolation Newton's Forward and Backward form Piece-wise Polynomial Interpolation Cubic Spline Interpolation
Interpolation is the process of finding the most appropriate estimate for missing data. e.g.: if we know the records for the past 5 years except the third year , the interpolation technique helps to estimate the record for that year under the assumption that the changes in the records over 5 years have been uniform.
If we have values like (x0, y0), (x1, y1) (xn , yn) are available, such that yi depends on xi, then our purpose is to know the relationship of y with x. If the number of data points are less , then our aim is to find one polynomial which fits the data that is
y i = p ( xi ), for i = 0,1,
, n.
for i=0,1,2, n. Each polynomial is of degree n. These polynomials are called Lagrangian polynomials for the points x0,x1,,xn. .
4
p( x ) = f ( x ) ,
for i = 0,1,2,
, n.
The existence of interpolating polynomial is supported by WEIERSTRASs approximation theorem which asserts that any continuous function on a closed interval can be approximated by a polynomial.
p n ( x) = f i l i ( x).
) = f i , q n ( xiof ) =deg f i ,at i= 0,1 ,2, n ,n . Theypare thepolynomial the most therefore n ( xi h(x) where h(x) = pn(x)-qn(x), we see that h(x) 0 so that pn(x) = qn(x). Hence interpolating polynomial is unique.
7
Example 1: Find the interpolating polynomial in Lagrangian form for the data (-2, -15), (-1, -4), (1, 0), (3, 20). Solution: There are four points hence we will get a polynomial of degree three. Calculate l0, l1, l2, l3 and then p3(x). The polynomial is x3-x2+x-1. (Checking at few points it can be verified that the polynomial is the correct polynomial).
If f(x) is real valued function, which is continuous on [a, b] and differentiable on (a, b). If f(a)=f(b) then there exists a point c in (a,b) such that f (c)=0. Mean Value Theorem If f(x) is real valued function, which is continuous on [a, b] and differentiable on (a, b). Then there exists a point c in (a,b) such that
f ( c ) = f (b ) f ( a ) . b a
9
10
11
Suppose x0,x1,,xn are n+1 distinct points in [a,b] and f is (n+1) times continuously differentiable, then for each x in [a,b] there exist a no. c in (a,b) with
f ( n +1) (c) ( x x0 ) E ( x) = (n + 1)!
( x x n ).
12
Error in Lagrange Interpolation is given as E(x)=f(x)-pn(x). At tabular points x0,x1,,xn. error is always zero. Suppose we want the error E() at the point in (x0, xn) . For this we consider the function F(x) as
F ( xA ) = such f ( x) that p n ( x) A( x x0Also )( x xwe ( x x n ). 1) Choose F( )=0. have F(xi)=0. Now F(x) is zero at (n+2) points x0,x1,,xn, . Assuming F(x) is (n+1) times continuously differentiable. We have by repeated application of Rolles theorem F(n+1)(x) vanish for some c in (x0, xn).
13
F ( n +1) (c) = f ( n +1) (c) 0 A(n + 1)!= 0. Therefore since (n+1)th derivative of pn is zero we have
f ( n +1) ( c ) . A = ( n + 1 )! Hence E() =f()-pn()=A(-x0)(-xn)=
f ( n +1) ( c ) ( x 0 )( x 1 ) ( n + 1)! ( x n ).
14
n ( x) = ( x x0 )( x x1 )
( x x n ) = ( x xi ),
i =0
Also we can see that and similarly for other li(x). Therefore we have
n ( x0 ) = ( x0 x1 )( x0 x 2 ) ( x0 x n ) = l 0 ( x),
n ( x) li ( x) = , ( x xi ) n ( x)
i = 0,1,
n.
16
Q1. Find the Lagrangian form of interpolating polynomial for the data (-1, 4), (2,7), (4, 5) hence interpolate f(1). Find the Lagrangian interpolating polynomial after adding the data point (6, -2) to the above data. See if the earlier calculations helps.
17
In Lagrangian polynomial formulation, if a tabular point is added to the data then all Lagrangian polynomials are to be constructed fresh. Therefore, another form of interpolating polynomial is needed to meet this requirement. Since, already proved that interpolating polynomial is unique, so only form will be different.
18
Suppose that Pn(x) is the n-th Lagrange polynomial that agrees with the function f at the distinct numbers x0, x1, x2,, xn. The divided differences of f w.r.t. x0, x1, x2,, xn are used to express Pn(x) in the form
Pn ( x) = a0 + a1 ( x x0 ) + a2 ( x x0 )( x x1 ) + ... + an ( x x0 ) ( x xn 1 )
for appropriate constants a0, a1, a2,,an.
19
Zero Divided Difference of the function f w.r.t. xi denoted by f[xi], is similar to the value of f at xi i.e.
f [ xi ] = f ( xi )
First Divided Difference of the function f w.r.t. xi and xi+1 denoted by f[xi, xi+1] and is defined as
f [ xi , xi +1 ] = f [ xi +1 ] f [ xi ] xi +1 xi
20
f [ xi , xi +1 , xi + 2 ] =
=
`
f [ xi +1 , xi + 2 ] f [ xi , xi +1 ] xi + 2 xi
(xi xi +1 )(xi xi + 2 )
fi
This shows that order of xi, xi+1 , xi+2 does not change the value of the divided differences. Similarly, nth Divided Difference is given by
f [ xi , xi +1 , xi + 2 ,..., xi + n ] =
f [ xi +1 , xi + 2 ,..., xi + n ] f [ xi , xi +1 ,..., xi + n 1 ] xi + n xi
21
In particular
f [ x0 , x1, x2 ,..., xn ] =
=
i =0
f ( xi )
(x x )
j =0 j i i j
22
Pn ( x) = a0 + a1 ( x x0 ) + a2 ( x x0 )( x x1 ) + ... + an ( x x0 )
`
( x xn 1 )
Therefore, we get
a0 = f [ x0 ], a1 = f [ x0 , x1 ], ....... an = f [ x0 , x1 ,..., xn ]
23
24
25
26
( x xn 1 )
This equation is known as Newtons divided difference form of polynomial. Note that the value of f [ x , x ,..., x ] is independent 0 1 n of the order of the numbers x0, x1, x2,, xn.
27
x1 x2 x3
f ( x1 ) f [ x 2 , x1 ] f ( x2 ) f [ x3 , x 2 ] f ( x3 )
f [ x 2 , x1 , x 0 ]
f [ x3 , x 2 , x1 ]
a3
f [ x3 , x 2 , x1 , x 0 ]
28
Let Pn-1(x) interpolates f(x) at x0, x1, x2,, xn-1 i.e. n distinct points. Now suppose (xn, fn) is added to the data. Then, find the interpolating polynomial Pn(x) which interpolates f(x) at x0, x1, x2,, xn, (n+1) distinct points. The polynomial is
E ( x) = ( x x0 )( x x1 )
Proof:
Let Pn(x) interpolates f(x) at x0, x1, x2,, xn, (n+1) distinct points. For x in [x0, xn] prove that
( x xn ) f [ x0 , x1 , , xn , x]
30
If abscissa repeats the we can show the following results: f ( x1 ) f ( x0 ) We have first divided difference f [ x0 , x1 ] = x x
1 0
lim f [ x , x ] = lim
x1 x0 0 1 x1 x0
` `
Similarly In general
f ( x0 ) 2! f ( n ) ( x0 ) f [ x0 , x0 ,..., x0 ] = n! f [ x0 , x0 , x0 ] =
( n +1) times
f ( x1 ) f ( x0 ) = f ( x0 ) f [ x0 , x0 ] = f ( x0 ) x1 x0
31
f [ x0 , x0 , x0 ] =
f ( x0 ) 2!
Proof: To get f[x0, x0, x0], we consider f[x0, x0+h, x0+k], and take the limit h0, and k0 i.e.
f [ x 0 , x 0 , x 0 ] = lim f [ x 0 , x 0 + h , x 0 + k ]
h 0 k0
= lim = lim
h 0 k0
f [ x 0 + h, x 0 + k ] f [ x 0 , x 0 + h ] k
Let g(x)= f[x0, x1, , xn, x], then g(x)=f[x0, x1, , xn, x, x]. Also g(k)(x)=f[x0, x1, , xn, x, x, , x] (here x appears (k+1) times. Proof: Now g(x+h) = f[x0, x1, , xn, x+h]. Then we get
g ( x + h) g ( x ) = lim f [ x0 , x1 , xn , x, x + h] h 0 h 0 x+hx g ( x)(Some = f [ x0 ,steps , x]. x1 , ,are xn , x missing) lim
Suppose f C n [a, b] and x0, x1, x2,, xn are (n+1) distinct numbers in [a,b]. Then there exists a number c in (a,b) such that f (c )
f [ x 0 , x1 , , x n ] =
(n)
n!
Proof: Let pn(x) interpolates f(x) at x0, x1, , xn , then E(x)=f(x)-pn(x) is k-times differentiable (as f(x) and p(x) are so). And E(xi)=f(xi)-pn(xi), i=0,1,2, , n Using Rolles Theorem repeatedly n-times, we see that En(x) vanishes at some point c in (a,b). Therefore En(c)= fn(c)-pn(c) =0.
34
Also Pn(x)= pn-1(x)+(x-x0)(x-xn-1)f[x0, x1, ,xn]. Differentiating n-times we get Pn(n)(x)= n! f[x0, x1, ,xn]. Thus Pn(n)(c)= n! f[x0, x1, ,xn]. Hence
f [ x 0 , x1 , , x n ] =
(n)
(c ) n!
35
Newton divided difference formula when x0, x1, x2,, xn are equispaced. Introduce the notation h = xi+1 -xi for each i=0,1, 2,, n. The divisor, for the first order differences will remain the same h and for 2nd order it becomes 2h and so on. Instead of dividing so many times, computation of differences and polynomial can be modified suitably to avoid the repeated work.
36
` ` `
The divided differences of f w.r.t. x0, x1, x2,, xn are used to express Pn(x) in the form
37
n n n f i = f n + i f n + i 1 + f n + i 2 + 1 2
+ ( 1) n f i
38
We have We obtain
Pn ( x) = a0 + a1 ( x x0 ) + a2 ( x x0 )( x x1 ) + ...
a0 = f 0 a1 =
+ an ( x x0 )
( x xn 1 )
f1 f 0 f 0 = x1 x0 h
2 f0 a2 = 2!h 2 n f0 an = n !h n
39
Setting x = x0 + sh, then the difference x-xi can be written as x - xi = (s-i)h and substituting the values of a0,a1,,an, we get Newton Forward-Difference Formula
Or we can write
s Pn ( x) = f 0 + k f 0 k =1 k
n
Pn ( x ) = f 0 + s f 0 +
s ( s 1) 2 f0 + 2! s ( s 1) ( s 2 ) ( s n + 1) n + f0 n!
40
x x0 x1 x2
f f0 f1 f2
2 f
f 0 f1
2 f0 f1
2
n 1 f 0 n 1 f1
n f0
2 f2
xn 1 f n 1 xn f n
f n
41
X F(x)
`
4 1
6 3
8 8
10 16
Interpolate F(5).
42
f [ x0 , x1 , , xn ] =
n !h n
Proof: By induction. 0 order f[x0]=f0=0f0. First and second order are as follows,
f1 f 0 f 0 , = x1 x0 h 2 f0 f [ x0 , x1 , x2 ] = 2!h 2
n f0 f [ x0 , x1 , , xn ] = n !h n
43
Error term E(x) = f(x)-pn(x) = Since x= x0+sh, x-x1 = x0+sh-(x0+h)=(s-1)h, . and so on. Substituting these values in the error term we get
( x x0 )
( x xn ) f [ x0 , x1 , , xn , x].
n +1 f h n 1 + s
n +1
(c )
44
` ` `
Backward difference operator denoted by . Suppose we are given a table of values of the function at the points x0, x1, , xn. Which are equi-spaced , that is x1=x0+h, x2=x0+2h, , xn=x0+nh. The corresponding points are y0, y1, , yn. Then we define the backward differences as follows. First order backward difference. y1 = y1 y0 Second order backward difference are 2 y2 = y2 y1 Third order backward differences is
3 yi = 2 yi 2 yi 1
45
yn = n y
Given the sequence { yn }n =0 define the backward difference yn by yn = yn yn 1 for n 1 Higher powers are defined respectively by
k yn = ( k 1 yn ) for k 2 The relation between the forward difference operator and the backward difference operator is given by
(i ) k y n = k y n k (ii ) n y i = n y i n ( iii ) n y i + n = n y i .
46
x x0 x1 x2 x3 x4 x5
f f0 f1 f2 f3 f4 f5
f1 f 2 f 3 f 4 f 5
2 f2 2 f3 2 f4 2 f5
3 f 3 3 f 4 3 f 5
4 f4 4 f5
5 f5
47
If the interpolating nodes are recorded as x0, x1, , xn-1, xn. These nodes are equally spaced with x = xn+ ph, xi=xn+(n-i)h and x - xi = (n+ p - i) h. Consider the interpolating polynomial of the form
Pn ( x) = a0 + a1 ( x xn ) + a2 ( x xn )( x xn 1 ) + ... + an ( x xn )( x xn 1 ) ( x x1 )
Imposing the condition that f and Pn(x) agree at the tabulated points.
48
( 1)
k =0
p k fn k
49
k f ( xn ) f [ xn , xn1,..., xnk ] = , k k !h
Proof is left to you. (proof it by the method of induction)
k 0
50
Error
E ( x) = f ( x) Pn ( x) p ( p + 1) ( p + n) n +1 n +1 h f (c), c ( x0 , xn ) (n + 1)! Newtons forward difference formula is used for the interpolation near the beginning of a set of tabular values and Newtons Backward Difference Formula is useful for interpolation near the end of the tabular values. =
51
Large number of data points results the higher degree interpolating polynomial. Oscillating nature of high degree polynomials induce more error in interpolation. Example: let f(x) = cos10x over the interval [-2, 2]. Fit the polynomials of degrees 2, 4, 6, and 8.
52
53
54
55
To overcome this inaccuracy: ` Total interval is divided into further small sub intervals and on each interval a lower degree interpolating polynomial is constructed. ` Approximation of functions by this type is called piecewise polynomial interpolation. ` So, this is another way to fit a polynomial to a set of data.
56
Simplest piecewise interpolation is piecewise linear interpolation, which consists of joining a set of data points by a series of straight lines. Tabular points x0, x1, x2,, xn may not be necessarily equispaced.
{( x0 , f 0 ), ( x1 , f1 ), ( x2 , f 2 ), , ( xn , f n )}
57
58
On interval [xi, xi-1], let us define the linear polynomial P i = 1, 2,..., n 1i = f i 1 + ( x xi 1 ) f [ xi 1 , xi ], There are n-such polynomials of degree one for a pair of tabular points. This is known as piecewise linear interpolation.
59
x y
0 2.5
1 0.5
2 0.5
2.5 1.5
3 1.5
3.5 1.125
4 0
60
61
Disadvantage of linear function approximation ` No differentiability at the end points of the subintervals i.e. the interpolating function is not smooth. From the physical conditions it is required that the approximation function must be continuously differentiable.
62
To obtain a somewhat smoother graph, consider using piecewise quadratic interpolation. Divided the interval [a, b] into 2n (even number) equal (not necessary) intervals i.e.
ba = h s.t. a = x0 , x1 , x2 ,..., x2 n 2 , x2 n 1 , x2 n = b 2n
Begin by constructing the quadratic polynomial that interpolates {( x2i 2 , f 2i 2 ), ( x2i 1 , f 2i 1 ), ( x2i , f 2i )}
63
Then, the quadratic interpolating polynomial is P2i = f 2i 2 + ( x x2i 2 ) f [ x2i 2 , x2i 1 ] + ( x x2i 2 )( x x2i 2 ) f [ x2i 2 , x2i 1 , x2i ] for the interval [x2i-2, x2i], i = 1,2,, n. (These polynomials are n in numbers).
64
x y
0 2.5
1 0.5
2 0.5
2.5 1.5
3 1.5
3.5 1.125
4 0
65
66
With piecewise quadratic interpolants, however, there are corners on the graph of the interpolating function. In the previous example, they are at x2 and at x4. Or the interpolating polynomial is not smooth (or differentiable). In the previous case the interpolating polynomial is not differentiable x2 and x4. Our aim is to construct the piecewise cubic interpolating polynomial which fulfills the differentiability requirement.
67
The most common piecewise polynomial approximation uses cubic polynomial between each successive pair of nodes called Cubic spline interpolation. These polynomials have the same slope and curvature at the nodes where they join. Do not require the intervals to be of same width.
68
Given a function f defined on [a, b] and a set of nodes a=x0<x1<x2<<xn=b. A cubic spline interpolant S for f is a function that satisfies
andS n1 = f ( xn ) (2) S j +1 ( x j +1 ) = S j ( x j +1 ), j = 0,1, 2,..., n 2 (3) S j +1 ( x j +1 ) = S j ( x j +1 ), j = 0,1, 2,..., n 2 (4) S ( x j +1 ) = S ( x j +1 ), j = 0,1, 2,..., n 2 j +1 j
69
70
Cubic splines that fit the function f(x)=cos10(x) on the interval [-2, 2].
71
x y
0 2.5
1 0.5
2 0.5
2.5 1.5
3 1.5
3.5 1.125
4 0
72
73
74
Then the upper bound on the error in piecewise cubic interpolation is given by
Mh 4 | E | , where M = max | f ( 4) ( x) |, I = [ a, b] xI 4!
and h = ba 3n .
75
Find the minimum number of equispaced tabular points required for piecewise cubic interpolation of the function f ( x) = e2 x + 22 x 4 3 on the interval [0, 3] to get 4 decimal place accuracy. Solution: Use the formula with one m factor, which is the relative error in function evaluation.
ba 3n
.
76
77