package com.imsl.test.example.math; import com.imsl.math.*; /** *

* Quadrature Example 2: Approximates the integral of \(e^{-x}\).

* The integral $$\int_0^\infty e^{-x} \, dx$$ is computed and compared to its * expected value. * * * @see Code * @see Output */ public class QuadratureEx2 { public static void main(String args[]) { Quadrature.Function fcn = new Quadrature.Function() { @Override public double f(double x) { return Math.exp(-x); } }; Quadrature q = new Quadrature(); double result = q.eval(fcn, 0.0, Double.POSITIVE_INFINITY); double expect = 1.; System.out.println("result = " + result); System.out.println("expect = " + expect); } }