Visualizing The Components of Lagrange and Newton Interpolation
Visualizing The Components of Lagrange and Newton Interpolation
Newton Interpolation
spaced. These interpolating points then determine a unique polynomial of degree n (or
possibly lower, if the points happen to lie on such a curve). One way to express the
equation of this polynomial is with the Lagrange Interpolating Formula:
n n ( x - xk ) n ( x - x0 )L ( x - xi -1 )( x - xi +1 )L ( x - xn )
Ln ( x) = yi = yi .
i =0 k =0, k i ( xi - xk ) i =0 ( xi - x0 )L ( xi - xi -1 )( xi - xi +1 )L ( xi - xn )
Equivalently, if we write this formula without the summation notation, it becomes
( x - x1 )( x - x2 )L ( x - xn ) ( x - x0 )( x - x2 )L ( x - xn )
Ln ( x) = y0 + y1 +
( x0 - x1 )( x0 - x2 )L ( x0 - xn ) ( x1 - x0 )( x1 - x2 )L ( x1 - xn )
( x - x0 )( x - x1 )L ( x - xn-1 )
L + yn .
( xn - x0 )( xn - x1 )L ( xn - xn-1 )
degree n (provided yi 0 ). Either way, both of these are rather daunting expressions for
students and consequently it is not surprising that many tend to miss some of the key
underlying concepts.
As an example, consider the three interpolating points (1, 2) , (3,8) , and (5, 4) that
determine the quadratic function whose graph is shown in Figure 1. Clearly, this function
1
(3, 8)
(1, 2) (5, 4)
passes through each of the three interpolating points. The corresponding expression for
this interpolating polynomial is
( x - 3)( x - 5) ( x - 1)( x - 5) ( x - 1)( x - 3)
L2 ( x) = 2 +8 +4 (1)
(1 - 3)(1 - 5) (3 - 1)(3 - 5) (5 - 1)(5 - 3)
1 1
= ( x - 3)( x - 5) - 2( x - 1)( x - 5) + ( x - 1)( x - 3) . (2)
4 2
More to the point here, this function is a linear combination of three distinct quadratic
functions, shown in the first expression. Lets see how each of these functions behaves,
as shown in Figure 2. (The heavier fourth curve shown is the Lagrange interpolating
polynomial.) Although the shapes of two of the curves totally miss the shape of the
interpolating polynomial, each of the three quadratics passes through just one of the
interpolating points. Moreover, not only does each one completely miss the other two
interpolating points, but also each quadratic has its real zeros precisely in line vertically
with the other two interpolating points. In addition, observe that each pair of quadratic
components share a common zero. To see why, notice that the component quadratic
functions are constructed in such a way that each of them has a pair of factors that
correspond to two of the three interpolating points. It is not coincidence that there is such
correspondence between the zeros and the interpolating points.
2
(3, 8)
(1, 2) (5, 4)
Furthermore, look at the first term in the first expression (1) for L2 ( x ) .
( x - 3)( x - 5)
Corresponding to the first interpolating point (1, 2) , the coefficient of is
(1 - 3)(1 - 5)
precisely equal to the value, 2, of y at this point. Also, at this point where x = 1 , the
factors in the numerator precisely cancel the factors in the denominator, so the total
contribution of this first term at x = 1 is y = 2 . Similarly, the second term in the
The Newton Interpolating Formula Again, suppose that we have the n + 1 points
( x0 , y0 ) , ( x1 , y1 ) , , ( xn , yn ) , where all of the xi are different. For simplicity, we
3
consider the case where these xi s are uniformly spaced with Dx = xk +1 - xk for each k .
These interpolating points determine a unique polynomial of degree n (or possibly lower,
if the points happen to lie on such a curve). Another way to express the equation of this
polynomial is with the Newton Forward Interpolating Formula:
D y0 D 2 y0 D3 y0
Pn ( x) = y0 + ( x - x0 ) + ( x - x0 )( x - x1 ) + ( x - x0 )( x - x1 )( x - x2 ) +
Dx 2!(D x) 2 3!(D x )3
(3)
D n y0
L + ( x - x0 )( x - x1 )L ( x - xn -1 ),
n!(D x) n
where
D y0 = y1 - y0 ,
D 2 y0 = D y1 - D y0 = y2 - 2 y1 + y0 ,
4
D3 y0 = D 2 y1 - D 2 y0 = y3 - 3 y2 + 3 y1 - y0 ,
M
D n y0 = D n -1 y1 - D n -1 y0
n(n - 1) n(n - 1)(n - 2)
= yn - nyn-1 + yn -2 - yn -3 + L + (-1) n y0 .
2! 3!
Notice that this polynomial Pn ( x) is also composed of n + 1 distinct polynomial terms,
but each of degree i , i = 0,1, 2,K , n . Term by term, each polynomial is of one degree
higher than the previous one.
At a quick glance, the above formula is obviously very similar to the formula for
D i y0
formula (3) as the stepsize Dx 0 . Clearly, the quantities in the polynomial
( D x )i
they do retain the uniform spacing. As all the interpolating points coalesce at x = x0 , we
see that the products of the various factors all converge toward ( x - x0 ) and so approach
start with the first two points ( x0 , y0 ) and ( x1 , y1 ) , which determine a line whose
algebraic representation can be written
y1- y0 Dy0
y = y0 + x1- x0 ( x - x0 ) = y0 + Dx ( x - x0 ).
5
Now suppose we also have the third point ( x2 , y2 ) . Unless the three points happen to be
collinear, which is highly unlikely, the line determined by the first two points will miss
the third point. In particular, if we extend that line until it reaches x = x2 = x0 + 2Dx , then
the height along the line is
Dy0 y1- y0 y1- y0
y = y0 + Dx ( x2 - x0 ) = y0 + Dx ( x0 + 2Dx - x0 ) = y0 + Dx (2Dx) = 2 y1 - y0 .
The question we pose is: How can we adapt the above linear function to create a
quadratic function that also passes through the third point? To do so, we want to
introduce a quadratic term that forces the entire quadratic function to pass through the
third point while maintaining the same two values y0 and y1 at x = x0 and x = x1 ,
respectively. To do this, we write the quadratic polynomial in the form
y1 - y0
y = y0 + Dx ( x - x0 ) + A( x - x0 )( x - x1 ).
where A is some constant to be determined. Notice that the presence of the factors
( x - x0 ) and ( x - x1 ) guarantee that the quadratic term has zero contribution at the first
Consequently,
2 A( Dx) 2 = y2 - 2( y1 - y0 ) - y0 = y2 - 2 y1 + y0 ,
and so
y2 - 2 y1 + y0
A= .
2( Dx) 2
Notice that the numerator y2 - 2 y1 + y0 is the second difference D 2 y0 = D y1 - D y0 .
Therefore, we write
D 2 y0
A=
2( Dx) 2
6
and
Dy0 D 2 y0
y = y0 + ( x - x0 ) + ( x - x0 )( x - x1 ).
Dx 2( Dx) 2
When doing this in class, we suggest asking the students to extend the argument
used to derive the cubic Newton interpolating formula.
Lets find the interpolating quadratic using the Newton interpolating formula for
the above example where the three interpolating points are (1, 2) , (3,8) , and (5, 4) . We
have
6 -10
P2 ( x) = 2 + ( x - 1) + ( x - 1)( x - 3)
2 2!22
5
= 2 + 3( x - 1) - ( x - 1)( x - 3).
4
7
Notice that the sum of the first two terms, P1 ( x) = 2 + 3( x - 1) , determines the linear
function that pass through the first two points (1, 2) and (3,8) . Figure 3 shows the
graphs of P1 ( x) and P2 ( x) . Lets include the graph of the quadratic term, denoted by
5
C2 ( x) = - ( x - 1)( x - 3) , to see how the quadratic term alone changes the interpolation
4
polynomial P1 ( x) based on the first two points into the interpolation polynomial P2 ( x)
based on all three points. Figure 4 shows that the quadratic component C2 ( x) has two
real zeros precisely in line vertically with the first two interpolating points. Therefore,
C2 ( x ) automatically contributes zero at x =1 and x=3 so that
P2 ( x) does not alter the perfect fit of the first two points by P1 ( x) . In addition, observe
that at x = 5 , the value of C2 (5) is the amount that bends the linear function P1 ( x) at
x = 5 in order for the P2 ( x) to pass through the third interpolating point (5, 4) .
(3, 8)
(5, 4)
(1, 2)
(3, 8)
Two vertical
segments with
(1, 2) equal length
(5, 4)
8
To better understand the process of finding the interpolating polynomial by using
Newton formula, we expand the data set of (1, 2) , (3,8) , and (5, 4) to include two
additional points (7, 2) , (9, 22) . These five points determine a quartic polynomial. We
show these successive Newton interpolating polynomials in Figure 5. Once again, notice
that the linear function passes through the first two points, though it completely misses all
the remaining points. The quadratic function passes through the first three points, but
then misses all the subsequent points. The cubic function passes through the first four
9
points, but comes nowhere near the final point. It is only the quartic function that passes
through all five points.
The approach used to introduce Newtons formula in many numerical analysis
texts tends to be rather abstract and, as such, conveys little in the way of understanding to
many students. Moreover, some texts give a somewhat misleading image of what is
actually happening; they tend to say something to the effect that, if you have n + 1
interpolating points, you usually need a polynomial of degree n to fit them, and any lower
degree polynomial misses the points. The derivation and examples used above actually
suggest that this is not exactly the truth. However, it is misleading to suggest that the
lower degree polynomials miss the points; they only miss the points further to the right.
. Lets interpolate the sine function at the five uniformly spaced points (0,0) , (p 2,1) ,
(p ,0) , (3p 2, -1) , and (2p ,1) . Just as we did earlier, we construct the successive
Newton interpolating polynomials, shown in Figure 6. Notice that the quadratic
interpolating polynomial P2 ( x) fits the sine function reasonably well on the interval
[0, p ] . As expected, the quadratic polynomial P2 ( x) misses all the points on the right.
The cubic polynomial P3 ( x) and quartic polynomial P4 ( x) are identical because the
fourth difference D 4 y0 is zero. This is the advantage of using the Newton formula that
determines the degree of the interpolating polynomial as we construct it. Had we
10
Figure 6: Successive Newton interpolating
polynomials for the sine function
used the Lagrange formula, we would only learn the degree of the interpolating
x3
T3 ( x ) = x - , is shown in Figure 7 along with the sine function and cubic interpolating
3!
polynomial. We see that the Taylor approximation achieves high accuracy between x = 0
and roughly x = p 2 , then the difference between the cubic Taylor polynomial and the
sine function grows significantly as x moves to the right beyond x = p 2 . Clearly, the
interpolating polynomial gives us a better approximation of a function on a larger interval
compared with the Taylor approximation.
11
Figure 7: Cubic Taylor polynomial and cubic interpolating polynomial
of the sine function
Comparisons Between Lagrange and Newton Interpolation The Lagrange and
Newton interpolating formulas provide two different forms for an interpolating
polynomial, even though the interpolating polynomial is unique. When we want a quick
symbolic expression of the interpolating polynomial, the Lagrange formula seems to be
the way to go. For this reason, the Lagrange form is most often used for deriving
formulas for approximating derivatives and integrals. For example, many numerical
analysis textbooks (for example, [1] and [2]) establish the trapezoidal rule and Simpsons
rule by using the Lagrange formula for linear and quadratic interpolating polynomials to
approximate the integrand, respectively. However, the Newton formula is much better
for computation than the Lagrange formula.
When using the interpolating polynomials for working with functions that are
stored in tabular form, we often choose the Newton formula. As we will show below, the
forward differences D n y0 that determine the coefficients of the Newton formula can be
easily constructed using a tabular form. More importantly, the Newton formula provides
a generally accurate idea of when the degree n is sufficiently large by observing the size
of the terms with higher-order forward differences. This is a useful technique in deciding
what degree polynomial to use.
Suppose we are given five points (2.0, 1.414214) , (2.1, 1.449138) ,
(2.2, 1.483240) , (2.3, 1.516575) , and (2.4, 1.549193) , which is based on an example in
[1]. We construct the forward difference table for these five points, shown in Table 1.
12
2 2.2 1.483240 0.033335 0.000717
3 2.3 1.516575 0.032618
4 2.4 1.549193
The last five entries in the first row are used to determine the coefficients of the Newton
interpolating polynomial
P4 ( x) = 1.414214 + 0.34924( x - 2.0) - 0.041( x - 2.0)( x - 2.1)
+ 0.009167( x - 2.0)( x - 2.1)( x - 2.2) - 0.002083( x - 2.0)( x - 2.1)( x - 2.2)( x - 2.3).
By applying the usual optimization approach from Calculus I to the fourth degree
polynomial term
-0.002083( x - 2.0)( x - 2.1)( x - 2.2)( x - 2.3)
Then the largest possible value the last term of P4 ( x) that will contribute to the
0.002083 0.0024 5 10 -6 .
This result may be improved on by following a common practice used in
approximating functions with the Newton formula. When we want to approximate the
function at a point x that is inside the first half of the interval, we use the above Newton
forward formula. Otherwise we use the Newton backward formula, or equivalently, we
apply the Newton forward formula to the same table where the entries are listed in
reverse order. If we stay with the original notation for the interpolating points ( xi , yi ) for
2 yn =
( yn ) = yn - yn -1 = yn - 2 yn -1 + yn -2 , and in general,
13
yn 2 yn 3 yn
Pn ( x) = yn + ( x - xn ) + ( x - xn )( x - x n -1 ) + ( x - xn )( x - xn -1)( x - xn - 2 ) +
Dx 2!( D x) 2 3!( D x)3
n yn
L + ( x - xn )( x - xn -1 )L ( x - x1 ).
n !(D x) n
Assume that we want to approximate the function between 2.0 and 2.2, the first
half of the interval [2.0, 2.4] . Now the maximum value of the last term of P4 ( x) on
[2.0, 2.2] is only about 2 10-7 . Since our data points are given to decimal places, the
Newton forward formula of order greater than three wont increase the accuracy of the
approximation for x in the interval [2.0, 2.2] . Therefore, we have achieved the desired
level of accuracy by using polynomials of degree three (or even lower). Table 2 gives the
confirm the above observation. A similar analysis can be given to the approximation of
the function between 2.2 and 2.4 using the Newton backward formula. We present the
results of approximations of f (2.24) , f (2.31) , and f (2.37) using Newton backward
formula in Table 3.
14
P3 ( x)
everything. This makes Lagrange interpolation less convenient for seeking the lowest
degree interpolating polynomial that fits the data with a given error tolerance.
Interpolation and Regression From time to time, we may have a large set of data. If
we have n + 1 points (where n is large), the interpolating polynomial is of the degree n ,
presuming that the points do not fall onto a polynomial of lower degree. This high degree
polynomial is an exact match to the data points, but can be a very poor match between
those points. This can happen because the polynomial may change direction up to n - 1
times. In the process, the interpolating polynomial may shoot way up or down after
passing through each interpolating point in order to reach the next turning point to come
back down/up to hit the next interpolating point. We illustrate such a case in Figure 8
where the interpolating points are (0, 5) , (1, 9) , (2, - 10) , (3, 40) , (4, 5) , (5, 50) and
(6, 29) . The problematic portions of the interpolating polynomial are between the first
two interpolating points and between the last two interpolating points. Such an
oscillatory behavior may dramatically affect the accuracy of approximation between
interpolating points and make the approximation very sensitive to any changes of the
interpolating points. Moreover, there is likely a high computational cost of using the
interpolating function. If we opt for a lower degree polynomial by using the method we
discussed above, we will have to constantly get back to the data to select a subset of
interpolating points according to the value of x of interest in order to get a good
approximation.
References:
[1] Atkinson, K. 1988. An Introduction to Numerical Analysis, 2nd Ed. New York: John
Wiley & Sons.
[2] Burden, R. and Faires, J. 2010. Numerical Analysis, 9th Ed. Boston: Brooks/Cole.
[3] Hamming, R. 1987. Numerical Methods for Scientists and Engineers, 2nd Ed. New
York: Dover Publications.
------------------------------------------------------------------------------------------------------------
Abstract This article takes a close look at Lagrange and Newton interpolation by
examining graphically the components of each of these formulas. While interpolation
methods are too often considered simply as computational procedures, we demonstrate
how hope that our emphasis on the components of the polynomial terms in these formulas
provides much in the way of insight into where these formulas came from, why they
work, and how they should be used.
16
Keywords interpolating polynomial, Lagrange formula, Newton formula, Taylor
polynomial
Suggested Running Head Components of Lagrange and Newton Interpolation
17