This is a method for the generic function integral
.
It computes the numerical integral
$$
I = \int f(x) dx
$$
of the function object f
.
If domain
is specified, the integral is restricted to the
interval of \(x\) values given by the domain
.
The result is a numeric value or numeric vector containing one entry
for each column of function values in f
.
Integrals are calculated numerically using the trapezoidal rule
restricted to the domain given.