Skip to content Skip to sidebar Skip to footer

Algoritma dan Pemrograman: Implementasi Metode Trapesium

Berikut adalah algoritma berupa flowchart untuk metode trapesium :

Implementasi metode trapesium menggunakan pemrograman java : 
/**
 *
 * @author ABD. CHARIS FAUZAN
 */
public class IntegrasiTrapesium {
        public static void main(String[] args) {
        double a = 0;
        double b = 0.8;
        double n = 10;
        double h = (b - a) / n;
        double x = a;
        double I = F(a)+F(b);
        double exact_Value = 1.640533;
        double sigma =0;
        for(int i=1;i < n;i++){
            x+=h;
            sigma+=2*F(x);
        }
        I=(I+sigma)*h/2;
        System.out.println("I = "+I);
        double Et = Math.abs((I-exact_Value)/exact_Value)*100;
        System.out.println("Et = "+Et+"%");
    }

    private static double F(double x) {
        return 0.2 + 25 * x - (200 * Math.pow(x, 2)) + (675 * Math.pow(x, 3)) - (900 * Math.pow(x, 4)) + (400 * Math.pow(x, 5));
    }
}
Output yang dihasilkan adalah :


Post a Comment for "Algoritma dan Pemrograman: Implementasi Metode Trapesium"