Menghitung Fungsi Newton Rhapson di Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package fungsinewtonrapson;

/**
*
* @author ANGGA
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.printf(“%5s%20s%20s%20s%20s%25s%25s%25s\n”, “Po”, “f(Po)”,”f'(P0)”,”p”,”f(P)”,”E1″,”E2″,”E3″);
System.out.println(“——————————————————————————————————————————————————————–“);
fungsiX(6);
fungsiX(4.3);
fungsiX(3);
fungsiX(2.1);
fungsiX(1.5);
fungsiX(1.1);
}

public static void fungsiX(double x){
double fungsiPO=Math.pow(x, 4)+3*Math.pow(x, 3)+6*Math.pow(x, 2)-7*x-3;
double fungsiTurunanPO=4*Math.pow(x, 3)+9*Math.pow(x, 2)+12*x-7;
double p=x-(fungsiPO/fungsiTurunanPO);
double fungsiP=Math.pow(p, 4)+3*Math.pow(p, 3)+6*Math.pow(p, 2)-7*p-3;
double E1=p-x;
double E2=E1/p;
double E3=fungsiP;
System.out.printf(“%5s%20s%20s%20s%20s%25s%25s%25s\n”,x,fungsiPO,fungsiTurunanPO,p,fungsiP,E1,E2,E3);

}

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s