Estimating an equation from a series of values

71 Views Asked by At

Secondary school student here. I know we tend to get annoying on this site with fairly trivial questions and ignorance of rules, so feel free to educate me.

What mathematical system could I research to approximate (or find exactly) the equation (linear, quadratic, cubic or quartic; not higher) of a table of values? For example, taking x = 1,4,9,16,25 where y=n and approximating it.

This is obviously y=x^2; but what generic way is there of finding this equation? I was thinking perhaps treating it like a linear/quadratic/cubic/quartic nth term sequence, but I don't know how to first differentiate between the four polynomial degrees there and therefore which method to apply? I have searched around a bit on this forum and asked my teachers, who recommended something called Taylor Series, but I'm not sure it will do what I want it to

1

There are 1 best solutions below

0
On

Yurly S' comments about regression are what you want to use if you have a lot more points than the degree of your polynomial. But since you mentioned solving it exactly, let me discuss that. Determining the lowest degree polynomial that passes through a give set of points is called polynomial interpolation.

A polynomial of degree $n$ has $n+1$ coefficients. These are the unknowns you must determine. Each point the polynomial passes through provides an equation in those unknowns: $$y_0 = x_0^2a + x_0b+c$$ Since you have $n+1$ unknowns, it requires $n+1$ equations to determine them, and therefore $n+1$ points.

This is the first rule about what degree you want: The degree of the polynomial needs to be at most $1$ less than the number of points you have. If you have a higher degree polynomial than this, you will not be able to identify all the coefficients. There will be an infinite number of polynomials which pass through all your points.

If you want a polynomial that passes through each of your $n+1$ points (which must all have different $x$ values, otherwise it is impossible), then a straight-forward method is write out the $n+1$ equations for the points:

$$y_0 = x_0^2a + x_0b+c\\y_1 = x_1^2a + x_1b+c\\y_2 = x_2^2a + x_2b+c$$ Here, the $a, b, c$ are the unknowns, while the $x_i, y_i$ are known. You can rewrite this in matrix form:

$$\begin{bmatrix}y_0\\y_1\\y_2\end{bmatrix} = \begin{bmatrix}x_0^2&x_0&1\\x_1^2&x_1&1\\x_2^2&x_2&1\end{bmatrix}\begin{bmatrix}a\\b\\c\end{bmatrix}$$ Multiply both sides by the inverse of the square matrix, and you get $$\begin{bmatrix}x_0^2&x_0&1\\x_1^2&x_1&1\\x_2^2&x_2&1\end{bmatrix}^{-1}\begin{bmatrix}y_0\\y_1\\y_2\end{bmatrix} = \begin{bmatrix}a\\b\\c\end{bmatrix}$$

And thus you can calculate the needed coefficients $a, b, c$.

While inverting a 3x3 matrix isn't bad, the difficulty in doing so naively rises exponentially with the degree. Fortunately, there are simpler methods.

Consider the polynomial $$P_0(x) = \frac{(x-x_1)(x-x_2)}{(x_0-x_1)(x_0-x_2)}$$ Note that $P_0(x_0) = 1$, but $P_0(x_1) = P_0(x_2) = 0$. If we similarly construct $P_1(x)$ and $P_2(x)$, then the unique quadratic passing through $(x_0, y_0), (x_1, y_1), (x_2, y_2)$ has to be $$y = y_0P_0(x) + y_1P_1(x) + y_2P_2(x)$$

The polynomials $P_0(x), P_1(x), P_2(x)$ are called Lagrange Polynomials. They can be used to interpolate through any number of points.

The problem with polynomial interpolation is that it is unstable. The polynomial interpolating through $(0,0), (1,0), (2,0), (3,0), (4,0)$ is obvious: $y = 0$. But move one of those points just slightly, say $(1,0.0001)$, and suddenly instead of a nice flat line, you've got a quartic that occilates wildly between the points. So if you are trying to estimate what the value of a function "ought" to be between the points you know, exact polynomial interpolation is not what you want. In that case, you are better off choosing a lower degree than you have points, and doing a regression as per Yurly's comments.