next up previous contents
Next: Optimizing Up: Calculus Previous: Differential Equations

Numerical Integration

For exact (symbolic) integrations and solutions, see gif Symbolic Math.

There are three functions available for numerical integration. The functions quad and quad8 use adaptive, recursive rules, the low order Simpson's and the higher order Newton Cotes 8 panel respectively; other than the rule used, they act identically. The basic format is quad('function', start, finish) to get the integral of function from start to finish. The function must take a single vector as input (of the length of start and finish) and return a single vector of output.

If the integration requires too much recursion (e.g. if the integral is singular), the value Inf is returned.

An optional fourth argument may be specified to give the tolerance (default tex2html_wrap_inline2881 . An optional boolean fifth argument may then be given to specify whether the evalutions should be traced in a point plot automatically (False if 0, True otherwise). An empty matrix may be passed for either of these to keep the defaults.

If function takes more than one argument, the others may be specified as constant (for the integration) parameters by quad('function', start, finish, tolerance, trace, first parameter, second parameter...). This integrates function(x, first parameter, second parameter...) over x = start to finish.

Alternatively, trapz may be used for trapezoidal numerical integration; the format is trapz(x, y). Here x is a vector and y is a matrix of any number of columns, but as many rows as the length of x. Each column of y is considered to be a function over x and is integrated with the trapezoidal approximation. The result is a vector of the column integrations. If x is omitted, unit spacing between points is assumed.



sepherke
Sat Mar 21 21:42:28 EST 1998