/*
* Compare brent() and bent() on a few simple functions. Comparison is based
* on CPU time and on number of function evaluations.
*/
batch("d:\\paul\\paper\\bentevfn.mac");
do_verbose:false$
bfprint_precision:5$
bfprecision:50$
tolerance:1.b-40$
brent_itmax:500$
bent_itmax:500$
timer(bent);
timer(brent);
funclist:[func1,func2,func3,func4,func5,case1,case2,case3,case4]$
for bent_hist_size:16 step 1 thru 16 do (
for funclistelem in funclist do (
l0:funclowlist[funclistelem],
h0:funchighlist[funclistelem],
if (do_verbose) then (
bent_brent_verbose:true,
ans:brent(funclistelem,l0,h0,tolerance),
print(funclistelem, "brent ans =", ans),
0),
bent_brent_verbose:false,
starttime:get('brent,'runtime),
ans:brent(funclistelem,l0,h0,tolerance),
brenttime:get('brent,'runtime)-starttime,
print(funclistelem, "brent ans =", ans),
if (do_verbose) then (
bent_brent_verbose:true,
ans:bent(funclistelem,l0,h0,tolerance),
print(funclistelem, "bent ans =", ans),
0),
bent_brent_verbose:false,
for bent_converge_ratio:1.b0 step 1.b-1 thru 2.b0 do (
starttime:get('bent,'runtime),
ans:bent(funclistelem,l0,h0,tolerance),
benttime:get('bent,'runtime)-starttime,
print(bent_hist_size, funclistelem, ans,
bent_converge_ratio,
num_bent_func_evals,
" benttime: ", benttime),
0),
print("brent # evals:",num_brent_func_evals,"bent # evals:",num_bent_func_evals),
print("brent runtime:",brenttime,"bent runtime:",benttime),
0),
0)$