* [Bug math/14473] Inaccurate CPOWF function on x86_32 and x86_64
2012-08-15 15:10 [Bug math/14473] New: Inaccurate CPOWF function on x86_32 and x86_64 liubov.dmitrieva at gmail dot com
@ 2012-08-15 15:23 ` joseph at codesourcery dot com
2012-08-16 7:52 ` liubov.dmitrieva at gmail dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: joseph at codesourcery dot com @ 2012-08-15 15:23 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14473
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-08-15 15:22:55 UTC ---
Again, please give testcases that use hex floats rather than using type
punning, so that the test inputs can more readily be extracted for use
elsewhere.
cpowf, cpow, cpowl are generically inaccurate for all architectures and
floating-point formats - there's nothing x86-specific. They are also by
far the hardest complex functions to make accurate; the errors in this
example are tiny compared to those you can get with properly chosen
examples. In general for long double you need to compute log and atan2
results to over 16000 places to get good results for cpowl. Consider
cpowl (LDBL_MAX, I * LDBL_MAX) for example - you need to compute LDBL_MAX
* log (LDBL_MAX), reduced mod 2pi. Many cases will overflow or underflow
but you still need to determine the signs of zero or infinity in those
cases.
--
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/14473] Inaccurate CPOWF function on x86_32 and x86_64
2012-08-15 15:10 [Bug math/14473] New: Inaccurate CPOWF function on x86_32 and x86_64 liubov.dmitrieva at gmail dot com
2012-08-15 15:23 ` [Bug math/14473] " joseph at codesourcery dot com
@ 2012-08-16 7:52 ` liubov.dmitrieva at gmail dot com
2013-01-25 16:49 ` glisse at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: liubov.dmitrieva at gmail dot com @ 2012-08-16 7:52 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14473
--- Comment #2 from Liubov Dmitrieva <liubov.dmitrieva at gmail dot com> 2012-08-16 07:51:45 UTC ---
Reformatted test case:
#include <stdio.h>
#include <math.h>
#include <complex.h>
#include <fenv.h>
#define real(a) (((float*)&(a))[0])
#define imag(a) (((float*)&(a))[1])
int main() {
float _Complex a,b,r1;
double _Complex r2;
a=-0x1.1c71c8p-1 + I * -0x1.c71c7cp-4; //argument
b= 0x1.1c71c6p-1 + I * -0x1.c71c7cp-4; //argument
fesetround(FE_TONEAREST);
r1 = cpowf(a,b); //actual result
r2 = cpow(a,b); //actual result 2
printf("inputs: a = %15.6a + I * %15.6a\n", creal(a), cimag(a));
printf(" b = %15.6a + I * %15.6a\n", creal(b), cimag(b));
printf("actual = %15.6a + I * %15.6a\n", creal(r1),cimag(r1));
printf("expected = %15.6a + I * %15.6a\n", creal(r2),cimag(r2));
printf("error = %15f + I * %15f ulp\n", fabs(creal(r1) - creal(r2)) *
exp2(23.0-logbf(creal(r1))),
fabs(cimag(r1) - cimag(r2)) *
exp2(23.0-logbf(cimag(r1))) );
return 0;
}
Results (same x86 and x86_64)
inputs: a = -0x1.1c71c8p-1 + I * -0x1.c71c7cp-4
b = 0x1.1c71c6p-1 + I * -0x1.c71c7cp-4
actual = -0x1.df1246p-11 + I * -0x1.0d38dap-1
expected = -0x1.df1aefp-11 + I * -0x1.0d38d9p-1
error = 1108.410103 + I * 0.495932 ulp
--
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/14473] Inaccurate CPOWF function on x86_32 and x86_64
2012-08-15 15:10 [Bug math/14473] New: Inaccurate CPOWF function on x86_32 and x86_64 liubov.dmitrieva at gmail dot com
2012-08-15 15:23 ` [Bug math/14473] " joseph at codesourcery dot com
2012-08-16 7:52 ` liubov.dmitrieva at gmail dot com
@ 2013-01-25 16:49 ` glisse at gcc dot gnu.org
2013-04-04 16:12 ` [Bug math/14473] Inaccurate CPOW* function on all machines carlos at redhat dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-01-25 16:49 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14473
Marc Glisse <glisse at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |glisse at gcc dot gnu.org
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> 2013-01-25 16:48:59 UTC ---
Hello,
as an additional data point, using cpow to compute i^2 yields a number with a
non-zero imaginary part, as was noticed in later messages of the conversation
started here:
http://gcc.gnu.org/ml/libstdc++/2013-01/msg00058.html
--
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/14473] Inaccurate CPOW* function on all machines.
2012-08-15 15:10 [Bug math/14473] New: Inaccurate CPOWF function on x86_32 and x86_64 liubov.dmitrieva at gmail dot com
` (2 preceding siblings ...)
2013-01-25 16:49 ` glisse at gcc dot gnu.org
@ 2013-04-04 16:12 ` carlos at redhat dot com
2013-04-04 16:13 ` carlos at redhat dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: carlos at redhat dot com @ 2013-04-04 16:12 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14473
Carlos O'Donell <carlos at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2013-04-04
CC| |carlos at redhat dot com
Summary|Inaccurate CPOWF function |Inaccurate CPOW* function
|on x86_32 and x86_64 |on all machines.
--- Comment #4 from Carlos O'Donell <carlos at redhat dot com> 2013-04-04 16:12:37 UTC ---
Related LSB test suite failure "/olver/math/cexp/tests/cpow_spec"
https://lsbbugs.linuxfoundation.org/show_bug.cgi?id=2912
--
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/14473] Inaccurate CPOW* function on all machines.
2012-08-15 15:10 [Bug math/14473] New: Inaccurate CPOWF function on x86_32 and x86_64 liubov.dmitrieva at gmail dot com
` (3 preceding siblings ...)
2013-04-04 16:12 ` [Bug math/14473] Inaccurate CPOW* function on all machines carlos at redhat dot com
@ 2013-04-04 16:13 ` carlos at redhat dot com
2013-08-05 19:27 ` licquia at linuxfoundation dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: carlos at redhat dot com @ 2013-04-04 16:13 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14473
Carlos O'Donell <carlos at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://lsbbugs.linuxfounda
| |tion.org/show_bug.cgi?id=29
| |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/14473] Inaccurate CPOW* function on all machines.
2012-08-15 15:10 [Bug math/14473] New: Inaccurate CPOWF function on x86_32 and x86_64 liubov.dmitrieva at gmail dot com
` (4 preceding siblings ...)
2013-04-04 16:13 ` carlos at redhat dot com
@ 2013-08-05 19:27 ` licquia at linuxfoundation dot org
2013-12-06 14:07 ` mwelinder at gmail dot com
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: licquia at linuxfoundation dot org @ 2013-08-05 19:27 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14473
Jeff Licquia <licquia at linuxfoundation dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |licquia at linuxfoundation dot org
--
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/14473] Inaccurate CPOW* function on all machines.
2012-08-15 15:10 [Bug math/14473] New: Inaccurate CPOWF function on x86_32 and x86_64 liubov.dmitrieva at gmail dot com
` (5 preceding siblings ...)
2013-08-05 19:27 ` licquia at linuxfoundation dot org
@ 2013-12-06 14:07 ` mwelinder at gmail dot com
2013-12-06 14:17 ` mwelinder at gmail dot com
2014-06-17 18:38 ` fweimer at redhat dot com
8 siblings, 0 replies; 10+ messages in thread
From: mwelinder at gmail dot com @ 2013-12-06 14:07 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14473
M Welinder <mwelinder at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mwelinder at gmail dot com
--- Comment #5 from M Welinder <mwelinder at gmail dot com> ---
There are at least two classes of accuracy issues with cpow(z,z2):
(1) Insufficient precision in intermediate results, affecting primarily "large"
arguments
(2) Bad handling of |z1| == 1. Sample program below. This is actually
easy to solve: use atan2pi, sinpi, and cospi instead of atan2, sin, and
cos.
#include <complex.h>
#include <stdio.h>
#include <math.h>
int dont_optimize = 0;
int
main (int argc, char **argv)
{
double complex z1, z2, z;
/*
* z here should be real. I see an imaginary part of
* 2.54571e-17, except when gcc is allowed to optimize
* the whole thing at compile time. Exact result should
* be -exp(-pi/2) =~ -0.20788
*
* Surprise: Mathematica gets it wrong too. I see the
* same value as gcc for N[I^(I+2)].
*/
z1 = dont_optimize + I;
z2 = 2 + I;
z = cpow (z1, z2);
printf ("%g + %g i\n", creal (z), cimag (z));
/*
* Really scary version. Exact result is exp(-pi/2)
* =~ 0.20788. I see "0.177058 + -0.108924 i".
*/
z2 = ldexp (1,53) + I;
z = cpow (z1, z2);
printf ("%g + %g i\n", creal (z), cimag (z));
return 0;
}
--
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/14473] Inaccurate CPOW* function on all machines.
2012-08-15 15:10 [Bug math/14473] New: Inaccurate CPOWF function on x86_32 and x86_64 liubov.dmitrieva at gmail dot com
` (6 preceding siblings ...)
2013-12-06 14:07 ` mwelinder at gmail dot com
@ 2013-12-06 14:17 ` mwelinder at gmail dot com
2014-06-17 18:38 ` fweimer at redhat dot com
8 siblings, 0 replies; 10+ messages in thread
From: mwelinder at gmail dot com @ 2013-12-06 14:17 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14473
--- Comment #6 from M Welinder <mwelinder at gmail dot com> ---
Ok, make that three classes of inaccuracy:
(3) Bad handling of real arguments. I see different values in this
case:
z1 = dont_optimize + 607/128;
z2 = 1234567 / 8192;
z = cpow (z1, z2);
printf ("%.20g + %g i\n", creal (z), cimag (z));
printf ("%.20g\n", pow (creal (z1), creal (z2)));
I get:
2.0370359763344673153e+90 + 0 i
2.0370359763344860863e+90
For real arguments cpow should defer to pow. (Or at least use a method
that is no less accurate than pow; I think the current evidence is that
pow is better.)
--
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/14473] Inaccurate CPOW* function on all machines.
2012-08-15 15:10 [Bug math/14473] New: Inaccurate CPOWF function on x86_32 and x86_64 liubov.dmitrieva at gmail dot com
` (7 preceding siblings ...)
2013-12-06 14:17 ` mwelinder at gmail dot com
@ 2014-06-17 18:38 ` fweimer at redhat dot com
8 siblings, 0 replies; 10+ messages in thread
From: fweimer at redhat dot com @ 2014-06-17 18:38 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14473
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