Dr. Mohammad H.
Alaroud MATH 322
Chapter 3
Interpolating and Polynomial Approximation
Sec. 3.1. Interpolating and The Lagrange Polynomials
Given data points:
(𝑥0 , 𝑦0 ), (𝑥1 , 𝑦1 ), … , (𝑥𝑛 , 𝑦𝑛 )
or tabulated data
𝑥 𝑥0 𝑥1 ⋯ 𝑥𝑛
𝑦 = 𝑓(𝑥) 𝑦0 𝑦1 ⋯ 𝑦𝑛
where 𝑥0 , 𝑥1 , … , 𝑥𝑛 are (𝑛 + 1) distinct points (or nodes).
Interpolation: Find a function 𝑔(𝑥) that agrees with 𝑓(𝑥) at the given data points
𝑔(𝑥𝑖 ) = 𝑓(𝑥𝑖 ) = 𝑦𝑖 , 𝑖 = 0,1, … , 𝑛.
The function 𝑔 belongs to specific family:
1. Polynomial
2. Trigonometric
3. Rational
We focus on Polynomial Interpolation:
------------------------------------------------------------------------------------------------
Find a polynomial
𝑃𝑛 (𝑥) = 𝑎𝑛 𝑥 𝑛 + 𝑎𝑛−1 𝑥 𝑛−1 + ⋯ + 𝑎1 𝑥 + 𝑎0
of degree at most 𝑛 such that
𝑃𝑛 (𝑥𝑖 ) = 𝑓(𝑥𝑖 ) = 𝑦𝑖 , 𝑖 = 0,1, … , 𝑛.
------------------------------------------------------------------------------------------------
1
Dr. Mohammad H. Alaroud MATH 322
Three questions to answer:
Question 1. Is 𝑃𝑛 (𝑥) unique?
Question 2. How to construct 𝑃𝑛 (𝑥)?
Question 3. Error bound on |𝑃𝑛 (𝑥) − 𝑓(𝑥)|?
➢ Answer to Question 1.
Suppose 𝑄𝑛 (𝑥) is another interpolating polynomial.
Let
𝑅(𝑥) = 𝑃𝑛 (𝑥) − 𝑄𝑛 (𝑥).
Then 𝑅(𝑥) is a polynomial of degree at most 𝑛. But 𝑅(𝑥) has (𝑛 + 1) zeros:
𝑅(𝑥𝑖 ) = 𝑃𝑛 (𝑥𝑖 ) − 𝑅(𝑥𝑖 ) = 𝑦𝑖 − 𝑦𝑖 = 0, 𝑖 = 0, 1, 2, … , 𝑛.
Therefore, it must be that 𝑅(𝑥) ≡ 0 and so 𝑃𝑛 (𝑥) = 𝑄𝑛 (𝑥).
➢ Answer Question 2.
Lagrange method: Define basis polynomials by
(𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) ⋯ (𝑥 − 𝑥𝑘−1 )(𝑥 − 𝑥𝑘+1 ) ⋯ (𝑥 − 𝑥𝑛 )
𝐿𝑘 (𝑥) = , 𝑘 = 0,1, … , 𝑛.
(𝑥𝑘 − 𝑥0 )(𝑥𝑘 − 𝑥1 ) ⋯ (𝑥𝑘 − 𝑥𝑘−1 )(𝑥𝑘 − 𝑥𝑘+1 ) ⋯ (𝑥𝑘 − 𝑥𝑛 )
• 𝐿𝑘 (𝑥) is a polynomial of degree 𝑛
• Normalization property:
1, 𝑘 = 𝑖,
𝐿𝑘 (𝑥𝑖 ) = {
0, 𝑘 ≠ 𝑖.
Define the function
𝑃𝑛 (𝑥) = 𝑦0 𝐿0 (𝑥) + 𝑦1 𝐿1 (𝑥) + ⋯ + 𝑦𝑛 𝐿𝑛 (𝑥).
Then 𝑃𝑛 (𝑥) is a polynomial of degree at most 𝑛 with
𝑃𝑛 (𝑥𝑖 ) = 𝑦0 𝐿0 (𝑥𝑖 ) + 𝑦1 𝐿1 (𝑥𝑖 ) + ⋯ + 𝑦𝑛 𝐿𝑛 (𝑥𝑖 ) = 𝑦𝑖 , 𝑖 = 0, 1, … , 𝑛.
Which means 𝑃𝑛 (𝑥) is an interpolating polynomial called the 𝒏th-Lagrange interpolating
polynomial.
2
Dr. Mohammad H. Alaroud MATH 322
Example 1. Find the linear Lagrange interpolating polynomial that passes through the
points (2, 4) and (5, 1).
Solution. We have
𝑥 − 𝑥1 𝑥−5 1
𝐿0 (𝑥) = = = − (𝑥 − 5)
𝑥0 − 𝑥1 2 − 5 3
𝑥 − 𝑥0 𝑥−2 1
𝐿1 (𝑥) = = = (𝑥 − 2)
𝑥1 − 𝑥0 5 − 2 3
Thus
1 1
𝑃1 (𝑥) = 𝑦0 𝐿0 (𝑥) + 𝑦1 𝐿1 (𝑥) = (4) [− (𝑥 − 5)] + (1) [ (𝑥 − 2)] = 6 − 𝑥.
3 3
Notice: 𝑃1 (2) = 4 and 𝑃1 (5) = 1 as desired.
Example 2. Use the nodes 𝑥0 = 2, 𝑥1 = 2.75, 𝑥2 = 4 to find the second Lagrange
interpolating polynomial for 𝑓(𝑥) = 1/𝑥. Then, use this polynomial to approximate 𝑓(3).
Solution. We have
(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) 2
𝐿0 (𝑥) = = (𝑥 − 2.75)(𝑥 − 4)
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) 3
(𝑥 − 𝑥0 )(𝑥 − 𝑥2 ) −16
𝐿1 (𝑥) = = (𝑥 − 2)(𝑥 − 4)
(𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) 15
(𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) 2
𝐿2 (𝑥) = = (𝑥 − 2)(𝑥 − 2.75)
(𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 ) 5
Therefore:
𝑃2 (𝑥) = 𝑓(𝑥0 )𝐿0 (𝑥) + 𝑓 (𝑥1 )𝐿1 (𝑥) + 𝑓 (𝑥2 )𝐿2 (𝑥)
1 2 1 −16 1 2
= ( ) [ (𝑥 − 2.75)(𝑥 − 4)] + ( )[ (𝑥 − 2)(𝑥 − 4)] + ( ) [ (𝑥 − 2)(𝑥 − 2.75)]
2 3 2.75 15 4 5
1 2 35 49
= 𝑥 − 𝑥+ .
22 88 44
We approximate 𝑓(3) ≈ 𝑃2 (3) = 0.32955.
3
Dr. Mohammad H. Alaroud MATH 322
Homework. Construct the interpolation polynomial 𝑃3 (𝑥) for the data
𝑥 −1 0 1 2
𝑦 2 1 2 5
What is the degree of the resulting polynomial? Why is that?
➢ Answer to Question 3.
Theorem. (Interpolation error) For 𝑥 ∈ [𝑥0 , 𝑥𝑛 ] we have
𝑓 (𝑛+1) (𝜉)
𝑃𝑛 (𝑥) +
𝑓(𝑥) = ⏟ (𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) ⋯ (𝑥 − 𝑥𝑛 ) , 𝜉 ∈ (𝑥0 , 𝑥𝑛 ).
(𝑛 + 1)!
⏟
Approx.
Error
Example 3. If 𝑃(𝑥) interpolates 𝑓(𝑥) = sin 𝑥 at the nodes
𝜋 𝜋 𝜋
𝑥0 = 0, 𝑥1 = , 𝑥2 = , 𝑥3 = .
6 3 2
(a) Find the worst-case error at 𝑥 = 1.
(b) Find a bound on the approximation error at 𝑥 = 0.2.
Solution. We have 𝑛 = 3 and 𝑓 (4) (𝑥) = sin 𝑥. Therefore:
sin(𝜉) 𝜋 𝜋 𝜋
|𝑓(𝑥) − 𝑃(𝑥)| = | (𝑥 − 0) (𝑥 − ) (𝑥 − ) (𝑥 − )|
4! 6 3 2
4
Dr. Mohammad H. Alaroud MATH 322
1 𝜋 𝜋 𝜋 𝜋
≤ |(𝑥 − 0) (𝑥 − ) (𝑥 − ) (𝑥 − )|, ∀𝑥 ∈ (0, ).
24 6 3 2 2
(a) We have
1 𝜋 𝜋 𝜋
|sin(1) − 𝑃(1)| ≤ |(1 − 0) (1 − ) (1 − ) (1 − )| = 0.0005.
24 6 3 2
(b) We have
1 𝜋 𝜋 𝜋
|sin(0.2) − 𝑃(0.2)| ≤ |(0.2 − 0) (0.2 − ) (0.2 − ) (0.2 − )| = 0.0003.
24 6 3 2
Example 4. Let 𝑓(𝑥) = √𝑥 + 1. Suppose we approximated 𝑓(𝑥) by a second interpolating
polynomial through the nodes 𝑥0 = 1, 𝑥1 = 1.2, 𝑥2 = 1.5. Find a bound on the absolute
error |𝑓(𝑥) − 𝑃2 (𝑥)| for all 𝑥 ∈ [1, 1.5].
Solution. We have
𝑓 (3) (𝜉)
𝑓(𝑥) = 𝑃2 (𝑥) + (𝑥 − 1)(𝑥 − 1.2)(𝑥 − 1.5), 𝜉 ∈ (1, 1.5).
3!
Therefore,
𝑓 (3) (𝜉)
|𝑓(𝑥) − 𝑃2 (𝑥)| = | (𝑥 − 1)(𝑥 − 1.2)(𝑥 − 1.5)|
⏟
3! 𝑔(𝑥)
Simple calculations show that
5
(3)
3 1 (3)
3 1 5
𝑓 (𝑥) = ( ) ⟹ |𝑓 (𝑥)| ≤ ( ) ∀𝑥 ∈ [1, 1.5].
8 √𝑥 + 1 8 √2
Since
𝑔′ (𝑥) = 3𝑥 2 − 7.4𝑥 + 4.5.
the critical points of 𝑔(𝑥) in (1, 1.5) are
5
Dr. Mohammad H. Alaroud MATH 322
7.4 ± √(7.4)2 − (4)(3)(4.5)
𝑟1,2 = ⟹ 𝑟1 = 1.08804, 𝑟2 = 1.37863
6
with 𝑔(1) = 0, 𝑔(𝑟1 ) = 0.00406, 𝑔(𝑟2 ) = −0.0082, 𝑔(1.5) = 0, and so
|𝑔(𝑥)| ≤ 0.0082 ∀𝑥 ∈ [1, 1.5].
Therefore:
1 3 1 5
|𝑓(𝑥) − 𝑃2 (𝑥)| ≤ × ( ) × (0.0082) = 9 × 10−5 ∀𝑥 ∈ [1, 1.5].
3! 8 √2