Fig 1. Initial data points
· Cubic spline interpolation
Fig 2. Plot of the data with linear interpolation superimposed
Generally, if we have data points, there is exactly one polynomial of degree at most going through all the data points. The interpolation error is proportional to the distance between the data points to the power n. Furthermore, the interpolant is a polynomial and thus infinitely differentiable. So, we see that polynomial interpolation solves all the problems of linear interpolation.
However, polynomial interpolation also has some disadvantages. Calculating the interpolating polynomial is computationaly expensive compared to linear interpolation. Furthermore, polynomial interpolation may not be so exact after all, especially at the end points. These disadvantages can be avoided by using spline interpolation.
Example of construction of polynomial by least square method
Data is given by the table:
Polynomial is given by the model:
In order to find the optimal parameters the following substitution is being executed:
, , …,
Then:
The error function:
It is necessary to find parameters , which provide minimums to function :
It should be noted that the matrix must be nonsingular matrix.
For the given data points matrix become singular, and it makes impossible to construct polynomial with order, where - number of data points, so we will use polynomial
Fig 3. Plot of the data with polynomial interpolation superimposed
Because the polynomial is forced to intercept every point, it weaves up and down.
Fig 4. Plot of the data with Lagrange interpolating polynomial interpolation superimposed
One can see, that Lagrange polynomial has a lot of oscillations due to the high order if polynomial.
1.2.4 Cubic spline interpolation
Remember that linear interpolation uses a linear function for each of intervals . Spline interpolation uses low-degree polynomials in each of the intervals, and chooses the polynomial pieces such that they fit smoothly together. The resulting function is called a spline. For instance, the natural cubic spline is piecewise cubic and twice continuously differentiable. Furthermore, its second derivative is zero at the end points.
Like polynomial interpolation, spline interpolation incurs a smaller error than linear interpolation and the interpolant is smoother. However, the interpolant is easier to evaluate than the high-degree polynomials used in polynomial interpolation. It also does not suffer from Runge's phenomenon.
Fig 5. Plot of the data with Lagrange interpolating polynomial interpolation superimposed
It should be noted that cubic spline curve looks like metal ruler fixed in the nodal points, one can see that such interpolation method could not be used for modeling sudden data points jumps.
Linear interpolation
Least squares interpolation
Lagrange polynomial
Cubic spline
Root mean square
0.148
0.209
0.015
0.14
0.146
0.678
0.664
0.612
0.641
0.649
1.569
1.649
1.479
1.562
1.566
Table 1. Results of interpolation by different methods in the given points.
In order to determine the best interpolation method for the current case should be constructed the table of deviation between interpolation results and root mean square, if number of interpolations methods increases then value of RMS become closer to the true value.
Average deviation from the RMS
Table 2. Table of Average deviation between average deviation and interpolation results.
One can see that cubic spline interpolation gives the best results among discussed methods, but it should be noted that sometimes cubic spline gives wrong interpolation, especially near the sudden function change. Also good interpolation results are provided by Linear interpolation method, but actually this method gives average values on each segment between values on it boundaries.