1,105,450 Community Members

Polynomial interpolation algorithm

Member Avatar
jssutton11
Newbie Poster
6 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

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?

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article