Mercurial > hg > octave-nkf
diff scripts/general/quadl.m @ 12612:16cca721117b stable
doc: Update all documentation for chapter on Numerical Integration
* cumtrapz.m, dblquad.m, quadgk.m, quadl.m, quadv.m, trapz.m,
triplequad.m, quad.cc, quadcc.cc: Improve docstrings.
* Quad-opts.in: Keep code sample together on a single line.
* mk-opts.pl: Update quad-options function description
* octave.texi: Update order of detailmenu to match order in quad.texi.
* quad.txi: Add language about when to use each quad function,
add examples of using trapz.
* aspell-octave.en.pws: Add new spelling words from quad.texi chapter
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 17 Apr 2011 19:57:07 -0700 |
parents | d0b799dafede |
children | f96b9b9f141b |
line wrap: on
line diff
--- a/scripts/general/quadl.m +++ b/scripts/general/quadl.m @@ -22,21 +22,28 @@ ## @deftypefnx {Function File} {@var{q} =} quadl (@var{f}, @var{a}, @var{b}, @var{tol}, @var{trace}) ## @deftypefnx {Function File} {@var{q} =} quadl (@var{f}, @var{a}, @var{b}, @var{tol}, @var{trace}, @var{p1}, @var{p2}, @dots{}) ## -## Numerically evaluate integral using adaptive Lobatto rule. -## @code{quadl (@var{f}, @var{a}, @var{b})} approximates the integral of -## @code{@var{f}(@var{x})} to machine precision. @var{f} is either a -## function handle, inline function or string containing the name of -## the function to evaluate. The function @var{f} must return a vector -## of output values if given a vector of input values. +## Numerically evaluate the integral of @var{f} from @var{a} to @var{b} +## using an adaptive Lobatto rule. +## @var{f} is a function handle, inline function, or string +## containing the name of the function to evaluate. +## The function @var{f} must be vectorized and return a vector of output values +## if given a vector of input values. +## +## @var{a} and @var{b} are the lower and upper limits of integration. Both +## limits must be finite. ## -## If defined, @var{tol} defines the relative tolerance to which to -## which to integrate @code{@var{f}(@var{x})}. While if @var{trace} is -## defined, displays the left end point of the current interval, the -## interval length, and the partial integral. +## The optional argument @var{tol} defines the relative tolerance with which +## to perform the integration. The default value is @code{eps}. ## -## Additional arguments @var{p1}, etc., are passed directly to @var{f}. -## To use default values for @var{tol} and @var{trace}, one may pass -## empty matrices. +## The algorithm used by @code{quadl} involves recursively subdividing the +## integration interval. +## If @var{trace} is defined then for each subinterval display: (1) the left +## end of the subinterval, (2) the length of the subinterval, (3) the +## approximation of the integral over the subinterval. +## +## Additional arguments @var{p1}, etc., are passed directly to the function +## @var{f}. To use default values for @var{tol} and @var{trace}, one may pass +## empty matrices ([]). ## ## Reference: W. Gander and W. Gautschi, @cite{Adaptive Quadrature - ## Revisited}, BIT Vol. 40, No. 1, March 2000, pp. 84--101. @@ -55,7 +62,7 @@ ## * replace global variable terminate2 with local function need_warning ## * add paper ref to docs -function Q = quadl (f, a, b, tol, trace, varargin) +function q = quadl (f, a, b, tol, trace, varargin) need_warning (1); if (nargin < 4) tol = []; @@ -128,7 +135,7 @@ if (is == 0) is = b-a; endif - Q = adaptlobstp (f, a, b, fa, fb, is, trace, varargin{:}); + q = adaptlobstp (f, a, b, fa, fb, is, trace, varargin{:}); endfunction ## ADAPTLOBSTP Recursive function used by QUADL. @@ -141,7 +148,7 @@ ## ## Walter Gautschi, 08/03/98 -function Q = adaptlobstp (f, a, b, fa, fb, is, trace, varargin) +function q = adaptlobstp (f, a, b, fa, fb, is, trace, varargin) h = (b-a)/2; m = (a+b)/2; alpha = sqrt(2/3); @@ -165,12 +172,12 @@ warning ("quadl: required tolerance may not be met"); need_warning (0); endif - Q = i1; + q = i1; if (trace) - disp ([a, b-a, Q]); + disp ([a, b-a, q]); endif else - Q = (adaptlobstp (f, a, mll, fa, fmll, is, trace, varargin{:}) + q = (adaptlobstp (f, a, mll, fa, fmll, is, trace, varargin{:}) + adaptlobstp (f, mll, ml, fmll, fml, is, trace, varargin{:}) + adaptlobstp (f, ml, m, fml, fm, is, trace, varargin{:}) + adaptlobstp (f, m, mr, fm, fmr, is, trace, varargin{:})