0% found this document useful (0 votes)
3 views

Module1-Part3

The document provides an introduction to interpolation in computational physics, defining it as the estimation of unknown values between known data points. It discusses polynomial interpolation methods, including Lagrange, Newton, and Vandermonde, and illustrates linear and quadratic interpolation with examples. Additionally, it explains the general form of Newton's interpolating polynomials and demonstrates the process of estimating values using various polynomial orders.

Uploaded by

ac2011491981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Module1-Part3

The document provides an introduction to interpolation in computational physics, defining it as the estimation of unknown values between known data points. It discusses polynomial interpolation methods, including Lagrange, Newton, and Vandermonde, and illustrates linear and quadratic interpolation with examples. Additionally, it explains the general form of Newton's interpolating polynomials and demonstrates the process of estimating values using various polynomial orders.

Uploaded by

ac2011491981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Introduction to Computational Physics

Interpolation

Dr. Sharad Chandra Tripathi

School of Advanced Sciences and Languages, VIT Bhopal University

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

A general formula for an (n − 1)-th order polynomial is:

f (x) = a0 + a1 x + a2 x 2 + · · · + an−1 x n−1 (1)

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.

Figure: Examples of interpolating polynomials: (a) first-order (linear) connecting


two points, (b) second-order (quadratic or parabolic) connecting three points, and
(c) third-order (cubic) connecting four points..

4/29
Methods of Polynomial Interpolation

Lagrange Interpolation: Constructs the polynomial using Lagrange


basis polynomials.
Newton Interpolation: Builds the polynomial incrementally using
divided differences.
Vandermonde Matrix: Solves the system of linear equations to find
the polynomial coefficients.

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

Using similar triangles, the formula for linear interpolation is:

f1 (x) − f (x1 ) f (x2 ) − f (x1 )


= (2)
x − x1 x2 − x1
Rearranging this equation yields the Newton 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

The error in the previous example resulted from approximating a curve


with a straight line.
Consequently, a strategy for improving the estimate is to introduce some
curvature into the line connecting the points. If three data points are
available, this can be accomplished with a second-order polynomial (also
called a quadratic polynomial or a parabola).
A particularly convenient form for this purpose is:

f2 (x) = b1 + b2 (x − x1 ) + b3 (x − x1 )(x − x2 ) (6)


A simple procedure can be used to determine the values of the coefficients.
For b1 , Eq. (6) with x = x1 can be used to compute f (x1 ).

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

f2 (x) = 0 + 0.4620981(x − 1) − 0.0518731(x − 1)(x − 4) (13)

which can be evaluated at x = 2 for

f (2) = 0.5658444 (14)

This represents a relative error of

ε = 18.4% (15)

Thus, the curvature introduced by the quadratic formula improves the


interpolation compared with the result obtained using straight lines.

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

The preceding analysis can be generalized to fit an (n − 1)th-order


polynomial to n data points. The (n − 1)th-order polynomial is given by

fn−1 (x) = b1 + b2 (x − x1 ) + · · · + bn (x − x1 )(x − x2 ) · · · (x − xn−1 ), (16)

where b1 , b2 , . . . , bn are the coefficients, and x1 , x2 , . . . , xn−1 are the


distinct data points.
As was done previously with linear and quadratic interpolation, data points
can be used to evaluate the coefficients b1 , b2 , . . . , bn .
For an (n − 1)th-order polynomial, n data points are required:

(x1 , f (x1 )), (x2 , f (x2 )), . . . , (xn , f (xn )).

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)

..
.

bn = f [xn , xn−1 , . . . , x2 , x1 ] (20)


where the bracketed function evaluations are finite divided differences. For
example, the first finite divided difference is represented generally as
f (xi ) − f (xj )
f [xi , xj ] = (21)
xi − xj
19/29
The second finite divided difference, which represents the difference of two
first divided differences, is expressed generally as
f [xi , xj ] − f [xj , xk ]
f [xi , xj , xk ] = (22)
xi − xk
Similarly the nth finite divided difference is
f [xn , xn−1 , . . . , x2 ] − f [xn−1 , xn−2 , . . . , x1 ]
f [xn , xn−1 , . . . , x2 , x1 ] = (23)
xn − x1
These differences can be used to evaluate the coefficients in Eqs. (17)
through (20), which can then be substituted into Eq. (16) to yield the
general form of Newton’s interpolating polynomial:

fn−1 (x) = f [x1 ]


+ (x − x1 )f [x2 , x1 ]
+ (x − x1 )(x − x2 )f [x3 , x2 , x1 ] (24)
+ ···
+ (x − x1 )(x − x2 ) · · · (x − xn−1 )f [xn , xn−1 , . . . , x1 ]
20/29
We should note that it is not necessary that the data points used in Eq.
(24) be equally spaced or that the abscissa values necessarily be in
ascending order. However, the points should be ordered so that they are
centered around and as close as possible to the unknown. Also, notice how
Eqs. (21) through (23) are recursive—that is, higher-order differences are
computed by taking differences of lower-order differences.

Figure: Graphical depiction of the recursive nature of finite divided differences.


This representation is referred to as a divided difference table.

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

The third-order polynomial, Eq. (16) with n = 4, is

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

The second divided differences are (from Eq. 22)

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

The third divided difference is (from Eq. 23 with n = 4)

−0.02041100 − (−0.05187311)
f [x4 , x3 , x2 , x1 ] = = 0.007865529.
5−1

26/29
Divided Difference Table

Thus, the divided difference table is


xi f (xi ) First Second Third
1 0 0.4620981 -0.05187311 0.007865529
4 1.386294 0.2027326 -0.02041100
6 1.791759 0.1823216
5 1.609438

27/29
Interpolating Cubic

The results for f (x), f [x1 , x2 ], f [x1 , x2 , x3 ], and f [x1 , x2 , x3 , x4 ] represent


the coefficients b1 , b2 , b3 , and b4 , respectively, of Eq. (16). Thus, the
interpolating cubic is

f3 (x) = 0
+ 0.4620981(x − 1)
(26)
− 0.05187311(x − 1)(x − 4)
+ 0.007865529(x − 1)(x − 4)(x − 6).

which can be used to evaluate f (2) = 0.6287686, which represents a


relative error of
ϵ = 9.3%.
The complete cubic polynomial is shown in the next Figure.

28/29
Figure: The use of cubic interpolation to estimate ln 2.

29/29

You might also like