View source: R/utils-calculus.R
simpson_num_integr | R Documentation |
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)
f |
function that takes a single argument |
a |
the lower limit of integration |
b |
the upper limit of integration |
n |
integer, number of integration points with a and b |
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.