bugGNU Octave - Bugs: bug #46658, fzero with single precision args...

 
 

bug #46658: fzero with single precision args fails to terminate

Submitted by:  Ceral Paquet <octavebugs>
Submitted on:  Thu 10 Dec 2015 04:11:56 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 4.0.0Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Mon 18 Jan 2016 06:23:19 PM UTC, comment #6:

I made the change to fzero to correctly choose a stopping tolerance on the stable branch (http://hg.savannah.gnu.org/hgweb/octave/rev/323e92c4589f). Even though there were no problems reported, I also updated the other scripts in the optimization directory to correctly choose a stopping tolerance (http://hg.savannah.gnu.org/hgweb/octave/rev/52af4092f863).

Closing report.

Rik <rik5>
Project Administrator
Fri 11 Dec 2015 09:51:32 AM UTC, comment #5:

Nice. Works for me with all combos of single and double.

I also looked at

fminsearch.m
fsolve.m
fminbnd.m
fminunc.m

There are a couple of places where class(x0) is used but when I tested them with with similar problems there was no problem with any combination of single/double.

fminunc.m: macheps = eps (class (x0));
fsolve.m: macheps = eps (class (x0));

The TolX and TolFun are hardcoded (to 1e-7).

Ceral Paquet <octavebugs>
Thu 10 Dec 2015 10:08:42 PM UTC, comment #4:

fzero is looking only at the class of x0 to decide what eps to use. It's pretty simple to extend that to include looking at the results of the function evaluation. The function fzero is written in fzero.m which means you can go ahead and change it quite easily.

I made a quick attempt which seems to work for me. See the attached cset.

(file #35694)

Rik <rik5>
Project Administrator
Thu 10 Dec 2015 06:01:53 PM UTC, comment #3:

Problem also goes away if fun returns a double. So, basically x0 and the return value of func need to be the same class.

Ceral Paquet <octavebugs>
Thu 10 Dec 2015 05:43:04 PM UTC, comment #2:

Seems the problem goes away if the initial estimate is a single too. Perhaps eps is being derived from the initial estimate, whereas it should be eps('single') if any of the inputs is single.

Ceral Paquet <octavebugs>
Thu 10 Dec 2015 04:23:14 PM UTC, comment #1:

Setting TolX with

works for me.

Matlab definitely documents that the default TolX value is eps("double"), which is what Octave's fzero is using.

Mike Miller <mtmiller>
Project Administrator
Thu 10 Dec 2015 04:11:56 PM UTC, original submission:

The code below does not terminate when data are in single precision although it works fine with doubles. Matlab works in both instances.

Passing opts = optimset('TolX',class(x)) did not fix it. That uses 1.16e-7 rather than 2.2e-16. It seems to need even lower precision, like 1e-6, to finish.

Ceral Paquet <octavebugs>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #35694:  fzero.cset added by rik5 (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by octavebugs (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 18 Jan 2016 06:23:19 PM UTCrik5Item GroupPerformance=>Incorrect Result
      StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Thu 10 Dec 2015 10:08:42 PM UTCrik5Attached File-=>Added fzero.cset, #35694
      StatusConfirmed=>Patch Submitted
    Thu 10 Dec 2015 04:23:14 PM UTCmtmillerCategoryNone=>Octave Function
      Item GroupNone=>Performance
      StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1