verry.integrate.cumulative_trapezoid#

verry.integrate.cumulative_trapezoid(fun, a, b, n)#

Cumulatively integrate fun using the composite trapezoidal rule.

Parameters:
  • fun (Callable) – Integrand. fun must be an univariate scalar-valued function.

  • a (Interval) – Lower limit of integration.

  • b (Interval) – Upper limit of integration.

  • n (int) – Number of divisions.

Warning

fun must be a \(C^2\)-function on some open interval that contains a and b. Furthermore, fun must neither be a constant nor contain conditional branches (cf. Common pitfalls).

Examples

>>> from verry import FloatInterval as FI
>>> from verry import function as vrf
>>> s = cumulative_trapezoid(lambda x: x**2 + 2 * vrf.sqrt(x), FI(1), FI(2), 300)
>>> print(s)
[4.771236, 4.771237]