[Math] how to get polynomial equation from points

graphing-functionspolynomials

How can i get polynomial equation from points?
I have data in excel and i want to get polynomial equation from it. I can get polynomial equation using excel using trendline but only to order of 6.
I would like to know how does excel get polynomial equation just with the points. the graph and the equation is shown in the picture
graph

Best Answer

You can do this most easily with matrices, and a quick Google search shows that matrix multiplication can be done in Excel, but it can be a bit of a pain, especially with so many points.

Let $A$ be the matrix created from the system of equations that result from plugging each point into $f(x)$ and $y$ be the matrix containing the values of $f(x)$. So given a set of points $\{(x_1, y_1),(x_2, y_2),...,(x_n, y_n)\}$, if you want a polynomial fit of degree $N$ (with $N>n$), you'd have the following matrices:

$A = \begin{bmatrix} x_1^{N} & x_1^{N-1} & x_1^{N-2} & ... & 1 \\ x_2^{N} & x_2^{N-1} & x_2^{N-2} & ... & 1 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ x_n^{N} & x_n^{N-1} & x_n^{N-2} & ... & 1 \end{bmatrix}$

$Y = \begin{bmatrix} y_1 \\ y_2 \\ \vdots \\ y_n \end{bmatrix}$

Now take set the matrix $\beta$ as

$$\beta = (A^T A)^{-1} A^T Y$$ whose elements are the coefficients of the $N$th degree polynomial corresponding to the set of points.

Related Question