Module1-Part3
Module1-Part3
Interpolation
1/29
Introduction
What is Interpolation?
Definition: Estimating unknown values between known data points.
Importance in data analysis and computer graphics.
2/29
Polynomial Interpolation
For n data points, there is only one polynomial of order (n − 1) that passes
through all the points.
Two Points: There is only one straight line (a first-order polynomial)
that connects two points.
Three Points: There is only one parabola (a second-order
polynomial) that connects three points.
3/29
Examples
Polynomial interpolation determines the unique (n − 1)-th order
polynomial that fits n data points, providing a formula to compute
intermediate values.
4/29
Methods of Polynomial Interpolation
5/29
Linear Interpolation
The simplest form of interpolation is to connect two data points with a
straight line, known as linear interpolation. This method is depicted
graphically in following figure:
Figure: Graphical depiction of linear interpolation. The shaded areas indicate the
similar triangles used to derive the Newton linear- interpolation formula.
6/29
Linear Interpolation Formula
f (x2 ) − f (x1 )
f1 (x) = f (x1 ) + (x − x1 ) (3)
x2 − x1
The notation f1 (x) designates that this is a first-order interpolating
polynomial. The term:
f (x2 ) − f (x1 )
(4)
x2 − x1
represents the slope of the line connecting the points (x1 , f (x1 )) and
(x2 , f (x2 )).
7/29
Newton Linear-Interpolation Formula
Notice that:
f (x2 ) − f (x1 )
(5)
x2 − x1
is a finite-difference approximation of the first derivative of f (x) at x. This
provides an estimate of the slope of the function between x1 and x2 .
In general, the smaller the interval between the data points, the better the
approximation. This is due to the fact that, as the interval decreases, a
continuous function will be better approximated by a straight line.
Example Problem:
Estimate the natural logarithm of 2 using linear interpolation. First,
perform the computation by interpolating between ln 1 = 0 and
ln 6 = 1.791759. Then, repeat the procedure using a smaller interval, from
ln 1 to ln 4 = 1.386294. Note that the true value of ln 2 is 0.6931472.
8/29
Solution:
To estimate the natural logarithm of 2 (ln 2) using linear interpolation,
follow these steps:
First Interpolation
Interpolate between the points (1, ln 1) and (6, ln 6). Given:
ln 1 = 0
ln 6 = 1.791759
We want to estimate ln 2. Using the linear interpolation formula:
f (x2 ) − f (x1 )
f1 (x) = f (x1 ) + (x − x1 )
x2 − x1
Here, x1 = 1, x2 = 6, f (x1 ) = ln 1 = 0, f (x2 ) = ln 6 = 1.791759, and
x = 2. Substitute these values into the formula:
1.791759 − 0
ln 2 ≈ 0 + (2 − 1)
6−1
1.791759
ln 2 ≈ = 0.3583518
9/29 5
Second Interpolation
Now, interpolate using a smaller interval between (1, ln 1) and (4, ln 4).
Given:
ln 4 = 1.386294
Again, using the linear interpolation formula with x1 = 1, x2 = 4,
f (x1 ) = ln 1 = 0, f (x2 ) = ln 4 = 1.386294, and x = 2:
1.386294 − 0
ln 2 ≈ 0 + (2 − 1)
4−1
1.386294
ln 2 ≈ = 0.462098
3
Comparison with True Value
The true value of ln 2 is approximately 0.6931472.
Using the interval from ln 1 to ln 6, the estimated value is 0.3583518.
Using the interval from ln 1 to ln 4, the estimated value is 0.462098.
The estimates are less accurate compared to the true value of 0.6931472.
The accuracy improves with smaller intervals around the point of interest.
10/29
Figure: Two linear interpolations to estimate ln 2. Note how the smaller interval
provides a better estimate.
11/29
Quadratic Interpolation
b1 = f (x1 ) (7)
12/29
Eq. (7) can be substituted into Eq. (6), which can be evaluated at x = x2
for
f (x2 ) − f (x1 )
b2 = (8)
x2 − x1
Finally Eq. (7) and Eq. (8) can be substituted into Eq. (6), which can be
evaluated at x = x3 and solved for
f (x3 )−f (x2 ) f (x2 )−f (x1 )
x3 −x2 − x2 −x1
b3 = (9)
x3 − x1
Notice that, as was the case with linear interpolation, b still represents the
slope of the line connecting two points x1 and x2 . Thus, the first two
terms of Eq. (6) are equivalent to linear interpolation between x1 and x2 ,
as specified previously in Eq. (3). The last term, b3 (x − x1 )(x − x2 ),
introduces the second-order curvature into the formula.
13/29
Example Problem:
Employ a second-order Newton polynomial to estimate ln 2 with the same
three points used in previous example:
x1 = 1 f (x1 ) = 0
x2 = 4 f (x2 ) = 1.386294
x3 = 6 f (x3 ) = 1.791759
14/29
Solution:
Applying Eq. (7) yields
b1 = 0 (10)
Equation (8) gives
1.386294 − 0
b2 = = 0.4620981 (11)
4−1
Eq. (9) yields
1.791759−1.386294
6−4 − 0.4620981
b3 = = −0.0518731 (12)
6−1
15/29
Substituting these values into Eq. (6) yields the quadratic formula
ε = 18.4% (15)
16/29
Figure: The use of quadratic interpolation to estimate ln 2. The linear
interpolation from x = 1 to 4 is also included for comparison.
17/29
General Form of Newton’s Interpolating Polynomials
18/29
We use these data points and the following equations to evaluate the
coefficients:
b1 = f (x1 ) (17)
b2 = f [x2 , x1 ] (18)
b3 = f [x3 , x2 , x1 ] (19)
..
.
21/29
Example Problem: In previous examples, data points at x = 1, x = 4,
and x = 6 were used to estimate ln 2 with a parabola. Now, adding a
fourth point (x = 5, f (x) = 1.609438), we aim to estimate ln 2 with a
third-order Newton’s interpolating polynomial.
22/29
Third-Order Polynomial
f3 (x) = b1 +b2 (x −x1 )+b3 (x −x1 )(x −x2 )+b4 (x −x1 )(x −x2 )(x −x3 ) (25)
23/29
First Divided Differences
The first divided differences for the problem are (from Eq. 21)
1.386294 − 0
f [x2 , x1 ] = = 0.4620981,
4−1
1.791759 − 1.386294
f [x3 , x2 ] = = 0.2027326,
6−4
1.609438 − 1.791759
f [x4 , x3 ] = = 0.1823216.
5−6
24/29
Second Divided Differences
0.2027326 − 0.4620981
f [x3 , x2 , x1 ] = = −0.05187311,
6−1
0.1823216 − 0.2027326
f [x4 , x3 , x2 ] = = −0.02041100.
5−4
25/29
Third Divided Difference
−0.02041100 − (−0.05187311)
f [x4 , x3 , x2 , x1 ] = = 0.007865529.
5−1
26/29
Divided Difference Table
27/29
Interpolating Cubic
f3 (x) = 0
+ 0.4620981(x − 1)
(26)
− 0.05187311(x − 1)(x − 4)
+ 0.007865529(x − 1)(x − 4)(x − 6).
28/29
Figure: The use of cubic interpolation to estimate ln 2.
29/29