Functions | |
endif | if (nargin< 4) tol |
endif | if (isa(a,"single")||isa(b,"single")) myeps |
endif | if (isempty(tol)) tol |
endif | if (isempty(trace)) trace=0 |
if (isinf(fa)) fa | |
endif | if (isinf(fb)) fb |
if (fcnt > 10000) warning("maximum iteration count reached") | |
elseif (isnan(q)||isinf(q)) warning("infinite or NaN function evaluations were returned") | |
elseif (hmin< (b-a)*myeps) warning("minimum step size reached -- possibly singular integral") = x != 0 | |
endif | if (trace) disp([fcnt |
id | q () |
endif | if (fcnt==5||abs(q-q0) > tol)[q1 |
endif endif endfunction | !assert (quadv(@sin, 0, 2 *pi), 0, 1e-5)%!assert(quadv(@sin |
Variables | |
function [q, fcnt] | |
else | myeps = eps |
endif | c = (a + b) / 2 |
fa = feval (f, a, varargin{:}) | |
fc = feval (f, c, varargin{:}) | |
fb = feval (f, b, varargin{:}) | |
fcnt = 3 | |
endif | h = (b - a) / 2 |
q = (b - a) / 6 * (fa + 4 * fc + fb) | |
else | d = (a + c) / 2 |
e = (c + b) / 2 | |
fd = feval (f, d, varargin{:}) | |
fe = feval (f, e, varargin{:}) | |
q1 = (c - a) / 6 * (fa + 4 * fd + fc) | |
q2 = (b - c) / 6 * (fc + 4 * fe + fb) | |
endif | a |
endif | hmin |
endif endif endfunction | pi |
endif endif endfunction !assert | ( | quadv(@sin, 0, 2 *pi) | , | |
0 | , | |||
1e- | 5 | |||
) |
elseif | ( | ) | = x != 0 |
elseif | ( | isnan(q)||isinf(q) | ) |
if | ( | fcnt | , | |
10000 | ||||
) |
if | ( | isinf(fa) | ) |
endif if | ( | isa(a,"single")||isa(b,"single") | ) |
endif if | ( | ) |
id q | ( | ) | [virtual] |
endif a |
endif c = (a + b) / 2 |
else d = (a + c) / 2 |
b d e = (c + b) / 2 |
fa = feval (f, a, varargin{:}) |
fb = feval (f, b, varargin{:}) |
fc = feval (f, c, varargin{:}) |
fd = feval (f, d, varargin{:}) |
endif endfunction function[q, fcnt, hmin] |
endif h = (b - a) / 2 |
* pi |