# How to calculate a third degree polynomial function

I have this formula calculated by excel: $$y = -0.0001x^3 + 0.0294x^2 - 0.0567x - 68$$

This formula was calculated using this data:

Data1      Data2
0           -68
50          -11
75           47
100         111


What I need to way to calculate the same 3rd degree polynomial, but using this data.

Data1      Data2
a           -68
b           -11
c            47
d           111


I appreciate any tips or links that would help me to solve this.

-
Do you have values for a, b, c, d? – anon Jul 1 '11 at 0:34
see Lagrange Interpolation e.g. mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html – deinst Jul 1 '11 at 1:19
Thank you...... – muek Jul 3 '11 at 20:01

Given $n+1$ points, you can uniquely fit a degree $n$ polynomial (e.g. with the help of Lagrange polynomials).

For a degree one polynomial, a line, you need two points (makes sense, right?). The formula looks like $$L(x) = \dfrac{x-x_0}{x_1-x_0}f(x_1) + \dfrac{x-x_1}{x_0-x_1}f(x_0),$$

Where the points are $(x_0,f(x_0)), (x_1,f(x_1))$

Notice here what happens to the left summand when we plug in $x_0$: we get zero contribution from this term; whereas, when we plug in $x_1$, we recover the function $f(x_1)$ that we're trying to reach. Notice also that when we plugged in $x_0$ and $x_1$, the RHS went to $f(x_0)$ and $0$ respectively as well. Thus $L(x_1) = f(x_1)$ and $L(x_0) = f(x_0)$. We "constructed" a polynomial given two pairs of points that hits them with least degree needed.

For three points (quadratic), you want the similar cancellation effect:

$$L(x) = \dfrac{x-x_0}{x_1-x_0}\dfrac{x-x_2}{x_1-x_2}f(x_1) +\dfrac{x-x_1}{x_0-x_1}\dfrac{x-x_2}{x_0-x_2}f(x_0) + \dfrac{x-x_1}{x_2-x_1}\dfrac{x-x_0}{x_2-x_0}f(x_2)$$

See how the magic happens there? You should be able to construct the fourth degree polynomial from here. Hope this helps.

-
well done. I would only add that this is all done under the assumption that no two of the $n+1$ points lie on the same vertical line, which is to say no two of the numbers $x_0,x_1,\dots$ are equal. – Gerry Myerson Jul 1 '11 at 2:39
Thank you...... – muek Jul 3 '11 at 20:01

Four points with distinct $x$-coordinates will yield a unique cubic going through them. However, this interpolation to other $x$-values could be completely irrelevent. What are you modeling?

-
+1: As other have pointed out, it is easy to find a polynomial matching a collection of data points, but that is surely a very wrong way of going about modeling. For example, it is hard to tell, how accurate the data is, so I would be very hesitant to start drawing conclusions. If there were a few dozen data points, and they would follow a cubic polynomial reasonably accurately, then there could be something there. Instead, try to come up with an educated guess of the type of function with a couple parameters, make a least square fitting, and see how well that predicts new data points – Jyrki Lahtonen Jul 1 '11 at 8:55