3 Polynomial approximations - exact data
Here and in subsections 4 and 5 we consider cases where, rather than knowing an expression for the function, we have a list of point values. Sometimes it is good enough to find a polynomial that passes near these points (like putting a straight line through experimental data). Such a polynomial is an approximating polynomial and this case follows in subsection 4. Here and in subsection 5 we deal with the case where we want a polynomial to pass exactly through the given data, that is, an interpolating polynomial .
3.1 Lagrange interpolation
Suppose that we know (or choose to sample) a function exactly at a few points and that we want to approximate how the function behaves between those points. In its simplest form this is equivalent to a dot-to-dot puzzle (see Figure 1(a)), but it is often more desirable to seek a curve that does not have“corners" in it (see Figure 1(b)).
Figure 1 :
Let us suppose that the data are in the form , , , …, these are the points plotted as crosses on the diagrams above. (For technical reasons, and those of common sense, we suppose that the -values in the data are all distinct.)
Our aim is to find a polynomial which passes exactly through the given data points. We want to find such that
There is a mathematical trick we can use to achieve this. We define Lagrange polynomials , , , which have the following properties:
Each of these functions acts like a filter which “turns off" if you evaluate it at a data point other than its own. For example if you evaluate at any data point other than , you will get zero.
Furthermore, if you evaluate any of these Lagrange polynomials at its own data point, the value you get is 1. These two properties are enough to be able to write down what must be:
and this does work, because if we evaluate at one of the data points, let us take for example, then
as required. The filtering property of the Lagrange polynomials picks out exactly the right -value for the current -value. Between the data points, the expression for above will give a smooth polynomial curve.
This is all very well as long as we can work out what the Lagrange polynomials are. It is not hard to check that the following definitions have the right properties.
Key Point 1
Lagrange Polynomials
and so on.
The numerator of does not contain
The denominator of does not contain
In each case the numerator ensures that the filtering property is in place, that is that the functions switch off at data points other than their own. The denominators make sure that the value taken at the remaining data point is equal to 1.
Figure 2
Figure 2 shows and in the case where there are five data points (the positions of these data points are shown as large dots). Notice how both and are equal to zero at four of the data points and that and .
In an implementation of this idea, things are simplified by the fact that we do not generally require an expression for . (This is good news, for imagine trying to multiply out all the algebra in the expressions for , , ….) What we do generally require is evaluated at some specific value. The following Example should help show how this can be done.
Example 3
Let be the polynomial of degree 3 which interpolates the data
Evaluate .
Solution
We are interested in the Lagrange polynomials at the point so we consider
Similar calculations for the other Lagrange polynomials give
and we find that our interpolated polynomial, evaluated at is
Key Point 2
Quote the answer only to the same number of decimal places as the given data (or to less places).
Task!
Let be the polynomial of degree 3 which interpolates the data
Evaluate .
We are interested in the Lagrange polynomials at the point so we consider
Similar calculations for the other Lagrange polynomials give
and we find that our interpolated polynomial, evaluated at is
The next Example is very much the same as Example 3 and the Task above. Try not to let the specific application, and the slight change of notation, confuse you.
Example 4
A designer wants a curve on a diagram he is preparing to pass through the points
He decides to do this by using an interpolating polynomial . What is the -value corresponding to ?
Solution
We are interested in the Lagrange polynomials at the point so we consider
Similar calculations for the other Lagrange polynomials give
and we find that our interpolated polynomial, evaluated at is
In this next Task there are five points to interpolate. It therefore takes a polynomial of degree 4 to interpolate the data and this means we must use five Lagrange polynomials.
Task!
The hull drag of a racing yacht as a function of the hull speed, , is known to be
(Here, the units for and are N and , respectively.)
Use Lagrange interpolation to fit this data and hence approximate the drag corresponding to a hull speed of .
We are interested in the Lagrange polynomials at the point so we consider
Similar calculations for the other Lagrange polynomials give
and we find that our interpolated polynomial, evaluated at is
This gives us the approximation that the hull drag on the yacht at is about 1100 N.
The following Example has time as the independent variable, and two quantities, and , as dependent variables to be interpolated. We will see however that exactly the same approach as before works.
Example 5
An animator working on a computer generated cartoon has decided that her main character’s right index finger should pass through the following positions on the screen at the following times
Use Lagrange polynomials to interpolate these data and hence find the position at time . Give and to 2 decimal places.
Solution
In this case is the independent variable, and there are two dependent variables: and . We are interested in the Lagrange polynomials at the time so we consider
Similar calculations for the other Lagrange polynomials give
These values for the Lagrange polynomials can be used for both of the interpolations we need to do. For the -value we obtain
and for the value we get
3.2 Error in Lagrange interpolation
When using Lagrange interpolation through points the error, in the estimate of is given by
where
N.B. The value of is not known precisely, only the interval in which it lies. Normally will lie in the interval (that’s interpolation ). If lies outside the interval then that’s called extrapolation and a larger error is likely.
Of course we will not normally know what is (indeed no may exist for experimental data). However, sometimes can at least be estimated. In the following (somewhat artificial) example we will be told and use it to check that the above error formula is reasonable.
Example 6
In an experiment to determine the relationship between power gain ( ) and power output ( ) in an amplifier, the following data were recorded.
5 | 7 | 8 | 11 | |
0.00 | 1.46 | 2.04 | 3.42 | |
- Use Lagrange interpolation to fit an appropriate quadratic, , to estimate the gain when the output is 6.5. Give your answer to an appropriate accuracy.
- Given that show that the actual error which occurred in the Lagrange interpolation in 1. lies withing the theoretical error limits.
Solution
- For a quadratic, , we need to fit three points and those most appropriate (nearest ) are for at :
-
We use the error formula
Here and :
So .
Substituting for :
Taking :
Taking :
The theory is satisfied because .
Task!
-
Use Lagrange interpolation to estimate
to appropriate accuracy given the table of values below, by means of the appropriate
cubic interpolating polynomial
2 5 7 9 10 0.980067 0.8775836 0.764842 0.621610 0.540302 The most appropriate cubic passes through at
Suitable accuracy is (rounded to d.p.).
-
Given that the table in 1. represents
,
calculate theoretical bounds for the estimate obtained:
This leads to
We can conclude that the True Value is or to d.p. or to d.p. (actual value is ).