integral
fun integral(a: DScalar, b: DScalar, n: Int = 5, eps: Float = 1.0E-5f, f: (DScalar) -> DScalar): DScalar
Content copied to clipboard
Compute the integral of the function f from a to b using Romberg's method.
Note: if the performance of this becomes important (for example, we want to minimize the number of function evaluations), then we might consider moving to another adaptive method such as Clenshaw–Curtis quadrature
Parameters
a
The start point of the integral
b
The end point of the integral
n
The maximum order of the integration. This may require O(2^n) function evaluations, but can give a precise result for polynomials of order n.
eps
Desired accuracy. If an order i and order i+1 results agree within a relative accuracy of eps, then that result is returned rather than continuing to compute the integral using further samples.
f
The function to be integrated