The Art of Polynomial Interpolation
The Art of Polynomial Interpolation
The Art of Polynomial Interpolation
STUART MURPHY
The Art of Polynomial Interpolation by Stuart Murphy is licensed under a Creative
Commons Attribution-NonCommercial 4.0 International License, except where
otherwise noted.
Contents
Introduction 1
Techniques 4
Acknowledgements
Introduction | 1
interpolation and I encourage students who are interested to check
them out.
It is not a lesson in using interpolation apps:
Quite the opposite. By engaging in exercising calculations, the
student is better equipped to understand how and why these
techniques work.
What is polynomial interpolation?
We experience information in discreet ways.
Typically, it comes from measurements or observations. However,
what we often want to do is look at a continuous process the data
represents; all at once or at least at any point we choose. While
we cannot represent a continuous process with a single number
we can do so with an equation. Graphically this equation could be
a single point (not usually that interesting). A straight line (degree
one polynomial), a curved line (degree two polynomial) that we often
call a quadratic equation or parabola; or some higher degree that
graphically, often begins to look like a wave repeating itself.
When dealing with data the specific numbers always represent
a snapshot. For example, if we measure rainfall and wind speed each
day for a year, we have a collection of data points that compare
rainfall to wind speed. We might ask if there is a relationship
between wind speed and rainfall. For example, hurricane force
winds are usually accompanied by heavy rainfall. It would be nice
to develop an equation that can predict rainfall when high winds
are expected. Normally someone analyzing this data would plot the
points on the x, y coordinate plane. In this text, the sample data used
to illustrate the various interpolation methods will be plotted in this
way.
Can the math stand alone? Most certainly not. The challenge
for someone utilizing interpolation techniques is to apply expertise
and experience to determine the most appropriate polynomial
structure. In other words, is the model most likely to accurately (or
at least reasonably) produce useful estimated values? This is what I
mean by the “Art” of polynomial interpolation.
Interpolation uses a known set of independent and dependent
2 | Introduction
values to estimate other dependent values, typically along a
continuous line represented by a polynomial. Technically if you use
the model to identify additional data points outside of the range of
the given points this is known as extrapolation. Our focus will be on
interpolation within the given range.
Adaptations of the techniques we explore have been used in pre-
computer times to generate tables of trig or log values used in
applications such as navigation. Nowadays they are adapted for use
by computers and calculators and they are an important part of the
tool kit researchers use to predict future events such as emerging
storms tracks, climate change, political elections, changing
demographics, spread of disease, and so forth.
We will explore five Interpolation techniques: Elimination
(Substitution), Newton’s Divided Difference, Splines, Least Squares
and Taylor Series.
Introduction | 3
Techniques
4 | Techniques
C) Splines
Techniques | 5
Note there are plenty of applications that will provide the desired
results very quickly. However, this textbook is meant to assist
students with an understanding of the computations and reasons
for them. Included are the manual calculations with explanation as
well as basic Matrix commands that students can use to mirror the
manual calculations.
Let’s look at a simple example.
Assumption: The faster a car is driven the lower the fuel
efficiency.
75 32
Long Description
6 | Techniques
Figure 1 – Comparing Linear to Quadratic Interpolation Methods
Long Description
The above plot suggests two likely scenarios. The question is:
Which more accurately represents what is really happening?
Linear: Pick two points that seem reasonable and draw a straight
line (red) through them.
Quadratic: Someone else looking at the data might conclude the
curved line (blue) is more reasonable and accurate.
Visually we would conclude that the quadratic is mathematically
Techniques | 7
a better fit because the curve is significantly closer to the given
data points. However, it is important to remember that while this is
true, an automotive expert applying expertise and experience may
conclude that in fact the linear interpolation is more meaningful
or that more data points are needed. We want to keep in mind
that the “Art” component is what has to be applied to determine
what degree polynomial and which technique will provide the best
approximation.
8 | Techniques
Chapter One - Elimination
(Substitution) Interpolation
A common method for solving the resulting system of equations
is using linear algebra and matrix math. However, neither are
necessary to illustrate this technique and apply to a practical
problem. We will use elimination to solve the example below. While
I think it is important students experience how basic algebra works
for interpolation, they will quickly see that unless the numbers
are small and simple this particular technique quickly becomes
unwieldy for large values generated during the process.
For example:
55 42
65 38
75 32
Long Description
Step Three: Lets create three quadratic equations with the same
three unknowns a, b, c and replacing x, y in each with the actual data
point values.
Eq. one: ———–>
______________________
For students looking for a less manual process here is the setup
using matrix math to run the calculations in a spreadsheet.
Long Description
1a)
50 $22 $1100
100 $15 $1500
Long Description
1b)
x y or f(x)
-4 12
[-1.75] [-2]
[1] [-3.7]
[3.3] [-1.4]
[6.9] [4]
7 3.9
9.1 6
Long Description
1c)
Select any three data points from the above table and develop a 2nd
degree (quadratic) Polynomial.
Example
x y
-2 25.2
-1 11.3
0 2
1 -2.7
2 -2.8
Long Description
Sample Data
Solution
Long Description
Since the 2nd divided differences are all the same this tells us that
there is a quadratic solution
with
By plugging in the x,y values (0,2) we can easily solve for c as
follows:
.
.
.
x f(x)
-2 3
Long Description
x f(x)
-2 3
-1 -4
Long Description
x f(x)
-2 3
-1 -4
3 6
Long Description
this component (in red) ensures this new solution works for
previous points as well as establishing a valid quadratic form.
Remember
CheckTwo
solve for
quadratic
Each new iteration builds upon and preserves the previous
solutions.
In general, the solution polynomial can continue to be increased
one degree at a time solving for each new variable as long as
additional points become available. This results in the following
general form:
Long Description
Long Description
Long Description
Long Description
2a)
While the owner in exercise 1a) was happy with the results of using
elimination/substitution, she was curious to see if the results would
differ using Newton’s Divided Difference (NDD) interpolation. You
have decided to assist her by generating a cubic polynomial using
NDD. (Solution given) The data is:
25 $28 $700
50 $22 $1100
2b)
Using the same seven data points from the previous chapter select
three data points and plug into the grid below to produce a
quadratic solution. Simplify the resulting polynomial and put in
standard form. Note solution given for the three bracketed points.
(Solution given)
x y or f(x)
-6.2 -8
[-3] [-7]
-1.5 -2.2
[1] [0.7]
3.5 3
4.25 5
[7.9] [11]
- -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
Long Description
Spline Example
Long Description
We now have four equations. The fifth equation we can develop
at the point (5,8) known as an internal knot. Note the two endpoints
are sometimes referred to as external knots.
If we take the derivative of the two equations at , we know
they have to be equal because the slope has to be the same at that
point. We can set them equal to each other and simplify. This results
in:
Rearrange
This is the sixth equation; see explanation below.
The sixth equation is based on the assumption that the line
leaving the endpoint is a straight line. The quadratic component
zeros out thus our sixth equation is simply . The other
endpoint would have produced which would have worked
equally well. We’ll use these six equations and solve with matrix
operations.
a1 b1 c1 a2 b2 c2 y
4 2 1 0 0 0 1
25 5 1 0 0 0 8
0 0 0 25 5 1 8
0 0 0 49 7 1 3
10 1 0 -2 -10 0 0
1 0 0 0 0 0 0
Long Description
Long Description
3 9.2
4 10
5 12
6 14.5
7 17
8 20
8.75 23
9 23.5
10 24
11 25.5
11.25 25.9
11.5 25.9
x y Interval
1 2 start of first interval
2.5 9 1st stage separation
We want to solve for the unknowns. However, with only
three equations we need to create six additional equations in order
to apply one of the standard techniques for solving n equations in n
unknowns.
Notice that each equation is a solution for two of the knots as
shown in figure 1. This allows us to split each spline equation into
two equations providing a total of n= 6 equations as follows:
at
the
seventh equation
at
Long Description
1 1 1 0 0 0 0 0 0 a1 2
6.25 2.5 1 0 0 0 0 0 0 b1 9
0 0 0 6.25 2.5 1 0 0 0 c1 9
0 0 0 76.56 8.75 1 0 0 0 a2 23
0 0 0 0 0 0 76.56 8.75 1 b2 23
0 0 0 0 0 0 126.56 11.25 1 c1 25.9
5 1 0 -5 -1 0 0 0 0 a3 0
0 0 0 17.5 1 0 -17.5 -1 0 b3 0
1 0 0 0 0 0 0 0 0 c3 0
Long Description
Long Description
2.5 9
3 9.2
4 10
5 12
6 14.5
7 17
8 20
8.75 23
9 23.5
10 24
11 25.5
11.25 25.9
11.5 25.9
6 14.5
7 17
Long Description
Resulting Equation
for
the interval
Let’s see how well our cubic polynomial fits when plotted against
all the given points plus x = 5.85
Long Description
3a)
Using the data from the Saturn launch example in chapter three
calculate the family of quadratic splines for the following different
Selected Interval Data Points (knots) and compare to the example.
1 2
2.5 9
3 9.2
4 10
5 12
6 14.5
7 17
8 20
8.75 23
9 23.5
10 24
11 25.5
11.25 25.9
11.5 25.9
x y Interval
3b)
Using the table in 3a) for time = 7.5, conduct a Direct Method Cubic
Interpolation. Show the resulting polynomial in standard form and
graph the solution manually or with your favorite graphing tool.
(Solution given)
Scenario
3 5
4 5
5 4
Long Description
1)
Simplify 1)
Simplify 2)
One:
Two:
II)
Rearrange:
One: 55a +
15b = 63
Two: 15a +
5b = 19
III) Apply
substitution
/elimination
to solve for a,
b
We now
have a
polynomial
that can
interpolate
or
Long Description
a —>
b —>
Additional sums:
Rearranging
Long Description
Long Description
4a)
Use weekly closing data for the Dow Jones Industrial Average and
run a Least Squares Regression to produce a 3rd degree (cubic)
interpolation polynomial. Plot the data on a chart for a visual
representation. Solution given uses data from January 2020
through July 2021, during height of the COVID-19 pandemic.
(Solution given)
Shown in
green above. The closer the predicted value is from the actual value
and the farther it is from the mean value, the better our prediction.
Using the data above we will conduct a (Squared Regression)
analysis to gauge numerically how well the linear and quadratic
polynomials fit the data.
1 2 2.6 0.36
2 3 3.2 0.04
3 5 3.8 1.44
4 5 4.4 0.36
5 4 5 1
- - -
- - -
The value of 53% suggests that this may not be the best fit.
To
Difference between actual di
Generated y values and generated squared: be
x y an
1 2 1.7428 0.06615184 3.
2 3 3.6284 0.39488656 0.
3 5 4.6568 0.11778624 1.4
- - -
Long Description
Let’s use the following sample set of data points and use Matrix
math to develop the interpolated data:
Interpolated Data
x actual y Iny
-1 0.4 -0.916
0 1.1 0.095
1 2.62 0.963
2 8.1 2.092
3 24.03 3.179
4 57.9 4.059
Long Description
Long Description
5a)
Measure the accuracy of the Fit from Exercise 4a, i.e. find .
(Solution given)
Long Description
Long Description
Long Description
...
From here we will develop the general form of the Taylor series
employing basic algebra.
This is done iteratively by solving one constant at a time. We set
since in fact all Taylor polynomials either start with
or include the adjustment, so that in effect the center will
always equal zero.
We will solve for a fourth-degree polynomial. This will be enough
to demonstrate the general pattern of the Taylor series. To solve
for each constant, we replace each of the with as
follows:
since
since we’re left with
...
Since every other term has zero in the numerator we can drop
these and condense p(0). Further since a = 0, we can simplify the
binomials.
The resulting Taylor Series polynomial is:
\large p(0) = \frac {1}{1!}(x) + \frac {-1}{3!}(x)^3 + \frac
{1}{5!}(x)^5 + \frac {-1}{7!}(x)^7 + \frac {1}{9!}(x)^9
We have a relatively simple polynomial we can program into our
app to produce values of sin for angles between 0 and 90 degrees .
Since sin is periodic, we can program in computations that give us
the reference angle for angles greater than 90 or less than 0 degrees
.
Step Five: We are now ready to test p(a) for various angles
between 0 and 90 degrees. Since it is easier to work with Radians,
I’ve included a conversion for students not familiar with them. f(x)
is generated from an app precise to 15 decimal positions. p(x) is our
Taylor approximation.
18 0.309016994374947 0.309016994375021
30 0.500000000000000 0.500000000000000
45 0.707106781186547 0.707106782936867
72 0.951056516295154 0.951056822327524
90 1.000000000000000 1.000003542584290
Long Description
6a)
Replicate the above example (sin) for the cos. Compare the resulting
graph to the one for sin.
(Solution given)
where c is
between a and x
The question we ask is what value for c should we use. The answer
in this case is to solve the remainder twice for the endpoints of
the range we are interested in. In this case we want to know how
For
7a)
Exercise 1a)
a b c d cost
1000 100 10 1 37
15625 625 25 1 28
125000 2500 50 1 22
1000000 10000 100 1 15
Long Description
2a)
Linear Quadratic
x y
10 37 37 - -
- - - -
25 28 28 -
- - - -
50 22 22 -
- - - -
100 15 15 - -
Simplifies to:
2b Table
x y or f(x)
-6.2 -8
-3 -7
-1.5 -2.2
1 0.7
3.5 3
4.25 5
7.9 8
-3 -7 - -
- - -
1 0.7 -
- - -
7.9 11 - -
2
Simplifies to: -0.040x + 1.845x – 1.105
Exercise 3b)
Long Description
4a)
The Setup:
Abbreviated List of weekly Dow Jones closing averages:
- - - - - - -
- - - - - - -
- - - - - - -
78 34,292.29 474,552.00 6,084.00 78.00 1 34,491.0287
Long Description
Long Description
Step One:
1a) Find the difference between each actual value and its
associated value generated by the interpolative polynomial. Square
the result.
1b) Find the difference between each actual value and the Mean of
the actual values. Square the result.
Step Two:
2a) Sum the results from 1a
2b) Sum the results from 1b
Step Three:
Divide 2a by 2b subtracting the result from 1.
Answer:
6a)
Every other term has zero in the numerator so we can drop these
and condense p(0). Further since a = 0 we can simplify the binomials.
18 0.951056516295154 0.951056516297732
30 0.866025403784439 0.866025404210352
45 0.707106781186548 0.707106805683294
72 0.309016994374947 0.309019668329804
90 0.000000000000000 0.000000000000000
7a)
where c is
between a and x
for
for
Acknowledgements | 109
About the Author