View source: R/romberg_int1d.R
romberg_int1d | R Documentation |
romberg_int1d
performs numerical romberg integration of 1-dimensional
functions. Vectorized to handle several functions at once. See examples.
romberg_int1d(f, a = -Inf, b = Inf, eps = 1e-04, max = NULL, d = NULL)
f |
The function (of one variable) to integrate, returning either a scalar or a vector. |
a |
A scalar or vector (only Romberg) giving the lower bound(s). A vector cannot contain both -Inf and finite values. |
b |
A scalar or vector (only Romberg) giving the upper bound(s). A vector cannot contain both Inf and finite values. |
eps |
Precision. |
max |
The maximum number of steps, by default set to 16. |
d |
The number of extrapolation points so that 2d is the order of integration, by default set to 5; d=2 is Simpson's rule. |
The vector of values of the integrals of the function supplied.
Bruce Swihart (based on rmutil::int
by J.K. Lindsey.)
f <- function(x) sin(x)+cos(x)-x^2
romberg_int1d(f, a=0, b=2)
#
f <- function(x) exp(-(x-2)^2/2)/sqrt(2*pi)
romberg_int1d(f, a=0:3)
romberg_int1d(f, a=0:3, d=2)
1-pnorm(0:3, 2)
#
f <- function(x) dnorm(x)
romberg_int1d(f, a=-Inf, b=qnorm(0.975))
# NOTE: see \code{rmutil::int} for TOMS614.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.