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

* Quadrature Example 1: Approximates an integral. *

* The integral $$\int_1^3 e^{2x} \, dx$$ is computed and compared to its * expected value. * * * * @see Code * @see Output */ public class QuadratureEx1 { public static void main(String args[]) { Quadrature.Function fcn = new Quadrature.Function() { @Override public double f(double x) { return Math.exp(2.0 * x); } }; Quadrature q = new Quadrature(); double result = q.eval(fcn, 1.0, 3.0); double expect = (Math.exp(6) - Math.exp(2)) / 2.0; System.out.println("result = " + result); System.out.println("expect = " + expect); } }