Java programming?

Obsidian

The Dork Knight
Joined
Sep 16, 2002
Messages
12,795
Reaction score
0
Points
31
I was wondering if someone could help me with this program I'm working on. It's focusing on interpolation (for those that don't know what that means, it means that you're taking a set of points and creating a new set of data points}. I've got the input down, I'm just not sure how to program the method.

/**
* @(#)Interpolation.java
*
* Interpolation application
*
* @author
* @version 1.00 2007/5/5
*/

import java.io.*;
import java.lang.Double;

public class Interpolation {

public static void main(String[] args)throws Exception {

int N; // the number of points to be interpolated
int mew; // the number of x points to be inputed
double[] xinter; // the x-values of the interpolated points
double[] yinter; // the y-values of the interpolated points
double[] newx; // the new x-values inputed
double[] newy; // the new y-values outputed
String input = "";
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
double[] lfct; // the L function
double[] yfct; // the Y function
double[] pfct; // the Lagrange polynomial value


System.out.println("Please enter the number of points to be interpolated");
input = in.readLine();
N = Integer.parseInt(input);

xinter = new double[N];
yinter = new double[N];


int sub = 0;

for (int i = 1; i <= N; i++){

System.out.println("Please enter x " + i);
input = in.readLine();
xinter[sub] = Double.parseDouble(input);

System.out.println("Please enter y " + i);
input = in.readLine();
yinter[sub] = Double.parseDouble(input);
sub++;
}

System.out.println("Please enter the number of x-values");
input = in.readLine();
mew = Integer.parseInt(input);

newx = new double[mew];

for (int j = 0; j < mew; j++){
System.out.println("Please enter the x(s):");
input = in.readLine();
newx[j]= Double.parseDouble(input);
}




}
}


I'm going to use Lagrange formula, but I can't for the life of me figure out how to code it. I understand the method pretty well, but when it gets down to coding, I'm lost. I have a general idea that it's going to involve a few loops, but yeah, if anyone can help me ASAP, it would be appreciated.

fbf1a1a198c3f3c6dc043ef8e18f8835.png


that's the general equation where the Yj refers to the Y coordinates that are going to be entered. The Xj will be used in the l(x) part of the equation, l(x) is the only part I'm really worried about. Once I get that, I'll be fine with the rest.

274f6e8c9bc39b035bd2c6d0601041e5.png


If you don't understand it, I'm welcome to explaining it.

Cheers,
Obsidian
 
Probably not the best forum to ask for programming help
Sorry, I could help you if this was in Python
Have you tried a java IRC channel?
 
I don’t think anyone can help you with this one, come back when you need to figure out how to do a scan disk. :o
 
Well, that's an easy problem. Wait here until I finish my PhD in a few years. D'oh!
 
Just after a quick look, it seems that L(x) is a simple enough loop multipling yj to the result of lj(x).

Solving lj(x) may best be done by recursion or another loop, skipping the recursion/loop iteration when i = j. It would proably be easiest to make lj(x) another function containg the recursion/loop. That way, when you've got the Product down, you won't have to worry about it anymore and can just multiply the result of the function to yj in the Summation.
 

Users who are viewing this thread

Back
Top
monitoring_string = "afb8e5d7348ab9e99f73cba908f10802"