LEC 5 Interpolation and Polynomial Approximation
LEC 5 Interpolation and Polynomial Approximation
Chapter -5-
Interpolation and Polynomial Approximation
5.1 Introduction
Engineers and scientists commonly assume that relationships between variables in a
physical problem can be approximately reproduced from data given by the problem. The
ultimate goal might be to determine the values at intermediate points, to approximate the
integral or derivative of the underlying function, or to simply give a smooth or continuous
representation of the variables in the problem.
Interpolation refers to determining a function that exactly represents a collection of data.
The most elementary type of interpolation consists of fitting a polynomial to a collection
of data points. Polynomials have derivatives and integrals that are themselves polynomials,
so they are a natural choice for approximating derivatives and integrals.
42
Engineering College Chemical Engineering Dept.
The interpolating polynomial is easily described now that the form of L n,k (x) is known.
This polynomial is called the nth Lagrange interpolating polynomial.
43
Engineering College Chemical Engineering Dept.
Note: This formula can also be used to split the given function into
partial fractions. For on dividing both sides of
(𝑥 − 𝑥0 ) (𝑥 − 𝑥1 ) … (𝑥 − 𝑥𝑛 )
𝑓(𝑥)
(𝑥 − 𝑥0 ) (𝑥 − 𝑥1 ) … (𝑥 − 𝑥𝑛 )
𝑓(𝑥0 ) 1
= ∗
(𝑥0 − 𝑥1 ) (𝑥0 − 𝑥2 ) … (𝑥0 − 𝑥𝑛 ) (𝑥 − 𝑥0 )
𝑓(𝑥1 ) 1
+ ∗ +⋯
(𝑥1 − 𝑥0 ) (𝑥1 − 𝑥2 ) … (𝑥1 − 𝑥𝑛 ) (𝑥 − 𝑥1 )
𝑓(𝑥𝑛 ) 1
+ ∗
(𝑥𝑛 − 𝑥0 ) (𝑥𝑛 − 𝑥1 ) … (𝑥𝑛 − 𝑥𝑛−1 ) (𝑥 − 𝑥𝑛 )
44
Engineering College Chemical Engineering Dept.
45
Engineering College Chemical Engineering Dept.
46
Engineering College Chemical Engineering Dept.
47
Engineering College Chemical Engineering Dept.
|𝑦1 (1.5) − 𝑓(1.5)| ≈ 1.53 ∗ 10−3 |𝑦3 (1.5) − 𝑓(1.5)| ≈ 2.5 ∗ 10−6
|𝑦2 (1.5) − 𝑓(1.5)| ≈ 5.42 ∗ 10−4 |𝑦̂3 (1.5) − 𝑓(1.5)| ≈ 1.5 ∗ 10−5
|𝑦̂2 (1.5) − 𝑓(1.5)| ≈ 6.44 ∗ 10−4 |𝑦4 (1.5) − 𝑓(1.5)| ≈ 7.7 ∗ 10−6
although y3(1.5) is the most accurate approximation, if we had no knowledge
of the actual value of f (1.5).
note: A practical difficulty with Lagrange interpolation is that since the error term is
difficult to apply, the degree of the polynomial needed for the desired accuracy is
generally not known until the computations are determined. The usual practice is to
compute the results given from various polynomials until appropriate agreement is
obtained, as was done in the previous example. However, the work done in calculating
the approximation by the second polynomial does not lessen the work needed to
calculate the third approximation; nor is the fourth approximation easier to obtain
once the third approximation is known, and so on. To derive these approximating
polynomials in a manner that uses the previous calculations to advantage, we need
some new notation.
48
Engineering College Chemical Engineering Dept.
49
Engineering College Chemical Engineering Dept.
𝑥𝑖 𝑓(𝑥𝑖 ) 1st divided differences 2nd divided differences 3rd divided differences
𝑥0 𝑓[𝑥0 ]
𝑓[𝑥1 ] − 𝑓[𝑥0 ]
𝑓[𝑥0 , 𝑥1 ] =
𝑥1 − 𝑥0
𝑥1 𝑓[𝑥1 ] 𝑓[𝑥1 , 𝑥2 ] − 𝑓[𝑥0 , 𝑥1 ]
𝑓[𝑥0 , 𝑥1 , 𝑥2 ] =
𝑥2 − 𝑥0
𝑓[𝑥2 ] − 𝑓[𝑥1 ] 𝑓[𝑥1 , 𝑥2 , 𝑥3 ] − 𝑓[𝑥0 , 𝑥1 , 𝑥2 ]
𝑓[𝑥1 , 𝑥2 ] = 𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 ] =
𝑥2 − 𝑥1 𝑥3 − 𝑥0
𝑥2 𝑓[𝑥2 ] 𝑓[𝑥2 , 𝑥3 ] − 𝑓[𝑥1 , 𝑥2 ]
𝑓[𝑥1 , 𝑥2 , 𝑥3 ] =
𝑥3 − 𝑥1
𝑓[𝑥3 ] − 𝑓[𝑥2 ] 𝑓[𝑥2 , 𝑥3 , 𝑥4 ] − 𝑓[𝑥1 , 𝑥2 , 𝑥3 ]
𝑓[𝑥2 , 𝑥3 ] = 𝑓[𝑥1 , 𝑥2 , 𝑥3 , 𝑥4 ] =
𝑥3 − 𝑥2 𝑥4 − 𝑥1
𝑥3 𝑓[𝑥3 ] 𝑓[𝑥3 , 𝑥4 ] − 𝑓[𝑥2 , 𝑥3 ]
𝑓[𝑥2 , 𝑥3 , 𝑥4 ] =
𝑥4 − 𝑥2
𝑓[𝑥4 ] − 𝑓[𝑥3 ] 𝑓[𝑥3 , 𝑥4 , 𝑥5 ] − 𝑓[𝑥2 , 𝑥3 , 𝑥4 ]
𝑓[𝑥3 , 𝑥4 ] = 𝑓[𝑥2 , 𝑥3 , 𝑥4 , 𝑥5 ] =
𝑥4 − 𝑥3 𝑥5 − 𝑥2
𝑥4 𝑓[𝑥4 ] 𝑓[𝑥4 , 𝑥5 ] − 𝑓[𝑥3 , 𝑥4 ]
𝑓[𝑥3 , 𝑥4 , 𝑥5 ] =
𝑥5 − 𝑥3
𝑓[𝑥5 ] − 𝑓[𝑥4 ]
𝑓[𝑥4 , 𝑥5 ] =
𝑥5 − 𝑥4
𝑥5 𝑓[𝑥5 ]
50
Engineering College Chemical Engineering Dept.
EXAMPLE 5: Table 3.2 lists values of a function at various points. Find the
approximations to f (1.5) by Divided-difference methods
𝑥 1 1.3 1.6 1.9 2.2
𝑦 0.7651977 0.6200860 0.4554022 0.2818186 0.1103623
Sol:
𝑓[𝑥𝑖−1 , 𝑥𝑖 ]
0.6200860 − 0.7651977
𝑓[1,1.3] = = −0.4837057
1.3 − 1
0.4554022 − 0.6200860
𝑓[1.3,1.6] = = −0.548946
1.6 − 1.3
0.2818186 − 0.4554022
𝑓[1.6,1.9] = = −0.578612
1.9 − 1.6
0.1103623 − 0.2818186
𝑓[1.9,2.2] = = −0.571521
2.2 − 1.9
𝑓[𝑥𝑖−2 , 𝑥𝑖−1 , 𝑥𝑖 ]
−0.548946 + 0.4837057
𝑓[𝑥0 , 𝑥1 , 𝑥2 ] = = −0.1087339
1.6 − 1
−0.578612 + 0.548946
𝑓[𝑥1 , 𝑥2 , 𝑥3 ] = = − 0.0494433
1.9 − 1.3
−0.571521 + 0.578612
𝑓[𝑥2 , 𝑥3 , 𝑥4 ] = = 0.0118183
2.2 − 1.9
𝑓[𝑥𝑖−3 , … , 𝑥𝑖 ]
− 0.0494433 + 0.1087339
𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 ] = = 0.0658784
1.9 − 1
0.0118183 + 0.0494433
𝑓[𝑥1 , 𝑥2 , 𝑥3 , 𝑥4 ] = = 0.0680685
2.2 − 1.3
0.0680685 − 0.0658784
𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 , 𝑥4 ] = = 0.0018251
2.2 − 1
51
Engineering College Chemical Engineering Dept.
ℎ = 𝑥𝑖+1 − 𝑥𝑖
Then we let a new variable s be defined by the equation
𝑥 = 𝑥0 + 𝑠ℎ
𝑥 − 𝑥𝑖 = (𝑠 − 𝑖)ℎ
Newton Forward Divided-Difference Formula
𝑛
𝑠
𝑃𝑛 (𝑥) = 𝑃𝑛 (𝑥0 + 𝑠ℎ) = 𝑓[𝑥0 ] + ∑ ( ) ∆𝑘 𝑓(𝑥0 )
𝑘
𝑘=1
𝑤ℎ𝑒𝑟𝑒 ∶
𝑠 𝑠 (𝑠 − 1)(𝑠 − 2) … (𝑠 − 𝑘 + 1)
( )=
𝑘 𝑘!
If the interpolating nodes are reordered from last to first as xn,xn-1,...,x0, This form is called the Newton
backward divided-difference formula. It is used to derive a formula known as the Newton backward-
difference formula.
−𝑠 𝑠 (𝑠 − 1)(𝑠 − 2) … (𝑠 − 𝑘 + 1)
( ) = (−1)𝑘
𝑘 𝑘!
52
Engineering College Chemical Engineering Dept.
EXAMPLE 5: Table 3.2 lists values of a function at various points. Find the
approximations to f (1.1) & f (2) by Divided-difference methods
𝑥 1 1.3 1.6 1.9 2.2
𝑦 0.7651977 0.6200860 0.4554022 0.2818186 0.1103623
Sol
i 𝑥𝑖 𝑓(𝑥𝑖 ) 𝑓[𝑥𝑖−1 , 𝑥𝑖 ] 𝑓[𝑥𝑖−2 , 𝑥𝑖−1 , 𝑥𝑖 ] 𝑓[𝑥𝑖−3 , … , 𝑥𝑖 ] 𝑓[𝑥𝑖−4 , … , 𝑥𝑖 ]
0 1 0.7651977
−0.4837057
1 1.3 0.6200860 −0.1087339
−0.548946 0.0658784
2 1.6 0.4554022 − 0.0494433 0.0018251
−0.578612 0.0680685
3 1.9 0.2818186 0.0118183
−0.571521
4 2.2 0.1103623
For f (1.1) Newton Forward
ℎ = 1.3 − 1 = 0.3
1.1 − 1 1
𝑠= =
0.3 3
1
𝑃4 (1.1) = 𝑃4 (1 + 0.3 ∗ )
3
= 0.7651977 + h ∗ s(−0.4837057) + 𝑠 ∗ (𝑠 − 1) ∗ ℎ2 (−0.1087339) + 𝑠 ∗ (𝑠 − 1)
∗ (𝑠 − 2) ∗ ℎ3 0.0658784 + 𝑠 ∗ (𝑠 − 1) ∗ (𝑠 − 2)(𝑠 − 3) ∗ ℎ4 0.0018251
1 1 2 1 2 5
= 0.7651977 + 0.3 ∗ (−0.4837057) + ∗ (− ) ∗ 0.32 (−0.1087339) + ∗ (− ) ∗ (− )
3 3 3 3 3 3
1 2 5 8
∗ 0.33 0.0658784 + ∗ (− ) ∗ (− )(− ) ∗ 0.34 0.0018251
3 3 3 3
𝑃4 (1.1) = 0.7196480
For f (2) Newton backward
ℎ = 1.3 − 1 = 0.3
2 − 2.2 2
𝑠= =−
0.3 3
2
𝑃4 (2) = 𝑃4 (2.2 − 0.3 ∗ )
3
= 0.1103623 + 𝑠 ∗ ℎ ∗ (−0.571521) + 𝑠 ∗ (𝑠 + 1) ∗ ℎ2 ∗ (0.0118183) + 𝑠 ∗ (𝑠 + 1)
∗ (𝑠 + 2) ∗ ℎ3 (0.0680685) + 𝑠 ∗ (𝑠 + 1) ∗ (𝑠 + 2) ∗ (𝑠 + 3) ∗ ℎ4 ∗ (0.0018251)
2 2 1 2 1 4
𝑃4 (2) = 0.1103623 − ∗ 0.3 ∗ (−0.571521) − ∗ ( ) ∗ 0.32 ∗ (0.0118183) − ∗ ( ) ∗ ( )
3 3 3 3 3 3
2 1 4 7
∗ 0.33 (0.0680685) − ( ) ∗ ( ) ∗ ( ) ∗ 0.34 ∗ (0.0018251)
3 3 3 3
𝑃4 (2) = 0.2238754
53
Engineering College Chemical Engineering Dept.
The Newton formulas are not appropriate for approximating f (x) when x lies near the center of the table,
since employing either the backward or forward method in such a way that the highest-order difference
is involved will not allow x0 to be close to x. A number of divided-difference formulas are available for
this situation, each of which has situations when it can be used to maximum advantage. These methods
are known as centered-difference formulas. There are a number of such methods, but we do not discuss
any of these techniques.
EXAMPLE 6: In the table below, the values of y are consecutive terms of a series of
which 23.6 is the 6th term. Find the first and tenth terms of the series:
x 3 4 5 6 7 8 9
y 4.8 8.4 14.5 23.6 36.2 52.8 73.9
Solution:
3 4.8
3.6
4 8.4 1.25
6.1 0.083333
5 14.5 1.5
9.1 0.083333
6 23.6 1.75
12.6 0.083333
7 36.2 2
16.6 0.083333
8 52.8 2.25
21.1
9 73.9
To find the first term, use Newton’s forward interpolation formula with
ℎ =4−3=1
1−3
𝑠= = −2
1
𝑃3 (1) = 𝑃3 (3 − 2)
= 4.8 + h ∗ s(3.6) + 𝑠 ∗ (𝑠 − 1) ∗ ℎ2 (1.25) + 𝑠 ∗ (𝑠 − 1) ∗ (𝑠 − 2) ∗ ℎ3 ∗ 0.083333
𝑃3 (1) = 3.1
To obtain the tenth term, u se Newton’s backward interpolation formula with
ℎ =4−3=1
10 − 9
𝑠= =1
1
𝑃3 (10) = 𝑃10 (9 + 1)
= 73.9 + 𝑠 ∗ ℎ ∗ (21.1) + 𝑠 ∗ (𝑠 + 1) ∗ ℎ2 ∗ (2.25) + 𝑠 ∗ (𝑠 + 1) ∗ (𝑠 + 2)
∗ ℎ3 (0.083333) = 100
54
92CHAPTER 3. INTERPOLATION AND POLYNOMIAL APPROXIMATION
1. For the given functions f (x), let x0 = 0, x1 = 0.6, and x2 = 0.9. Construct
the Lagrange interpolating polynomials of degree (i) at most 1 and (ii) at
most 2 to approximate f (0.45), and find the actual error.
√
(a) f (x) = cos x (b) f (x) = 1+x
2. Use the Lagrange polynomial error formula to find an error bound for the
approximations in Exercise 1.
7. The data for Exercise 3 were generated using the following functions. Use the
error formula to find a bound for the error and compare the bound to the
actual error for the cases n = 1 and n = 2.
(a) f (x) = x ln x
The actual value of cos 0.750 is 0.7317 (to four decimal places). Explain the
discrepancy between the actual error and the error bound.
11. Let P3 (x) be the interpolating polynomial for the data (0, 0), (0.5, y), (1, 3),
and (2, 2). Find y if the coefficient of x3 in P3 (x) is 6.
12. Neville’s method is used to approximate f (0.5), giving the following table.
x0 = 0 P0 = 0
x1 = 0.4 P1 = 2.8 P0,1 = 3.5
27
x2 = 0.7 P2 P1,2 P0,1,2 = 7
Determine P2 = f (0.7).
13. Suppose you need to construct eight-decimal-place tables for the common, or
base-10, logarithm function from x = 1 to x = 10 in such a way that linear
interpolation is accurate to within 10−6 . Determine a bound for the step size
for this table. What choice of step size would you make to ensure that x = 10
is included in the table?
15. Neville’s method is used to approximate f (0) using f (−2), f (−1), f (1), and
f (2). Suppose f (−1) was overstated by 2 and f (1) was understated by 3.
Determine the error in the original calculation of the value of the interpolating
polynomial to approximate f (0).
94CHAPTER 3. INTERPOLATION AND POLYNOMIAL APPROXIMATION
16. The following table lists the population of the United States from 1940 to
1990.
Find the Lagrange polynomial of degree 5 fitting this data, and use this
polynomial to estimate the population in the years 1930, 1965, and 2010.
The population in 1930 was approximately 123,203,000. How accurate do you
think your 1965 and 2010 figures are?
(a) Use the Maclaurin series to construct a table for erf(x) that is accurate
to within 10−4 for erf(xi ), where xi = 0.2i, for i = 0, 1, . . . , 5.
4. (a) Construct the fourth interpolating polynomial for the unequally spaced
points given in the following table:
(b) Suppose f (1.1) = −3.99583 is added to the table. Construct the fifth
interpolating polynomial.
5. (a) Use the following data and the Newton forward divided-difference for-
mula to approximate f (0.05).
7. Show that the polynomial interpolating the following data has degree 3.
x −2 −1 0 1 2 3
f (x) 1 4 11 16 13 −4
and
x −2 −1 0 1 2
f (x) −1 3 1 −1 3
(b) Why does part (a) not violate the uniqueness property of interpolating
polynomials?
10. The following data are given for a polynomial P (x) of unknown degree.
x 0 1 2
P (x) 2 −1 4
x0 = 0 f [x0 ]
f [x0 , x1 ]
50
x1 = 0.4 f [x1 ] f [x0 , x1 , x2 ] = 7
f [x1 , x2 ] = 10
x2 = 0.7 f [x2 ] = 6