I am trying to write an algorithm that finds the Lagrange polynomial given a set of points, in quadratic time.
I don't necessarily want the code to do it, just an explanation on how to write this algorithm in java in quadratic time. I know the equation, its relatively simple, I just have no idea how to represent it in Java.
For example, I know the code must calculate P(x) (for j to N, j != i) = (x - xi)/(xj-xi), and I represent each xi and xj value in an array, but how do I represent the symbol x?
If anyone can provide an explanation on how I can go about this algorithm, or any help whatsoever, it would be greatly appreciated.
Thanks.
Just for clarification, here is a link to the definition of a Lagrange polynomial:
http://en.wikipedia.org/wiki/Lagrange_polynomial