public class IntegralOutput { // ======================================================================= // Settings for Integrations // ======================================================================= // The tntegrant function. static final double f(double x) { return Math.cos(x); } static final double A = 0.0; // The lower-limit of the integration interval. static final double B = 1.0; // The upper-limit of the integration interval. static final int N = 10000; // The number of tiny intervals for numerical integration. // ======================================================================= // Compute The Integral Value Numerically // ======================================================================= public static void main(String[] args) { double delta = (B - A) / N; // The width of a tiny interval. double value = 0.0; // Add approximated area of all tiny intervals to this variable. // Traverse tiny intervals from lower-limit (left) to upper-limit (right). for(int i=0; i