Message117179
Thanks; so it's probably not an optimization bug, but rather a math library bug somewhere.
And thanks for the tanh result; unfortunately I asked the wrong question---I meant to ask about atanh(complex(-0.0, 0.0)) :(
Analysis: atan(z) is computed internally as atanh(iz) / i. So if the imaginary part of atan is coming out wrong, it's probably because the real part of atanh is incorrect. So I'd expect atanh(complex(-0.0, 0.0)) to produce 0.0j (instead of the correct answer of -0.0 + 0.0j).
The real part of atanh(x + iy) is computed (for a region of the complex plane containing 0.0) using the formula:
real_part = log1p(4.*z.real/((1-z.real)*(1-z.real) + z.imag * z.imag))/4.;
My best guess is that the log1p function is dropping the sign on a negative zero. But in that case I'd expect test_math to fail on your system, too.
Could you try the following experiments, and let me know what you get? (Feel free to stop as soon as your results start to differ from what's below.)
>>> import math, cmath
>>> math.log1p(-0.0)
-0.0
>>> z = complex(-0.0, 0.0)
>>> 4. * z.real
-0.0
>>> (1 - z.real) * (1 - z.real) + z.imag * z.imag
1.0
>>> 4. * z.real / ((1 - z.real) * (1 - z.real) + z.imag * z.imag)
-0.0
>>> math.log1p(4. * z.real / ((1 - z.real) * (1 - z.real) + z.imag * z.imag))
-0.0
>>> math.log1p(4. * z.real / ((1 - z.real) * (1 - z.real) + z.imag * z.imag)) / 4.
-0.0
>>> cmath.atanh(z).real
-0.0 |
|
Date |
User |
Action |
Args |
2010-09-23 10:36:23 | mark.dickinson | set | recipients:
+ mark.dickinson, sable |
2010-09-23 10:36:23 | mark.dickinson | set | messageid: <1285238183.07.0.773949712605.issue9920@psf.upfronthosting.co.za> |
2010-09-23 10:36:21 | mark.dickinson | link | issue9920 messages |
2010-09-23 10:36:20 | mark.dickinson | create | |
|