You are on page 1of 77

Polynomial Interpolation

Nonie Elvin S. Leyrita


(Instructor)

Father Saturnino Urios University

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The primary objective of this lesson is to introduce you to polynomial
interpolation
1 Recognizing that evaluating polynomial coefficients with simultaneous
equations is an ill-conditioned problem.
2 Knowing how to perform an interpolation with Newton’s polynomial.
3 Knowing how to perform an interpolation with a Lagrange polynomial.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


You will frequently have occasion to estimate intermediate values be-
tween precise data points. The most common method used for this purpose
is polynomial interpolation. The general formula for an (n − 1)th-order
polynomial can be written as

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


You will frequently have occasion to estimate intermediate values be-
tween precise data points. The most common method used for this purpose
is polynomial interpolation. The general formula for an (n − 1)th-order
polynomial can be written as

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

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


You will frequently have occasion to estimate intermediate values be-
tween precise data points. The most common method used for this purpose
is polynomial interpolation. The general formula for an (n − 1)th-order
polynomial can be written as

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

For n data points, there is one and only one polynomial of order (n − 1)
that passes through all the points.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


You will frequently have occasion to estimate intermediate values be-
tween precise data points. The most common method used for this purpose
is polynomial interpolation. The general formula for an (n − 1)th-order
polynomial can be written as

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

For n data points, there is one and only one polynomial of order (n − 1)
that passes through all the points.
1 There is only one straight line (i.e., a first-order polynomial) that
connects two points.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


You will frequently have occasion to estimate intermediate values be-
tween precise data points. The most common method used for this purpose
is polynomial interpolation. The general formula for an (n − 1)th-order
polynomial can be written as

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

For n data points, there is one and only one polynomial of order (n − 1)
that passes through all the points.
1 There is only one straight line (i.e., a first-order polynomial) that
connects two points.
2 Only one parabola connects a set of three points.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Definition 1
Polynomial interpolation consists of determining the unique (n − 1)th
order polynomial that fits n data points. This polynomial then provides
a formula to compute intermediate values.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Definition 1
Polynomial interpolation consists of determining the unique (n − 1)th
order polynomial that fits n data points. This polynomial then provides
a formula to compute intermediate values.

Figure 1: 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.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 2
Suppose that we want to determine the coefficients of the parabola,
f (x ) = a3 x 2 + a2 x + a1 , that passes through

x1 = 300 f (x1 ) = 0.616


x2 = 400 f (x2 ) = 0.525
x3 = 500 f (x3 ) = 0.457

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 2
Suppose that we want to determine the coefficients of the parabola,
f (x ) = a3 x 2 + a2 x + a1 , that passes through

x1 = 300 f (x1 ) = 0.616


x2 = 400 f (x2 ) = 0.525
x3 = 500 f (x3 ) = 0.457

We then have a system of three equation:

0.616 = a3 (300)2 + a2 (300) + a1


0.525 = a3 (400)2 + a2 (400) + a1
0.457 = a3 (500)2 + a2 (500) + a1

or in matrix form:

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


" #" # " #
90000 300 1 a3 0.616
u= 160000 400 1 a2 = 0.525 ,
250000 500 1 a1 0.457

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


" #" # " #
90000 300 1 a3 0.616
u= 160000 400 1 a2 = 0.525 ,
250000 500 1 a1 0.457

Thus, the problem reduces to solving three simultaneous linear algebraic


equations for the three unknown coefficients. Employing the methods
from previous discussions, the parabola that passes exactly through the
three points is

f (x ) = 0.00000115x 2 − 0.001715x + 1.027

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Newton Interpolating Polynomial

There are a variety of alternative forms for expressing an interpolating


polynomial beyond the familiar format of Eq. (1).

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Newton Interpolating Polynomial

There are a variety of alternative forms for expressing an interpolating


polynomial beyond the familiar format of Eq. (1).

Linear Interpolation
The simplest form of interpolation is to connect two data points with
a straight line. This technique, called linear interpolation. Using similar
triangles,

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Newton Interpolating Polynomial

There are a variety of alternative forms for expressing an interpolating


polynomial beyond the familiar format of Eq. (1).

Linear Interpolation
The simplest form of interpolation is to connect two data points with
a straight line. This technique, called linear interpolation. Using similar
triangles,

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


= (2)
x − x1 x2 − x1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Newton Interpolating Polynomial

There are a variety of alternative forms for expressing an interpolating


polynomial beyond the familiar format of Eq. (1).

Linear Interpolation
The simplest form of interpolation is to connect two data points with
a straight line. This technique, called linear interpolation. Using similar
triangles,

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


= (2)
x − x1 x2 − x1
which can be rearranged to yield

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Newton Interpolating Polynomial

There are a variety of alternative forms for expressing an interpolating


polynomial beyond the familiar format of Eq. (1).

Linear Interpolation
The simplest form of interpolation is to connect two data points with
a straight line. This technique, called linear interpolation. Using similar
triangles,

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


= (2)
x − x1 x2 − x1
which can be rearranged to yield

f (x2 ) − f (x1 )
f1 (x ) = f (x1 ) + (x − x1 ) (3)
x2 − x1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Figure 2: Graphical depiction of linear interpolation. The shaded areas indicate
the similar triangles used to derive the Newton linear-interpolation formula.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


which is the Newton linear-interpolation formula. The notation f1 (x ) des-
ignates that this is a first-order interpolating polynomial. Notice that
besides representing the slope of the line connecting the points, the term
[f (x2 ) − f (x1 )]/(x2 − x1 ) is a finite-difference approximation of the first
derivative.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 3

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, but use a smaller interval from
ln 1 to ln 4 = 1.386294. Note that the true value of ln 2 is 0.6931472.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 3

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, but use a smaller interval from
ln 1 to ln 4 = 1.386294. Note that the true value of ln 2 is 0.6931472.

Solution: We use Eq.(3) from x1 = 1 to x2 = 6 to give

1.791759 − 0
f1 (2) = 0 + (2 − 1) = 0.3583519
6−1
which represents an error of εt = 48.3%. Using the smaller interval from
x1 = 1 to x2 = 4 yields

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 3

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, but use a smaller interval from
ln 1 to ln 4 = 1.386294. Note that the true value of ln 2 is 0.6931472.

Solution: We use Eq.(3) from x1 = 1 to x2 = 6 to give

1.791759 − 0
f1 (2) = 0 + (2 − 1) = 0.3583519
6−1
which represents an error of εt = 48.3%. Using the smaller interval from
x1 = 1 to x2 = 4 yields
1.386294 − 0
f1 (2) = 0 + (2 − 1) = 0.4620981
4−1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Figure 3: Two linear interpolations to estimate ln 2.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Figure 3: Two linear interpolations to estimate ln 2.

Thus, using the shorter interval reduces the percent relative error to εt =
33.3%.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Quadratic Interpolation

The error in Example 3 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 poly-
nomial (also called a quadratic polynomial or a parabola). A particularly
convenient form for this purpose is

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Quadratic Interpolation

The error in Example 3 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 poly-
nomial (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 ) (4)

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Quadratic Interpolation

The error in Example 3 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 poly-
nomial (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 ) (4)

We now present a procedure can be used to determine the values of the


coefficients. For b1 , Eq.(4) with x = x1 can be used to compute

b1 = f (x1 ) (5)

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Equation (5) can be substituted into Eq. (4), which can be evaluated at
x = x2 for

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Equation (5) can be substituted into Eq. (4), which can be evaluated at
x = x2 for
f (x2 ) − f (x1 )
b2 = (6)
x2 − x1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Equation (5) can be substituted into Eq. (4), which can be evaluated at
x = x2 for
f (x2 ) − f (x1 )
b2 = (6)
x2 − x1
Finally, Eqs. (5) and (6) can be substituted into Eq. (4), which can be
evaluated at x = x3 and solved (after some algebraic manipulations) for

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Equation (5) can be substituted into Eq. (4), which can be evaluated at
x = x2 for
f (x2 ) − f (x1 )
b2 = (6)
x2 − x1
Finally, Eqs. (5) and (6) can be substituted into Eq. (4), which can be
evaluated at x = x3 and solved (after some algebraic manipulations) for
f (x3 )−f (x2 ) f (x2 )−f (x1 )
x3 −x2 − x2 −x1
b3 = (7)
x3 − x1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Equation (5) can be substituted into Eq. (4), which can be evaluated at
x = x2 for
f (x2 ) − f (x1 )
b2 = (6)
x2 − x1
Finally, Eqs. (5) and (6) can be substituted into Eq. (4), which can be
evaluated at x = x3 and solved (after some algebraic manipulations) for
f (x3 )−f (x2 ) f (x2 )−f (x1 )
x3 −x2 − x2 −x1
b3 = (7)
x3 − x1
Observations:
1 b2 still represents the slope of the line connecting points x1 and x2

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Equation (5) can be substituted into Eq. (4), which can be evaluated at
x = x2 for
f (x2 ) − f (x1 )
b2 = (6)
x2 − x1
Finally, Eqs. (5) and (6) can be substituted into Eq. (4), which can be
evaluated at x = x3 and solved (after some algebraic manipulations) for
f (x3 )−f (x2 ) f (x2 )−f (x1 )
x3 −x2 − x2 −x1
b3 = (7)
x3 − x1
Observations:
1 b2 still represents the slope of the line connecting points x1 and x2
2 the first two terms of Eq. (4) are equivalent to linear interpolation
between x1 and x2

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Equation (5) can be substituted into Eq. (4), which can be evaluated at
x = x2 for
f (x2 ) − f (x1 )
b2 = (6)
x2 − x1
Finally, Eqs. (5) and (6) can be substituted into Eq. (4), which can be
evaluated at x = x3 and solved (after some algebraic manipulations) for
f (x3 )−f (x2 ) f (x2 )−f (x1 )
x3 −x2 − x2 −x1
b3 = (7)
x3 − x1
Observations:
1 b2 still represents the slope of the line connecting points x1 and x2
2 the first two terms of Eq. (4) are equivalent to linear interpolation
between x1 and x2
3 b3 (x − x1 )(x − x2 ), introduces the second-order curvature into the
formula

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 4

Employ a second-order Newton polynomial to estimate ln 2 with the


same three points used in Example 3:

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 4

Employ a second-order Newton polynomial to estimate ln 2 with the


same three points used in Example 3:

x1 = 1 f (x1 ) = 0
x2 = 4 f (x2 ) = 1.386294
x3 = 6 f (x3 ) = 1.791759

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 4

Employ a second-order Newton polynomial to estimate ln 2 with the


same three points used in Example 3:

x1 = 1 f (x1 ) = 0
x2 = 4 f (x2 ) = 1.386294
x3 = 6 f (x3 ) = 1.791759

Solution: Applying Eq. (5) yields b1 = 0. Equation (6) gives

1.386294 − 0
b2 = = 0.4620981
4−1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 4

Employ a second-order Newton polynomial to estimate ln 2 with the


same three points used in Example 3:

x1 = 1 f (x1 ) = 0
x2 = 4 f (x2 ) = 1.386294
x3 = 6 f (x3 ) = 1.791759

Solution: Applying Eq. (5) yields b1 = 0. Equation (6) gives

1.386294 − 0
b2 = = 0.4620981
4−1
and Eq.(7) yields
1.791759−1.386294
6−4 − 0.4620981
b3 = = −0.0518731
6−1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Figure 4: The use of quadratic interpolation to estimate ln 2. The linear
interpolation from x = 1 to 4 is also included for comparison

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Substituting these values into Eq. (4) yields the quadratic formula

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

which can be evaluated at x = 2 for f2 (2) = 0.5658444, which represents


a relative error of εt = 18.4%. Thus, the curvature introduced by the
quadratic formula (Fig.4) improves the interpolation compared with the
result obtained using straight lines in Example 3 and Fig. 3.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


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

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


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

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

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


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

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

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 )]. We use these data points and the following equations to eval-
uate the coefficients:

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


b1 = f (x1 ) (9a)
b2 = f [x2 , x1 ] (9b)
b3 = f [x3 , x2 , x1 ] (9c)
..
.
bn = f [xn , xn−1 , . . . , x2 , x1 ] (9d)

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


b1 = f (x1 ) (9a)
b2 = f [x2 , x1 ] (9b)
b3 = f [x3 , x2 , x1 ] (9c)
..
.
bn = f [xn , xn−1 , . . . , x2 , x1 ] (9d)

where the bracketed function evaluations are finite divided differences. For
example, the first finite divided difference is represented generally as

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


b1 = f (x1 ) (9a)
b2 = f [x2 , x1 ] (9b)
b3 = f [x3 , x2 , x1 ] (9c)
..
.
bn = f [xn , xn−1 , . . . , x2 , x1 ] (9d)

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 ] = (11)
xi − xj

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The second finite divided difference, which represents the difference of two
first divided differences, is expressed generally as

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


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 ] = (12)
xi − xk

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


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 ] = (12)
xi − xk
Similarly, the nth finite divided difference is

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


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 ] = (12)
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 ] = (13)
xn − x1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


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 ] = (12)
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 ] = (13)
xn − x1
These differences can be used to evaluate the coefficients in Eqs. (9a)
through (9d), which can then be substituted into Eq. (8) to yield the
general form of Newton’s interpolating polynomial:

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


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 ] = (12)
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 ] = (13)
xn − x1
These differences can be used to evaluate the coefficients in Eqs. (9a)
through (9d), which can then be substituted into Eq. (8) to yield the
general form of Newton’s interpolating polynomial:

fn−1 (x ) = f (x1 ) + (x − x 1)f [x2 , x1 ] + (x − x1 )(x − x2 )f [x3 , x2 , x1 ]


+ · · · + (x − x1 )(x − x2 ) · · · (x − xn−1 )f [xn , xn−1 , · · · , x2 , x1 ]
(14)

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 5
In Example 4, data points at x1 = 1, x2 = 4, and x3 = 6 were
used to estimate ln 2 with a parabola. Now, adding a fourth point
[x4 = 5; f (x4 ) = 1.609438], estimate ln 2 with a third-order Newton’s
interpolating polynomial.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 5
In Example 4, data points at x1 = 1, x2 = 4, and x3 = 6 were
used to estimate ln 2 with a parabola. Now, adding a fourth point
[x4 = 5; f (x4 ) = 1.609438], estimate ln 2 with a third-order Newton’s
interpolating polynomial.

Solution: The third-order polynomial, Eq. (8) with n = 4, is

f3 (x ) = b1 + b2 (x − x 1) + b3 (x − x1 )(x − x2 ) + b4 (x − x 1)(x − x2 )(x − x3 )

The first divided differences for the problem are


1.386249 − 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

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The second divided differences are
0.2027326 − 0.4620981
f [x3 , x2 , x1 ] = = −0.05187311
6−1
0.1823216 − 0.2027326
f [x4 , x3 , x2 ] = = −0.02041100
5−4

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The second divided differences are
0.2027326 − 0.4620981
f [x3 , x2 , x1 ] = = −0.05187311
6−1
0.1823216 − 0.2027326
f [x4 , x3 , x2 ] = = −0.02041100
5−4
The third divided difference is
−0.02041100 − (−0.05187311)
f [x4 , x3 , x2 , x1 ] = = 0.007865529
5−1
The results for f (x1 ), f [x2 , x1 ], f [x3 , x2 , x1 ], and f [x4 , x3 , x2 , x1 ] represent
the coefficients b1 , b2 , b3 , and b4 , respectively, of Eq. (8). Thus, the
interpolating cubic is

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The second divided differences are
0.2027326 − 0.4620981
f [x3 , x2 , x1 ] = = −0.05187311
6−1
0.1823216 − 0.2027326
f [x4 , x3 , x2 ] = = −0.02041100
5−4
The third divided difference is
−0.02041100 − (−0.05187311)
f [x4 , x3 , x2 , x1 ] = = 0.007865529
5−1
The results for f (x1 ), f [x2 , x1 ], f [x3 , x2 , x1 ], and f [x4 , x3 , x2 , x1 ] represent
the coefficients b1 , b2 , b3 , and b4 , respectively, of Eq. (8). Thus, the
interpolating cubic is

f3 (x ) = 0 + 0.4620981(x − 1) − 0.05187311(x − 1)(x − 4)


+ 0.007865529(x − 1)(x − 4)(x − 6)

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The second divided differences are
0.2027326 − 0.4620981
f [x3 , x2 , x1 ] = = −0.05187311
6−1
0.1823216 − 0.2027326
f [x4 , x3 , x2 ] = = −0.02041100
5−4
The third divided difference is
−0.02041100 − (−0.05187311)
f [x4 , x3 , x2 , x1 ] = = 0.007865529
5−1
The results for f (x1 ), f [x2 , x1 ], f [x3 , x2 , x1 ], and f [x4 , x3 , x2 , x1 ] represent
the coefficients b1 , b2 , b3 , and b4 , respectively, of Eq. (8). Thus, the
interpolating cubic is

f3 (x ) = 0 + 0.4620981(x − 1) − 0.05187311(x − 1)(x − 4)


+ 0.007865529(x − 1)(x − 4)(x − 6)

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


relative error of εt = 9.3%.
Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation
Figure 5: The use of cubic interpolation to estimate ln 2.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Lagrange Interpolating Polynomials

Suppose we formulate a linear interpolating polynomial as the weighted


average of the two values that we are connecting by a straight line:

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Lagrange Interpolating Polynomials

Suppose we formulate a linear interpolating polynomial as the weighted


average of the two values that we are connecting by a straight line:

f (x ) = L1 f (x1 ) + L2 f (x2 ) (15)

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Lagrange Interpolating Polynomials

Suppose we formulate a linear interpolating polynomial as the weighted


average of the two values that we are connecting by a straight line:

f (x ) = L1 f (x1 ) + L2 f (x2 ) (15)

where the L0 s are the weighting coefficients. It is logical that the first
weighting coefficient is the straight line that is equal to 1 at x1 and 0 at
x2 :

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Lagrange Interpolating Polynomials

Suppose we formulate a linear interpolating polynomial as the weighted


average of the two values that we are connecting by a straight line:

f (x ) = L1 f (x1 ) + L2 f (x2 ) (15)

where the L0 s are the weighting coefficients. It is logical that the first
weighting coefficient is the straight line that is equal to 1 at x1 and 0 at
x2 :
x − x2
L1 =
x1 − x2
Similarly, the second coefficient is the straight line that is equal to 1 at x2
and 0 at x1 :

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Lagrange Interpolating Polynomials

Suppose we formulate a linear interpolating polynomial as the weighted


average of the two values that we are connecting by a straight line:

f (x ) = L1 f (x1 ) + L2 f (x2 ) (15)

where the L0 s are the weighting coefficients. It is logical that the first
weighting coefficient is the straight line that is equal to 1 at x1 and 0 at
x2 :
x − x2
L1 =
x1 − x2
Similarly, the second coefficient is the straight line that is equal to 1 at x2
and 0 at x1 :
x − x1
L2 =
x2 − x1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Substituting these coefficients into Eq.15 yields the straight line that con-
nects the points (Fig.6):

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Substituting these coefficients into Eq.15 yields the straight line that con-
nects the points (Fig.6):
x − x2 x − x2
f1 (x ) = f (x1 ) + f (x2 ) (16)
x1 − x2 x1 − x2

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Substituting these coefficients into Eq.15 yields the straight line that con-
nects the points (Fig.6):
x − x2 x − x2
f1 (x ) = f (x1 ) + f (x2 ) (16)
x1 − x2 x1 − x2
where the nomenclature f1 (x ) designates that this is a first-order poly-
nomial. Equation (16) is referred to as the linear Lagrange interpolating
polynomial.

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Figure 6: A visual depiction of the rationale behind Lagrange interpolating
polynomials. The figure shows the first-order case. Each of the two terms of
Eq. (16) passes through one of the points and is zero at the other. The
summation of the two terms must, therefore, be the unique straight line that
connects the two points

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The same strategy can be employed to fit a parabola through three points.
For this case three parabolas would be used with each one passing through
one of the points and equaling zero at the other two. Their sum would
then represent the unique parabola that connects the three points. Such
a second-order Lagrange interpolating polynomial can be written as

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The same strategy can be employed to fit a parabola through three points.
For this case three parabolas would be used with each one passing through
one of the points and equaling zero at the other two. Their sum would
then represent the unique parabola that connects the three points. Such
a second-order Lagrange interpolating polynomial can be written as
(x − x2 )(x − x3 ) (x − x1 )(x − x3 )
f2 (x ) = f (x1 ) + f (x2 )
(x1 − x2 )(x1 − x3 ) (x2 − x1 )(x2 − x3 )
(17)
(x − x1 )(x − x2 )
+ f (x3 )
(x3 − x1 )(x3 − x2 )

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The same strategy can be employed to fit a parabola through three points.
For this case three parabolas would be used with each one passing through
one of the points and equaling zero at the other two. Their sum would
then represent the unique parabola that connects the three points. Such
a second-order Lagrange interpolating polynomial can be written as
(x − x2 )(x − x3 ) (x − x1 )(x − x3 )
f2 (x ) = f (x1 ) + f (x2 )
(x1 − x2 )(x1 − x3 ) (x2 − x1 )(x2 − x3 )
(17)
(x − x1 )(x − x2 )
+ f (x3 )
(x3 − x1 )(x3 − x2 )
Both the first- and second-order versions as well as higher-order Lagrange
polynomials can be represented concisely as
n
X
fn−1 (x ) = Li (x )f (xi ) (18)
i=1

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The same strategy can be employed to fit a parabola through three points.
For this case three parabolas would be used with each one passing through
one of the points and equaling zero at the other two. Their sum would
then represent the unique parabola that connects the three points. Such
a second-order Lagrange interpolating polynomial can be written as
(x − x2 )(x − x3 ) (x − x1 )(x − x3 )
f2 (x ) = f (x1 ) + f (x2 )
(x1 − x2 )(x1 − x3 ) (x2 − x1 )(x2 − x3 )
(17)
(x − x1 )(x − x2 )
+ f (x3 )
(x3 − x1 )(x3 − x2 )
Both the first- and second-order versions as well as higher-order Lagrange
polynomials can be represented concisely as
n
X
fn−1 (x ) = Li (x )f (xi ) (18)
i=1
where
n
x − xj Y
Li (x ) = (19)
xi − xj
j=1,j6=i
Q
where n = the number of data points and designates the “product of.”
Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation
Example 6
Use a Lagrange interpolating polynomial of the first and second order
to evaluate the density of unused motor oil at T = 15◦ C based on the
following data:

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


Example 6
Use a Lagrange interpolating polynomial of the first and second order
to evaluate the density of unused motor oil at T = 15◦ C based on the
following data:
x1 = 0 f (x1 ) = 3.85
x2 = 20 f (x2 ) = 0.800
x3 = 40 f (x3 ) = 0.212

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The first-order polynomial can be used to obtain the estimate at x = 15:
15 − 20 15 − 0
f1 (x ) = (3.85) + (0.800) = 1.5625
0 − 20 20 − 0

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation


The first-order polynomial can be used to obtain the estimate at x = 15:
15 − 20 15 − 0
f1 (x ) = (3.85) + (0.800) = 1.5625
0 − 20 20 − 0
In a similar fashion, the second-order polynomial is developed as

(15 − 20)(15 − 50) (15 − 0)(15 − 40)


f2 (x ) = (3.85) + (0.800)
(0 − 20)(0 − 40) (20 − 0)(20 − 40)
(15 − 0)(15 − 20)
+ (0.212) = 1.3316875
(40 − 0)(40 − 20)

Nonie Elvin S. Leyrita (Instructor) Polynomial Interpolation

You might also like