octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #36923] Bug in fminbnd?


From: Nir Krakauer
Subject: [Octave-bug-tracker] [bug #36923] Bug in fminbnd?
Date: Mon, 23 Jul 2012 16:19:03 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3

URL:
  <http://savannah.gnu.org/bugs/?36923>

                 Summary: Bug in fminbnd?
                 Project: GNU Octave
            Submitted by: nir_krakauer
            Submitted on: Mon 23 Jul 2012 04:19:02 PM GMT
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Nir Krakauer
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.6.1
        Operating System: Any

    _______________________________________________________

Details:

For functions that are flat after the first 38% (2-phi) of the interval,
fminbnd doesn't return the minimum even if it's reached at one endpoint, e.g.

[x, fval, info] = fminbnd(@(x) (x > 0.3), 0, 1)

returns

x =  1.00000
fval =  1
info =  1


This can apparently be fixed at the cost of evaluating the function at the
interval endpoints. I inserted after line 96 ('fv = fw = fval = fun (x);') in
fminbnd.m


  ## set x equal to one of the endpoints if the function value there is lower
than at v
  fa = fun (a);
  if fa < fv
        x = a;
        w = v;
        fw = fv;
        fval = fa;
  end
  fb = fun (b);
  if fb < fv
        x = b;
        w = v;
        fw = fv;
        fval = fb;
  end


After this modification,

[x, fval, info] = fminbnd(@(x) (x > 0.3), 0, 1)

returns, correctly,

x =  5.7206e-09
fval = 0
info =  1




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?36923>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]