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

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

[Octave-bug-tracker] [bug #46658] fzero with single precision args fails


From: Ceral Paquet
Subject: [Octave-bug-tracker] [bug #46658] fzero with single precision args fails to terminate
Date: Thu, 10 Dec 2015 16:11:58 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0

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

                 Summary: fzero with single precision args fails to terminate
                 Project: GNU Octave
            Submitted by: octavebugs
            Submitted on: Thu 10 Dec 2015 04:11:56 PM GMT
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.0.0
        Operating System: GNU/Linux

    _______________________________________________________

Details:

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.



% data
x = -20:20;
y = [
0.030339992
0.033821423
0.041702233
0.054150544
0.069778219
0.085964844
0.099779591
 0.10928077
 0.11479455
 0.11970813
 0.13039705
 0.15512653
 0.20207173
 0.27689669
 0.38052434
 0.50775862
 0.64725506
 0.78300703
 0.89711601
 0.97325319
          1
  0.9732579
 0.89712346
 0.78301448
 0.64725971
 0.50775862
 0.38051969
 0.27688923
 0.20206429
 0.15512197
 0.13039705
 0.11971273
   0.114802
 0.10928822
0.099784195
0.085964851
0.069773585
0.054143101
0.041694809
0.033816814
0.030339992
];

plot(x,y)

% these prevent fzero from terminating
x = single(x);
y = single(y);

% find FWHM
myfunc = @(x,y,pt) interp1(x,y,pt,'spline') - 0.5;

pt0 = 5;
pt = fzero(@(pt)myfunc(x,y,pt),pt0)






    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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