Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package internewt;
- /**
- *
- * @author Student
- */
- public class InterNewt {
- public static void main(String[] args) {
- double tabx[]={0,2,3,4,6};
- double taby[]={1,3,2,5,7};
- int x=1,f=0,g=1;
- double w=0;
- int q=tabx.length;
- int qq=q;
- double tabt[]= new double[q-1];
- double tabfx[]= new double[q];
- double tabwx[]= new double[q-1];
- tabfx[0]=taby[0];
- for (int k=0;k<q-1;k++){
- tabt[k]=(taby[k+1]-taby[k])/(tabx[k+1]-tabx[k]);
- if(g==1){
- tabfx[g]=tabt[k];
- g++;
- }
- }
- for (int i=0;i<qq;i++){
- for (int j=0; j<qq-2;j++){
- tabt[j]=(tabt[j+1]-tabt[j+0])/(tabx[j+f+2]-tabx[0+j]);
- if(j==0){
- tabfx[g]=tabt[j];
- g++;
- }
- }
- f+=1;
- qq-=1;
- }
- for (int i=0;i<q-1;i++){
- if(i==0)
- tabwx[i]=x-tabx[i];
- else if(i>0)
- tabwx[i]=tabwx[i-1]*(x-tabx[i]);
- }
- for (int i=0;i<q;i++){
- if (i==0)
- w+=taby[0];
- else
- w+=tabfx[i]*tabwx[i-1];
- }
- System.out.println(w);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement