| vc_integrate | R Documentation |
Approximate a signed definite integral
vc_integrate(
f,
interval,
method = c("trapezoid", "simpson", "adaptive"),
n = 32L,
abs_tol = 1e-08,
rel_tol = 1e-08,
subdivisions = 100L
)
f |
Deterministic function accepting a real scalar and returning one finite real scalar. Vectorization is not required. |
interval |
Two finite real bounds, allowing reversed or equal bounds. |
method |
Quadrature rule: trapezoid, Simpson, or adaptive QUADPACK through stats::integrate(). Improper infinite bounds are not supported. |
n |
Initial number of equal cells for fixed rules; positive integer, even and at least two for Simpson. Ignored by the adaptive rule. |
abs_tol, rel_tol |
Nonnegative finite absolute and relative diagnostic tolerances; at least one must be positive. Adaptive integration also applies the tolerance restrictions of stats::integrate(). |
subdivisions |
Positive integer maximum adaptive subinterval count; ignored by fixed rules. |
Fixed rules evaluate n and 2*n cells and return the finer result. Richardson diagnostics use abs(fine-coarse)/3 for trapezoids and /15 for Simpson. They assume sufficiently smooth functions and an asymptotic error regime; aliasing or missed narrow features can make them misleading. tolerance_met is only a numerical diagnostic, never a certified bound. Adaptive status preserves QUADPACK failure messages without claiming convergence. Evaluation errors and nonfinite sampled values/results stop. Scalar-only functions are supported. Reversed bounds negate the integral; equal bounds return zero without evaluating f. Integrals are signed, not geometric areas. No method proves integrability or discovers every singularity; split known discontinuities/singularities explicitly.
Plain list with type, interval, method, estimate, error_estimate, tolerance, tolerance_met, status, message, n (finest fixed cell count or NA), table (finest fixed nodes, values, signed weights/contributions), refinement (coarse/fine estimates), subdivisions and note. Adaptive internal nodes are unavailable and table/refinement are NULL.
(function(x)x^2) |> vc_integrate(c(0,2),method="simpson")
vc_integrate(sin,c(0,pi),method="adaptive")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.