Section 4.2 Curve Fitting
¶Subsection 4.2.1 Interpolating Polynomials
¶Given two points in the plane, there is a unique line through them. Given three points in the plane, and not in a line, there is a unique parabola through them. Given four points in the plane, there is a unique polynomial, of degree 3 or less, passing through them. And so on. We can prove this result, and give a procedure for finding the polynomial with the help of Vandermonde matrices ((((section on vandermonde matrices)))).
Theorem 4.2.1. Interpolating Polynomial.
Suppose \(\setparts{(x_i,\,y_i)}{1\leq i\leq n+1}\) is a set of \(n+1\) points in the plane where the \(x\)-coordinates are all different. Then there is a unique polynomial of degree \(n\) or less, \(p(x)\text{,}\) such that \(p(x_i)=y_i\text{,}\) \(1\leq i\leq n+1\text{.}\)
Proof.
Write \(p(x)=a_0+a_1x+a_2x^2+\cdots+a_nx^n\text{.}\) To meet the conclusion of the theorem, we desire,
This is a system of \(n+1\) linear equations in the \(n+1\) variables \(a_0,\,a_1,\,a_2,\,\ldots,\,a_n\text{.}\) The vector of constants in this system is the vector containing the \(y\)-coordinates of the points. More importantly, the coefficient matrix is a Vandermonde matrix ((((definition-vandermonde)))) built from the \(x\)-coordinates \(\scalarlist{x}{n+1}\text{.}\) Since we have required that these scalars all be different, (((theorem-NVM))) tells us that the coefficient matrix is nonsingular and Theorem NMUS says the solution for the coefficients of the polynomial exists, and the solution is unique. As a practical matter, Theorem SNCM provides an expression for the solution.
Example 4.2.2. Polynomial through five points.
Suppose we have the following 5 points in the plane and we wish to pass a degree 4 polynomial through them.
\(i\) | 1 | 2 | 3 | 4 | 5 |
\(x_i\) | -3 | -1 | 2 | 3 | 6 |
\(y_i\) | 276 | 16 | 31 | 144 | 2319 |
The required system of equations has a coefficient matrix that is the Vandermonde matrix where row \(i\) is successive powers of \(x_i\)
Theorem NMUS provides a solution as
So the polynomial is \(p(x)=3 - 4x + 5x^2 - 2x^3 + 2x^4\text{.}\)
The unique polynomial passing through a set of points is known as the interpolating polynomial and it has many uses. Unfortunately, when confronted with data from an experiment the situation may not be so simple or clear cut. Read on.
Subsection 4.2.2 Fitting Curves Through Data
To construct an interpolating polynomial, we presumed we wanted a curve passing through a set of points exactly. Sometimes we have a similar, but distinctly different situation. We have a set of data points \(x_i\text{,}\) \(1\leq i\leq n\text{,}\) where the \(x_i\) are \(m\)-tuples. We have a model or a physical law which suggests that each \(m\)-tuple satisfies some linear equation with \(k\) unknown parameters. We wish to estimate the parameters. If we can formulate a linear system with the parameters as the variables, then we can use a least-squares estimate (Section Section 4.1). We illustrate with two examples.
Example 4.2.4. Fitting a Third Degree Polynomial.
Suppose we believe the twelve data points below are related by a degree three polynomial, \(y=p(x)=a_0+a_1x+a_2x^2+a_3x^3\text{.}\) We have four unknown parameters, the coefficients of the polynomial. For each point we can create a \(5\) tuple, \((1, x_i, x_i^2, x_i^3, y_i)\text{,}\) with entries that are related by the linear equation \(a_0+a_1x_i+a_2x_i^2+a_3x_i^3=y_i\text{.}\) So we have \(12\) linear equations in \(4\) variables. The coefficent matrix \(A\) has \(12\) rows and \(4\) columns, similar in spirit to a Vandermonde matrix (Section Section 5.1), though not even square. The vector of constants is the \(12\) values of \(y_i\text{.}\)
\(x_i\) | \(y_i\) |
0.142 | -10.867 |
0.645 | 10.120 |
0.953 | 8.1728 |
2.958 | 11.693 |
2.975 | 18.931 |
3.167 | 16.215 |
3.413 | 3.863 |
4.301 | -7.971 |
5.552 | -24.108 |
6.576 | -31.217 |
7.957 | 0.719 |
8.027 | 9.550 |
Here are the relevant pieces of the system, the normal equations, and the solution.
So the polynomial obtained from a least-squares fit is
With other models, it may be necessary to rearrange the equation to “linearize” it. For example, if the relationship between \(x\) and \(y\) is exponential and is given by \(y=ae^{bx}\) then applying the logarithm to both sides would yield \(\log(y)=\log(a) + bx\text{.}\) Then by using pairs \((x_i, \log(y_i))\text{,}\) a least-squares solution would provide estimates of \(\log(a)\) and \(b\text{,}\) which could be easily converted to estimates of \(a\) and \(b\text{.}\)