Subscribe For Free Updates!

We'll not spam mate! We promise.

coding java Polinom Newton

+++++++++++++++++++++++++++++++++++++++++++++
package metnum;

import java.text.DecimalFormat;


public class polinom_newton {
   
    
    static double fx(double x){
    double fx;
    fx = 0.2657* x + 2.895;
    return fx;
    }

    public static void main(String[] args) {
        DecimalFormat df = new DecimalFormat("0.0000");  
       double a= 1,b=6,c=7,d=9,e=12;
       double fa=fx(a),fb=fx(b),fc=fx(c),fd=fx(d),fe=fx(e),f45;
  
         System.out.println("x   |   "+a+"      |   "+b+"      |   "+c+"      |   "+d+"      |   "+e+"   |");
        System.out.println("y   |   "+df.format(fa)+"   |  "+df.format(fb)+"    |  "+df.format(fc)+"    |  "+df.format(fd)+"    |  "+df.format(fe)+"  |");
      
        System.out.println();
        f45=fx(4.5);
        System.out.println("fx = 0.2657* x + 2.895");
        System.out.println("f(4,5)= "+df.format(f45));
        System.out.println();
        System.out.println("Polinom newton");
       
        double st1a, st1b,st1c,st1d;
        double st2a, st2b,st2c;
        double st3a, st3b;
        double st4a;
       
        st1a=(fb-fa)/(b-a);st1b=(fc-fb)/(c-b); st1c=(fd-fc)/(d-c);
        st1d=(fe-fd)/(e-d);
        st2a=(st1b-st1a)/(c-a);st2b=(st1c-st1b)/(d-b);st2c=(st1d-st1c)/(e-c);
        st3a=(st2b-st2a)/(d-a);st3b=(st2c-st2b)/(e-b);
        st4a=(st3b-st3a)/(e-a);
        System.out.println("================================================="
                + "========================");
        System.out.println("x     |   y        |   st1    |   st2       |   st3"
                + "      |    st4      |");
        System.out.println(""+a+"   |   "+df.format(fa)+"   |   "
                + ""+df.format(st1a)+" |   "+df.format(st2a)+"   |   "
                + ""+df.format(st3a)+"   |   "+df.format(st4a)+"   |   ");
        System.out.println(""+b+"   |   "+df.format(fb)+"   |  "
                + " "+df.format(st1b)+" |   "+df.format(st2b)+"    |  "
                + " "+df.format(st3b)+"   |             |");
        System.out.println(""+c+"   |   "+df.format(fc)+"   |  "
                + " "+df.format(st1c)+" |   "+df.format(st2c)+"    |          "
                + "  |             |");
        System.out.println(""+d+"   |   "+df.format(fd)+"   |  "
                + " "+df.format(st1d)+" |             |            |         "
                + "    |");
        System.out.println(""+e+"  |   "+df.format(fe)+"   |          |       "
                + "      |            |             |");
        System.out.println("=================================================="
                + "=======================");
    double f45p;
    f45p=fa+st1a*(4.5-a)+st2a*(4.5-a)*(4.5-b)+st3a*(4.5-a)*(4.5-b)*(4.5-c)
            +st4a*(4.5-a)*(4.5-b)*(4.5-c)*(4.5-d);
        System.out.println(" Hasil Polinom newton = "+df.format(f45p));
    }  
}

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

1 komentar:

  1. Very nice article. I definitely appreciate this website.
    Keep writing!
    My web page - Cream A dha

    ReplyDelete