integral | R Documentation |
Computes the integrals of functions
or characters
in arbitrary
orthogonal coordinate systems.
integral( f, bounds, params = list(), coordinates = "cartesian", relTol = 0.001, absTol = 1e-12, method = NULL, vectorize = NULL, drop = TRUE, verbose = FALSE, ... )
f |
array of |
bounds |
|
params |
|
coordinates |
coordinate system to use. One of: |
relTol |
the maximum relative tolerance. |
absTol |
the absolute tolerance. |
method |
the method to use. One of |
vectorize |
|
drop |
if |
verbose |
|
... |
additional arguments passed to |
The function integrates seamlessly with cubature for efficient numerical integration in C. If the package cubature is not installed, the function implements a naive Monte Carlo integration by default. For arbitrary orthogonal coordinates q_1… q_n the integral is computed as:
\int J\cdot f(q_1… q_n) dq_1… dq_n
where J=∏_i h_i is the Jacobian determinant of the transformation and is equal to the product of the scale factors h_1… h_n.
list with components
the final estimate of the integral.
estimate of the modulus of the absolute error.
cubature output when method "hcubature"
, "pcubature"
, "cuhre"
, "divonne"
, "suave"
or "vegas"
is used.
Guidotti E (2022). "calculus: High-Dimensional Numerical and Symbolic Calculus in R." Journal of Statistical Software, 104(5), 1-37. doi: 10.18637/jss.v104.i05
Other integrals:
ode()
### unidimensional integral i <- integral("sin(x)", bounds = list(x = c(0,pi))) i$value ### multidimensional integral f <- function(x,y) x*y i <- integral(f, bounds = list(x = c(0,1), y = c(0,1))) i$value ### vector-valued integrals f <- function(x,y) c(x, y, x*y) i <- integral(f, bounds = list(x = c(0,1), y = c(0,1))) i$value ### tensor-valued integrals f <- function(x,y) array(c(x^2, x*y, x*y, y^2), dim = c(2,2)) i <- integral(f, bounds = list(x = c(0,1), y = c(0,1))) i$value ### area of a circle i <- integral(1, bounds = list(r = c(0,1), theta = c(0,2*pi)), coordinates = "polar") i$value ### surface of a sphere i <- integral(1, bounds = list(r = 1, theta = c(0,pi), phi = c(0,2*pi)), coordinates = "spherical") i$value ### volume of a sphere i <- integral(1, bounds = list(r = c(0,1), theta = c(0,pi), phi = c(0,2*pi)), coordinates = "spherical") i$value
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.