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

Break up the equation into simple binary operations and someone can show you the code.
For example to multiply two variables: var1 * var2

how do I represent the symbol x

A variable named: x would be defined by putting a type in front of the x:
<THE TYPE Here> x;
valid types are: int, short, float, double, .....


If you need help writing a program, have you thought of hiring a programmer?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.