public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/13629] New: clog() returns wrong values around z=1
@ 2012-01-27 14:12 fxcoudert at gcc dot gnu.org
  2012-01-27 15:57 ` [Bug math/13629] " tprince at computer dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2012-01-27 14:12 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13629

             Bug #: 13629
           Summary: clog() returns wrong values around z=1
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj@suse.de
        ReportedBy: fxcoudert@gcc.gnu.org
    Classification: Unclassified


On the example below, clog() is called on value 1+epsilon*I. The result (first
output line) is pretty different from the expected result, calculated in the
second output line as a second-order series expansion.

I could reproduce it with glibc versions 2.5, 2.11.2, and 2.13, on both i686
and x86_64 systems (and many compilers).


$ cat a.c                            
#include <math.h>
#include <complex.h>
#include <stdio.h>

int main ()
{
  complex double z, fz,gz;
  z = 1.0f + 0.00000001f*I;
  fz = clog(z);
  gz = (z-1) - (z-1)*(z-1)/2;
  printf (" %.15e + %.15ei\n", creal(fz), cimag(fz));
  printf (" %.15e + %.15ei\n", creal(gz), cimag(gz));
  return 0;
}
$ gcc a.c -lm -O0 -W -Wall -std=c99 && ./a.out
 0.000000000000000e+00 + 1.000000000000000e-08i
 5.000000000000001e-17 + 1.000000000000000e-08i

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug math/13629] clog() returns wrong values around z=1
  2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
@ 2012-01-27 15:57 ` tprince at computer dot org
  2012-01-27 15:58 ` tprince at computer dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tprince at computer dot org @ 2012-01-27 15:57 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13629

--- Comment #1 from Tim Prince <tprince at computer dot org> 2012-01-27 15:57:08 UTC ---
Created attachment 6179
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6179
result of toms714 test of complex double log, against Intel math library

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug math/13629] clog() returns wrong values around z=1
  2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
  2012-01-27 15:57 ` [Bug math/13629] " tprince at computer dot org
@ 2012-01-27 15:58 ` tprince at computer dot org
  2012-01-27 16:00 ` tprince at computer dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tprince at computer dot org @ 2012-01-27 15:58 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13629

--- Comment #2 from Tim Prince <tprince at computer dot org> 2012-01-27 15:57:55 UTC ---
Created attachment 6180
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6180
result of toms714 test of complex double log, against glibc-2.12

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug math/13629] clog() returns wrong values around z=1
  2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
  2012-01-27 15:57 ` [Bug math/13629] " tprince at computer dot org
  2012-01-27 15:58 ` tprince at computer dot org
@ 2012-01-27 16:00 ` tprince at computer dot org
  2012-03-03 21:28 ` jsm28 at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tprince at computer dot org @ 2012-01-27 16:00 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13629

Tim Prince <tprince at computer dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tprince at computer dot org

--- Comment #3 from Tim Prince <tprince at computer dot org> 2012-01-27 16:00:17 UTC ---
I ran the TOMS 714 test against glibc-2.12-1.7.el6.x86_64 and Intel libimf
(latter requires option -fp-model source).
This test doesn't exercise the neighborhood of (1, 0).
The only outright failure for glibc came with LOG(  0.1797693+309 
0.1797693+309).
Otherwise, the maximum errors in each tested region are similar for the two
libraries, but the number of unequal comparisons is about 10 times as many for
glibc.
Comparisons attached: 
dclog_gf.txt (gfortran/glibc)
dclog_if.txt (ifort/imf)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug math/13629] clog() returns wrong values around z=1
  2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-01-27 16:00 ` tprince at computer dot org
@ 2012-03-03 21:28 ` jsm28 at gcc dot gnu.org
  2012-03-20  0:39 ` jsm28 at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-03-03 21:28 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13629

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|aj at suse dot de           |unassigned at sourceware
                   |                            |dot org

--- Comment #4 from Joseph Myers <jsm28 at gcc dot gnu.org> 2012-03-03 21:26:56 UTC ---
Confirmed in current source code by inspection.  The implementation approach of
log(hypot) for finding the real part of clog will cause undue overflows for
large input, inaccurate results from undue underflow for subnormal input, and
inaccurate results for z close to |z|=1 (not just close to 1 itself).  The
general case of z close to that circle will be more complicated to fix than the
overflow and underflow cases.

clog10 (a GNU extension, name reserved in ISO C) has the same issues.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug math/13629] clog() returns wrong values around z=1
  2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-03-03 21:28 ` jsm28 at gcc dot gnu.org
@ 2012-03-20  0:39 ` jsm28 at gcc dot gnu.org
  2012-07-26 11:36 ` jsm28 at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-03-20  0:39 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13629

--- Comment #5 from Joseph Myers <jsm28 at gcc dot gnu.org> 2012-03-19 20:21:02 UTC ---
Overflows and underflows for clog and clog10 fixed by:

commit 1897ad44326bb7761dcda46132ae303f7288aba9
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Mon Mar 19 20:13:10 2012 +0000

    Fix clog overflow/underflow (bug 13629).

The problems near |z|=1 are *not* yet fixed (and will be somewhat more involved
to fix than the overflows/underflows).

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug math/13629] clog() returns wrong values around z=1
  2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2012-03-20  0:39 ` jsm28 at gcc dot gnu.org
@ 2012-07-26 11:36 ` jsm28 at gcc dot gnu.org
  2012-07-31 14:26 ` jsm28 at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-07-26 11:36 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13629

--- Comment #6 from Joseph Myers <jsm28 at gcc dot gnu.org> 2012-07-26 11:35:59 UTC ---
The next case - where real or imaginary part of the argument to clog or clog10
has absolute value exactly 1, and the other part is small (the only case where
underflow exceptions may correctly occur for the real part of the result) - has
been fixed by:

commit da865e95bcf9a5365de78fa6b5c681aca0a1bb46
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Thu Jul 26 11:31:35 2012 +0000

    Improve clog, clog10 handling of values with real or imaginary part 1 (bug
13629).

Some other cases near |z|=1 remain to be fixed.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug math/13629] clog() returns wrong values around z=1
  2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2012-07-26 11:36 ` jsm28 at gcc dot gnu.org
@ 2012-07-31 14:26 ` jsm28 at gcc dot gnu.org
  2012-09-25 19:49 ` jsm28 at gcc dot gnu.org
  2014-06-27 10:03 ` fweimer at redhat dot com
  8 siblings, 0 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-07-31 14:26 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13629

--- Comment #7 from Joseph Myers <jsm28 at gcc dot gnu.org> 2012-07-31 14:25:26 UTC ---
Cases where the real or imaginary part has absolute value > 1 fixed by:

commit d0419dbfbd19cb01398d43895a679c0bcb961070
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Jul 31 14:21:19 2012 +0000

    Improve clog, clog10 handling of values with real or imaginary part
slightly above 1 (bug 13629).

The remaining cases not yet fixed are those close to |z| = 1, where both real
and imaginary parts have absolute value < 1.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug math/13629] clog() returns wrong values around z=1
  2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2012-07-31 14:26 ` jsm28 at gcc dot gnu.org
@ 2012-09-25 19:49 ` jsm28 at gcc dot gnu.org
  2014-06-27 10:03 ` fweimer at redhat dot com
  8 siblings, 0 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-09-25 19:49 UTC (permalink / raw)
  To: glibc-bugs


http://sourceware.org/bugzilla/show_bug.cgi?id=13629

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #8 from Joseph Myers <jsm28 at gcc dot gnu.org> 2012-09-25 19:49:01 UTC ---
The remaining cases fixed for 2.17 by:

commit d032e0d29b6ed9d3844916ada0ead19c3190ff9a
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Sep 25 19:43:49 2012 +0000

    Fix inaccuracy of clog, clog10 near |z| = 1 (bug 13629).

Results should now be within a few ulps of the correct results in both the real
and imaginary parts, for all of clog, clogf, clogl, clog10, clog10f, clog10l
over the whole input range, and with exceptions (other than maybe inexact) in
accord with the results.  If you find any remaining problems, please file
separate bugs for them.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug math/13629] clog() returns wrong values around z=1
  2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2012-09-25 19:49 ` jsm28 at gcc dot gnu.org
@ 2014-06-27 10:03 ` fweimer at redhat dot com
  8 siblings, 0 replies; 10+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 10:03 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=13629

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-06-27 10:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-27 14:12 [Bug math/13629] New: clog() returns wrong values around z=1 fxcoudert at gcc dot gnu.org
2012-01-27 15:57 ` [Bug math/13629] " tprince at computer dot org
2012-01-27 15:58 ` tprince at computer dot org
2012-01-27 16:00 ` tprince at computer dot org
2012-03-03 21:28 ` jsm28 at gcc dot gnu.org
2012-03-20  0:39 ` jsm28 at gcc dot gnu.org
2012-07-26 11:36 ` jsm28 at gcc dot gnu.org
2012-07-31 14:26 ` jsm28 at gcc dot gnu.org
2012-09-25 19:49 ` jsm28 at gcc dot gnu.org
2014-06-27 10:03 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).