function Q = adaptsim(f,a,b,tol,trace,varargin) %ADAPTSIM Numerically evaluate integral using adaptive % Simpson rule. % % Q = ADAPTSIM('F',A,B) approximates the integral of % F(X) from A to B to machine precision. 'F' is a % string containing the name of the function. The % function F must return a vector of output values if % given a vector of input values. % % Q = ADAPTSIM('F',A,B,TOL) integrates to a relative % error of TOL. % % Q = ADAPTSIM('F',A,B,TOL,TRACE) displays the left % end point of the current interval, the interval % length, and the partial integral. % % Q = ADAPTSIM('F',A,B,TOL,TRACE,P1,P2,...) allows % coefficients P1, ... to be passed directly to the % function F: G = F(X,P1,P2,...). To use default values % for TOL or TRACE, one may pass the empty matrix ([]). % % See also ADAPTSIMSTP. % % Walter Gander, 08/03/98 % Reference: Gander, Computermathematik, Birkhaeuser, 1992. global termination2 termination2 = 0; if (nargin < 4), tol = []; end; if (nargin < 5), trace = []; end; if (isempty(tol)), tol = eps; end; if (isempty(trace)), trace = 0; end; if tol