Visualizing Interpolation

Visualizing the Error of Approximation
of Interpolating Polynomials
We consider a few actual examples, showing the function,
the interval, and the number of subdivision of the interval
into equal parts. For some the approximations are very,
very good, but others the approximations are poor.
All calculations and plots were generated with Maple.
Mathematical text was generated with Scientific Notebook.
©2013 G. Donald Allen
The Set Up
Interpolation of functions at given abscissas, x i , i  0. . n. In
this movie we suppose the data has the form
x i , fx i , i  0. . n
for some given function fxthat is n 1—times continuously
differentiable over some interval containing the x-values. The interval
under study is 
a, b
.
TheQuestion
A natural question to ask is this: if p n xis the interpolating polynomial
for this data, and x is given, can we estimate the difference
|fxp n x|
We call this the error of approximation at x. It is natural to expect
this error to depend on at least three factors
Error Dependency
We call this the error of approximation at x. It is natural to expect
this error to depend on at least three factors.
 The given nodes, x_i, i 0. . n. We assume x 0 a and
x n  b, and the other values are increasing from a to b.
 The selected value of x.
 Properties of the function fx
The Basic Theorem
For example, it seems reasonable to expect the further the value x is
from the nodes, x i , i 0. . n, the greater the error of approximation
might be. Or, the more the function oscillates, the less representative of
the function the data x i , fx i , i 0. . nwill be and hence the
greater the error of approximation.
There is a fundamental theorem here, that tells all provided
the function has enough continuous derivative. So, it will
not apply to functions with corners, such as the absolute
value function.
The Basic Theorem
Assume that fxis continuous on the interval 
a, band
n 1times continuously differentiable over a, b, and that the
nodes x i , i  0. . n are in 
a, b
. Let p n xbe the unique polynomial
of degree  n that interpolates the data x i , fx i , i  0. . n. Let x
be some fixed value in 
a, b
. Then there is a value in the smallest
interval I that contains the points x, x 0 , x 1 , , x n for which
f n1
x x 0 x x 1 x x n 
fxp n x
n 1!
where f n1xdenotes the n 1st derivative of fx.
We need to estimate the right side of this inequality.
Estimating
Equally spaced points. Let us assume the points a  x 0 ,  , x n  b
a
are equally spaced with spacing h  b
n . Then it is easy to see that if
x is between x 0 and x n we have
|x x 0 x x 1 x x n |  n!h  n! b a
n
n
though tighter estimates are possible.
n
Hence
f n1
n! b a
|fxp n x| 
n
n 1!
 max f n1 b a
n
n
n
1
n 1
The maximum is taken over the interval containing x, a, and b. So,
estimating the error of approximation really depends on the magnitude
of the n 1st derivative of the original function. Making this
estimate is difficult, except in very simple cases. In the slides below
we’ll show just how well equally spaced interpolants approximate
various functions.
Note
It actually turns out that using equally spaced points is not
necessarily the best strategy for interpolation.
It may also be that using a polynomial of high degree is
not the best method for interpolation. A powerful
competitor is the spline.
We save these topics for another day.
Examples
•
•
•
•
We show the function f(x)
The interval [a,b]
The values of n.
Graphs of the function and interpolants.
Examples
fx sin x,



,
,
n 4
Original function in blue
Interpolant in red
fx sin x,



,
,
n 8
Note, the interpolant is so
accurate, there is no apparent
blue image.
The higher derivatives
For the previous example, look at the higher derivatives
divided by n! As you can see they are bounded. This
means we have good control of the error.
Example
fx e x sinx



,
,
n 4
Original function in blue
Interpolant in red
fx e x sinx



,
,
n 8
Note, the interpolant is so accurate,
there is no apparent blue image.
Example
fx 1/1 4x 2 

3, 3
,
n 6
fx 1/1 4x 2 

3, 3
n  12
Note, the interpolant is not accurate at
all, and apparently becoming more
inaccurate near the endpoints.
The higher derivatives
For the previous example, look at the
higher derivatives divided by n! – up
to n=12. As you can see they are
wild and going unbounded. This
implies there may be little control of
the error of approximation.
Below is the 12th derivative – messy!
Example
fx |x |

3, 3
n  12
fx |x |

3, 3
n  24
Very poor behavior near the endpoints. This
function is not differentiable at zero. Thus we have
little knowledge of the error on the basis of our
theorem.