Simpson's method to integrate a univariate continuous function.
Faster that R's integrate()
and precise enough, but does not do any checks.
The error is at most M (b-a)^5/(180 n^4)
where M
is the maximum of
the fourth derivative of the integrand in the interval [a, b]
.
simpson_num_integr(f, a, b, n)
numeric, the integration value examples #expect 1 simpson_num_integr(sin, 0, pi/2, 100) #max error for simpson_num_integr(sin, 0, pi/2, 100) is 5.312842e-10 1 * (pi/2 - 0)^5/(180 * 100^4)
function that takes a single argument
the lower limit of integration
the upper limit of integration
integer, number of integration points with a and b