I have a set of estimated points, listed below, and I would like to know how to calculate the polynomial.
I've looked at Wikipedia, and I don't quite understand how at works. Example 1 on http://en.wikipedia.org/wiki/Lagrange_polynomial#Example_1 seems to be the closest to what I'm trying to do, but I don't know how to get the basis polynomials, i.e. turning the middle section into the right section. I can probably get it to the interpolating section from there.
My points are as follows:
800, 175; 600, 125; 400, 100; 200, 125; 0,0; -200, -125; -400, -100; -600, -125; -800, -175.
Eventually, I'm going to try and dynamically swap out the points above in the program I'm building, so I could really use a step by step description. I read Determining Coefficients of a Finite Degree Polynomial $f$ from the Sequence $\{f(k)\}_{k \in \mathbb{N}}$, but I don't quite follow it. It's very possible I'm out of my depth and should re-think what I'm trying to accomplish, but I'd really like to try this. Thanks!
Best Answer
If you know for a fact that your points lie on a polynomial of degree 5, you can use finite differences. This is especially easy when the $x$-values are in arithmetic progression, as in your case. Write the $y$-values:
175 125 100 125 0 -125 -100 -125 -175
Then write the difference between each number and the next:
-50 -25 25 -125 -125 25 -25 -50
Again:
25 50 -150 0 150 -50 -25
Again:
25 -200 150 150 -200 25
Again:
-225 350 0 -350 225
And once more:
575 -350 -350 575
Now if your points were really from a polynomial of degree 5, that last line would have been constant, but it's not, so they're not. But after all, you said they were estimated points - they still might be close to some polynomial of degree 5. To find the polynomial of degree 5 that comes closest to your points, there is a method called least squares, and there are many expositions of it on the web.
EDIT: Here's a start on least squares:
You want a polynomial $p(x)=ax^5+bx^4+cx^3+dx^2+ex+f$ such that $p(800)=175$, $p(600)=125$, etc. We already know that's impossible, so we settle for making all the numbers $p(800)-175$, $p(600)-125$, etc., small. In fact, we form the quantity $$(p(800)-175)^2+(p(600)-125)^2+\cdots+(p(-800)-175)^2$$ and we try to minimize it. This quantity is a function of the 6 variables $a,b,c,d,e,f$, and there are standard calculus techniques for minimizing such a function. It gets very messy, but fortunately you don't actually have to do it; someone has done it for you, in the most general case, and found that you can write down a very simple matrix equation which you can solve for the unknowns $a,b,c,d,e,f$. And that's what you'll find if you search for least squares polynomial fit.