2.1.Polynomial interpolation¶
The United States carries out a census of its population every 10 years. Suppose we want to know the population at times in between the census years, or to estimate future populations. One technique is to find a polynomial that passes through all the data points.[1]
As posed in Definition 2.1.1, the polynomial interpolation problem has a unique solution. Once the interpolating polynomial is found, it can be evaluated anywhere to estimate or predict values.
2.1.1Interpolation as a linear system¶
Given data for , we seek a polynomial
such that for all . These conditions are used to determine the coefficients :
These equations form a linear system for the coefficients :
or more simply, . The matrix is of a special type.
Polynomial interpolation can therefore be posed as a linear system of equations with a Vandermonde matrix.
# Choose 500 times in the interval [0,35].
tt = range(0, 35, 500)
# Evaluate the polynomial at all the vector components.
yy = p.(tt)
foreach(println, yy[1:4])962.2387878787875
963.9282039963299
965.6118068288089
967.2896105457506
Now we use plot! to add to the current plot, rather than replacing it.
Tip
The plot function plots lines connecting the given and values; you can also specify markers at the points.
By convention, functions whose names end with the bang ! change the value or state of something, in addition to possibly returning output.
plot!(tt, yy, label="interpolant")
::::{aside}
:::{div}
:width: 100%
```{iframe} https://cdnapisec.kaltura.com/p/2358381/embedPlaykitJs/uiconf_id/57659783?iframeembed=true&entry_id=1_itrr356e&config%5Bprovider%5D=%7B%22widgetId%22%3A%221_r1yqhz87%22%7D&config%5Bplayback%5D=%7B%22startTime%22%3A0%7D
```
:::
2.1.2Exercises¶
We’re quite certain that the U.S. Census Bureau uses more sophisticated modeling techniques than the one we present here!