Upload
britanni-kinney
View
16
Download
0
Embed Size (px)
DESCRIPTION
- PowerPoint PPT Presentation
Citation preview
public class Interpola{
private static double D[][], xn[]; private static int orden;
public static double newton(double x){ // cálculo del polinomio, se invoca las veces que una quiera double f = D[0][0]; double xterm = 1;
for(int i = 1; i <= orden;i++) { xterm = xterm * (x - xn[i - 1]); f = f + D[0][i] * xterm; } return f;}
public static void newton(double x[], double f[], int n){ // cálculo de las diferencias finitas, se invoca una vez: int i, j; D = new double[n + 1][n + 1]; xn = new double[n + 1]; orden = n;
xn[0] = x[0]; for(i = 0; i <= orden;i++) { D[i][0] = f[i]; xn[i] = x[i]; }
for(j = 1; j <= orden;j++) for(i = 0; i <= n - j;i++) D[i][j] = (D[i + 1][j - 1] - D[i][j - 1]) / (x[i + j] - x[i]);}
}