Mercurial > hg > octave-lyh
annotate scripts/optimization/fzero.m @ 10297:ed88ea036716
improve docs of fzero/fminbnd
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 10 Feb 2010 16:15:30 +0100 |
parents | 035ac548a67e |
children | 7c97da90fc8f |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2008, 2009 VZLU Prague, a.s. |
8305 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 ## | |
19 ## Author: Jaroslav Hajek <highegg@gmail.com> | |
20 | |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
21 ## -*- texinfo -*- |
9143
74d5c1a4ca96
Eliminate 'unbalanced parentheses in @def...' error during texi2pdf.
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
22 ## @deftypefn {Function File} {[@var{x}, @var{fval}, @var{info}, @var{output}] =} fzero (@var{fun}, @var{x0}, @var{options}) |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
23 ## Find a zero point of a univariate function. @var{fun} should be a function |
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
24 ## handle or name. @var{x0} specifies a starting point. @var{options} is a |
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
25 ## structure specifying additional options. Currently, @code{fzero} |
8515
ec2715c76039
fzero.m, fsolve.m: additional doc fixes
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
26 ## recognizes these options: @code{"FunValCheck"}, @code{"OutputFcn"}, |
ec2715c76039
fzero.m, fsolve.m: additional doc fixes
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
27 ## @code{"TolX"}, @code{"MaxIter"}, @code{"MaxFunEvals"}. |
ec2715c76039
fzero.m, fsolve.m: additional doc fixes
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
28 ## For description of these options, see @ref{doc-optimset,,optimset}. |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
29 ## |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
30 ## On exit, the function returns @var{x}, the approximate zero point |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
31 ## and @var{fval}, the function value thereof. |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
32 ## @var{info} is an exit flag that can have these values: |
10297
ed88ea036716
improve docs of fzero/fminbnd
Jaroslav Hajek <highegg@gmail.com>
parents:
10296
diff
changeset
|
33 ## |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
34 ## @itemize |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
35 ## @item 1 |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
36 ## The algorithm converged to a solution. |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
37 ## @item 0 |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
38 ## Maximum number of iterations or function evaluations has been exhausted. |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
39 ## @item -1 |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
40 ## The algorithm has been terminated from user output function. |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
41 ## @end itemize |
8515
ec2715c76039
fzero.m, fsolve.m: additional doc fixes
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
42 ## @seealso{optimset, fsolve} |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
43 ## @end deftypefn |
8305 | 44 |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
45 ## This is essentially the ACM algorithm 748: Enclosing Zeros of |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
46 ## Continuous Functions due to Alefeld, Potra and Shi, ACM Transactions |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
47 ## on Mathematical Software, Vol. 21, No. 3, September 1995. Although |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
48 ## the workflow should be the same, the structure of the algorithm has |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
49 ## been transformed non-trivially; instead of the authors' approach of |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
50 ## sequentially calling building blocks subprograms we implement here a |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
51 ## FSM version using one interior point determination and one bracketing |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
52 ## per iteration, thus reducing the number of temporary variables and |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
53 ## simplifying the algorithm structure. Further, this approach reduces |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
54 ## the need for external functions and error handling. The algorithm has |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
55 ## also been slightly modified. |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
56 |
8648
ff61b53eb294
optimization: use PKG_ADD: comments instead of PKG_ADD file
John W. Eaton <jwe@octave.org>
parents:
8596
diff
changeset
|
57 ## PKG_ADD: __all_opts__ ("fzero"); |
ff61b53eb294
optimization: use PKG_ADD: comments instead of PKG_ADD file
John W. Eaton <jwe@octave.org>
parents:
8596
diff
changeset
|
58 |
8305 | 59 function [x, fval, info, output] = fzero (fun, x0, options = struct ()) |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
60 |
8596
8833c0b18eb2
enable default settings queries in optim funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
8515
diff
changeset
|
61 ## Get default options if requested. |
8833c0b18eb2
enable default settings queries in optim funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
8515
diff
changeset
|
62 if (nargin == 1 && ischar (fun) && strcmp (fun, 'defaults')) |
10296 | 63 x = optimset ("MaxIter", Inf, "MaxFunEvals", Inf, "TolX", 1e-8, \ |
8596
8833c0b18eb2
enable default settings queries in optim funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
8515
diff
changeset
|
64 "OutputFcn", [], "FunValCheck", "off"); |
8833c0b18eb2
enable default settings queries in optim funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
8515
diff
changeset
|
65 return; |
8833c0b18eb2
enable default settings queries in optim funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
8515
diff
changeset
|
66 endif |
8833c0b18eb2
enable default settings queries in optim funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
8515
diff
changeset
|
67 |
8305 | 68 if (nargin < 2 || nargin > 3) |
69 print_usage (); | |
70 endif | |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
71 |
8305 | 72 if (ischar (fun)) |
9464
e598248a060d
safer str2func use in optim functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9143
diff
changeset
|
73 fun = str2func (fun, "global"); |
8305 | 74 endif |
75 | |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
76 ## TODO |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
77 ## displev = optimget (options, "Display", "notify"); |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
78 funvalchk = strcmpi (optimget (options, "FunValCheck", "off"), "on"); |
8305 | 79 outfcn = optimget (options, "OutputFcn"); |
10296 | 80 tolx = optimget (options, "TolX", 1e-8); |
8305 | 81 maxiter = optimget (options, "MaxIter", Inf); |
82 maxfev = optimget (options, "MaxFunEvals", Inf); | |
83 | |
84 persistent mu = 0.5; | |
85 | |
86 if (funvalchk) | |
8507 | 87 ## Replace fun with a guarded version. |
8305 | 88 fun = @(x) guarded_eval (fun, x); |
89 endif | |
90 | |
8507 | 91 ## The default exit flag if exceeded number of iterations. |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
92 info = 0; |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
93 niter = 0; |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
94 nfev = 0; |
8305 | 95 |
96 x = fval = a = fa = b = fb = NaN; | |
10296 | 97 eps = eps (class (x0)); |
8305 | 98 |
8507 | 99 ## Prepare... |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
100 a = x0(1); |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
101 fa = fun (a); |
8305 | 102 nfev = 1; |
103 if (length (x0) > 1) | |
104 b = x0(2); | |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
105 fb = fun (b); |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
106 nfev += 1; |
8305 | 107 else |
8507 | 108 ## Try to get b. |
8305 | 109 if (a == 0) |
110 aa = 1; | |
111 else | |
112 aa = a; | |
113 endif | |
114 for b = [0.9*aa, 1.1*aa, aa-1, aa+1, 0.5*aa 1.5*aa, -aa, 2*aa, -10*aa, 10*aa] | |
115 fb = fun (b); nfev += 1; | |
116 if (sign (fa) * sign (fb) <= 0) | |
117 break; | |
118 endif | |
119 endfor | |
120 endif | |
121 | |
122 if (b < a) | |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
123 u = a; |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
124 a = b; |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
125 b = u; |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
126 |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
127 fu = fa; |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
128 fa = fb; |
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
129 fb = fu; |
8305 | 130 endif |
131 | |
132 if (! (sign (fa) * sign (fb) <= 0)) | |
8468
866492035ecf
fsolve.m, fzero.m: undo part of previous change
John W. Eaton <jwe@octave.org>
parents:
8467
diff
changeset
|
133 error ("fzero:bracket", "fzero: not a valid initial bracketing"); |
8305 | 134 endif |
135 | |
136 itype = 1; | |
137 | |
138 if (abs (fa) < abs (fb)) | |
139 u = a; fu = fa; | |
140 else | |
141 u = b; fu = fb; | |
142 endif | |
143 | |
144 d = e = u; | |
145 fd = fe = fu; | |
146 mba = mu*(b - a); | |
147 while (niter < maxiter && nfev < maxfev) | |
148 switch (itype) | |
149 case 1 | |
8507 | 150 ## The initial test. |
8305 | 151 if (b - a <= 2*(2 * abs (u) * eps + tolx)) |
152 x = u; fval = fu; | |
153 info = 1; | |
154 break; | |
155 endif | |
156 if (abs (fa) <= 1e3*abs (fb) && abs (fb) <= 1e3*abs (fa)) | |
8507 | 157 ## Secant step. |
8305 | 158 c = u - (a - b) / (fa - fb) * fu; |
159 else | |
8507 | 160 ## Bisection step. |
8305 | 161 c = 0.5*(a + b); |
162 endif | |
163 d = u; fd = fu; | |
164 itype = 5; | |
165 case {2, 3} | |
166 l = length (unique ([fa, fb, fd, fe])); | |
167 if (l == 4) | |
8507 | 168 ## Inverse cubic interpolation. |
8305 | 169 q11 = (d - e) * fd / (fe - fd); |
170 q21 = (b - d) * fb / (fd - fb); | |
171 q31 = (a - b) * fa / (fb - fa); | |
172 d21 = (b - d) * fd / (fd - fb); | |
173 d31 = (a - b) * fb / (fb - fa); | |
174 q22 = (d21 - q11) * fb / (fe - fb); | |
175 q32 = (d31 - q21) * fa / (fd - fa); | |
176 d32 = (d31 - q21) * fd / (fd - fa); | |
177 q33 = (d32 - q22) * fa / (fe - fa); | |
178 c = a + q31 + q32 + q33; | |
179 endif | |
180 if (l < 4 || sign (c - a) * sign (c - b) > 0) | |
8507 | 181 ## Quadratic interpolation + newton. |
8305 | 182 a0 = fa; |
183 a1 = (fb - fa)/(b - a); | |
184 a2 = ((fd - fb)/(d - b) - a1) / (d - a); | |
8507 | 185 ## Modification 1: this is simpler and does not seem to be worse. |
8305 | 186 c = a - a0/a1; |
187 if (a2 != 0) | |
188 c = a - a0/a1; | |
189 for i = 1:itype | |
190 pc = a0 + (a1 + a2*(c - b))*(c - a); | |
191 pdc = a1 + a2*(2*c - a - b); | |
192 if (pdc == 0) | |
193 c = a - a0/a1; | |
194 break; | |
195 endif | |
196 c -= pc/pdc; | |
197 endfor | |
198 endif | |
199 endif | |
200 itype += 1; | |
201 case 4 | |
8507 | 202 ## Double secant step. |
8305 | 203 c = u - 2*(b - a)/(fb - fa)*fu; |
8507 | 204 ## Bisect if too far. |
8305 | 205 if (abs (c - u) > 0.5*(b - a)) |
206 c = 0.5 * (b + a); | |
207 endif | |
208 itype = 5; | |
209 case 5 | |
8507 | 210 ## Bisection step. |
8305 | 211 c = 0.5 * (b + a); |
212 itype = 2; | |
213 endswitch | |
214 | |
8507 | 215 ## Don't let c come too close to a or b. |
8305 | 216 delta = 2*0.7*(2 * abs (u) * eps + tolx); |
217 if ((b - a) <= 2*delta) | |
218 c = (a + b)/2; | |
219 else | |
220 c = max (a + delta, min (b - delta, c)); | |
221 endif | |
222 | |
8507 | 223 ## Calculate new point. |
8305 | 224 x = c; |
225 fval = fc = fun (c); | |
226 niter ++; nfev ++; | |
227 | |
8507 | 228 ## Modification 2: skip inverse cubic interpolation if |
229 ## nonmonotonicity is detected. | |
8305 | 230 if (sign (fc - fa) * sign (fc - fb) >= 0) |
8507 | 231 ## The new point broke monotonicity. |
232 ## Disable inverse cubic. | |
8305 | 233 fe = fc; |
234 else | |
235 e = d; fe = fd; | |
236 endif | |
237 | |
8507 | 238 ## Bracketing. |
8305 | 239 if (sign (fa) * sign (fc) < 0) |
240 d = b; fd = fb; | |
241 b = c; fb = fc; | |
242 elseif (sign (fb) * sign (fc) < 0) | |
243 d = a; fd = fa; | |
244 a = c; fa = fc; | |
245 elseif (fc == 0) | |
246 a = b = c; fa = fb = fc; | |
247 info = 1; | |
248 break; | |
249 else | |
8507 | 250 ## This should never happen. |
8468
866492035ecf
fsolve.m, fzero.m: undo part of previous change
John W. Eaton <jwe@octave.org>
parents:
8467
diff
changeset
|
251 error ("fzero:bracket", "fzero: zero point is not bracketed"); |
8305 | 252 endif |
253 | |
8507 | 254 ## If there's an output function, use it now. |
8305 | 255 if (outfcn) |
10296 | 256 optv.funccount = nfev; |
8305 | 257 optv.fval = fval; |
258 optv.iteration = niter; | |
259 if (outfcn (x, optv, "iter")) | |
260 info = -1; | |
261 break; | |
262 endif | |
263 endif | |
264 | |
265 if (abs (fa) < abs (fb)) | |
266 u = a; fu = fa; | |
267 else | |
268 u = b; fu = fb; | |
269 endif | |
270 if (b - a <= 2*(2 * abs (u) * eps + tolx)) | |
271 info = 1; | |
272 break; | |
273 endif | |
274 | |
8507 | 275 ## Skip bisection step if successful reduction. |
8305 | 276 if (itype == 5 && (b - a) <= mba) |
277 itype = 2; | |
278 endif | |
279 if (itype == 2) | |
280 mba = mu * (b - a); | |
281 endif | |
282 endwhile | |
283 | |
284 output.iterations = niter; | |
10296 | 285 output.funcCount = nfev; |
8305 | 286 output.bracket = [a, b]; |
287 output.bracketf = [fa, fb]; | |
288 | |
289 endfunction | |
290 | |
8507 | 291 ## An assistant function that evaluates a function handle and checks for |
8467
77b8d4aa2743
fsolve.m, fzero.m: style fixes; use strcmpi to compare options
John W. Eaton <jwe@octave.org>
parents:
8305
diff
changeset
|
292 ## bad results. |
8305 | 293 function fx = guarded_eval (fun, x) |
294 fx = fun (x); | |
295 fx = fx(1); | |
296 if (! isreal (fx)) | |
8468
866492035ecf
fsolve.m, fzero.m: undo part of previous change
John W. Eaton <jwe@octave.org>
parents:
8467
diff
changeset
|
297 error ("fzero:notreal", "fzero: non-real value encountered"); |
8305 | 298 elseif (isnan (fx)) |
8468
866492035ecf
fsolve.m, fzero.m: undo part of previous change
John W. Eaton <jwe@octave.org>
parents:
8467
diff
changeset
|
299 error ("fzero:isnan", "fzero: NaN value encountered"); |
8305 | 300 endif |
301 endfunction | |
302 | |
10296 | 303 %!shared opt0 |
304 %! opt0 = optimset ("tolx", 0); | |
305 %!assert(fzero(@cos, [0, 3], opt0), pi/2, 10*eps) | |
306 %!assert(fzero(@(x) x^(1/3) - 1e-8, [0,1], opt0), 1e-24, 1e-22*eps) |