quadv

Numerical integration of a real vector-valued function using adaptive Simpson's rule.

Syntax

area=quadv(@func,a,b)

area=quadv(@func,a,b,abstol)

[area,count]=quadv(...)

Inputs

func
The function to integrate.
The input is a scalar and the output is a vector.
A function handle or anonymous function is also supported.
a
Lower integration limit.
Type: double
Dimension: scalar
b
Upper integration limit.
Type: double
Dimension: scalar
abstol
Absolute tolerance (default: sqrt(eps) or about 1.0e-8).
Type: double
Dimension: scalar

Outputs

area
The estimated area.
Dimension: scalar | vector
count
Number of function evaluations.
Dimension: scalar

Example

function y = Integrand(x)
	y(1) = 13 * (x - x^2) * exp(-3*x/2);
	y(2) = log(1 + x);
end

[area,count] = quadv(@Integrand, 0, 4, 1.0e-5)
-1.54879  4.04719
        count = 69

Comments

quadv recursively bisects each interval until the improvement falls below the absolute tolerance. Intervals are assumed to have finite bounds.

The maximum number of function evaluations is 10,000, and the minimum interval is 1.0e-12.

To pass additional parameters to a function argument, use an anonymous function.