Top Banner
1. Metode Tabel package Tabel; public class tabel { public static void main(String[] args) { double a = -1; double b = 0; int n = 10; double h = (b-a)/n; double x[] = new double[n+2]; x[0] = a; double fx[] = new double[x.length]; fx[0] = a*Math.exp(-(a))+1; for (int i = 0; i <= n; i++) { x[i+1] = x[i]+h; fx[i+1] = x[i+1]*Math.exp(-(x[i+1]))+1; System.out.println("x = "+i+" |"+x[i]); System.out.println("f("+i+") "+fx[i]); } System.out.println("====================="); for (int i = 0; i < fx.length; i++) { if(Math.abs(fx[i])<Math.abs(fx[i+1])){ System.out.println("Root : "+x[i]); i = fx.length; } } } }
13

Source Code applikasi

Oct 09, 2015

Download

Documents

Ali Munajid

Source Code tugas
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

1. Metode Tabel

package Tabel;public class tabel { public static void main(String[] args) { double a = -1; double b = 0; int n = 10; double h = (b-a)/n; double x[] = new double[n+2]; x[0] = a; double fx[] = new double[x.length]; fx[0] = a*Math.exp(-(a))+1; for (int i = 0; i