Mercurial > hg > octave-nkf
changeset 18315:61dab64aa5a6
fminbnd.m: Correctly handle certain functions with odd discontinuities (bug #36923)
* fminbnd.m: Correctly get a minimum result even for functions with
specifically placed discontinuities which were defeating the Golden Section
search. Add a %!test which verifies the behavior.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 15 Jan 2014 17:21:53 -0800 |
parents | 906e95708ec1 |
children | 9b163d6c1de7 |
files | scripts/optimization/fminbnd.m |
diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/optimization/fminbnd.m +++ b/scripts/optimization/fminbnd.m @@ -170,7 +170,7 @@ ## update a, b, v, w, and x - if (fu <= fval) + if (fu < fval) if (u < x) b = x; else @@ -283,4 +283,5 @@ %!assert (fminbnd (@(x) (x - 1e-3)^4, -1, 1, opt0), 1e-3, 10e-3*sqrt (eps)) %!assert (fminbnd (@(x) abs (x-1e7), 0, 1e10, opt0), 1e7, 10e7*sqrt (eps)) %!assert (fminbnd (@(x) x^2 + sin (2*pi*x), 0.4, 1, opt0), fzero (@(x) 2*x + 2*pi*cos (2*pi*x), [0.4, 1], opt0), sqrt (eps)) +%!assert (fminbnd (@(x) x > 0.3, 0, 1) < 0.3)