quadv
Adaptive Simpson quadrature of a vector-valued function of one variable.
Category: Mathematics > Numerical Integration and Differential Equations
Syntax
Q = quadv(fun, a, b)
Integrates fun from a to b, where fun(x) returns an array for a scalar x.
Q = quadv(fun, a, b, tol)
Uses the absolute tolerance tol.
Description
All components are integrated together on a shared subdivision of the interval, which is faster than calling quad once per component. The function is evaluated one point at a time, so it does not need to be vectorized in x.
The modern equivalent is integral(fun, a, b, 'ArrayValued', true).
Input arguments
fun- Handle called with a scalar
xthat returns a scalar, vector or array. a, b- Finite limits.
tol- Absolute tolerance. Default
1e-6.
Output arguments
Q- Array of the same size as
fun(x), holding the integrals of every component.
Example
Two integrals at once
Q = quadv(@(x) [x, x.^2], 0, 1)
Output
Q = 1×2
0.5000 0.3333