FUNCTION REFERENCE

integral

Numerical integration of a function of one variable.

Numerical integration of a function of one variable.

Syntax

q = integral(fun, a, b)

Syntax

q = integral(fun, a, b, 'Name', value, ...)

fun is a function handle called with a row of points; it must return a row of the same size. a and b are real scalars and may be -Inf or Inf. Options: 'AbsTol' (default 1e-10), 'RelTol' (default 1e-6), 'Waypoints' (real points where fun has kinks or jumps) and 'ArrayValued' (true calls fun with one point at a time and integrates every element of the array it returns). Complex integrands give a complex result. Adaptive Gauss-Kronrod (7,15) quadrature with the endpoint and infinite-interval transformations of Shampine (2008).

Example

integral(@(x) x.^2, 0, 1)   % 0.3333

Example

integral(@(x) exp(-x), 0, Inf)   % 1

Example

integral(@(x) [x; x.^2], 0, 1, 'ArrayValued', true)   % [0.5000; 0.3333]

Example

integral(@(x) abs(x - 1), 0, 3, 'Waypoints', 1)   % 2.5000

Differences from MATLAB: Complex limits and complex waypoints (contour integration) are not supported yet. Warnings use MATLAB's wording.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.