Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Lib/test/mathdata/cmath_testcases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,13 @@ atan0301 atan 1e-155 1.0 -> 0.78539816339744828 178.79691829731851
atan0302 atan 9.9999999999999999e-161 -1.0 -> 0.78539816339744828 -184.55338102980363
atan0303 atan -1e-165 1.0 -> -0.78539816339744828 190.30984376228875
atan0304 atan -9.9998886718268301e-321 -1.0 -> -0.78539816339744828 -368.76019403576692
-- gh-157859: real part at and next to sqrt(DBL_MIN) = 2**-511 (see atanh0305-0310)
atan0305 atan 1.4916681462400412e-154 1.0 -> 0.78539816339744828 177.445678223346
atan0306 atan 1.4916681462400413e-154 1.0 -> 0.78539816339744828 177.445678223346
atan0307 atan 1.4916681462400417e-154 1.0 -> 0.78539816339744828 177.445678223346
atan0308 atan -1.4916681462400413e-154 1.0 -> -0.78539816339744828 177.445678223346
atan0309 atan 1.4916681462400413e-154 -1.0 -> 0.78539816339744828 -177.445678223346
atan0310 atan -1.4916681462400413e-154 -1.0 -> -0.78539816339744828 -177.445678223346

-- Additional real values (mpmath)
atan0400 atan 1.7976931348623157e+308 0.0 -> 1.5707963267948966192 0.0
Expand Down Expand Up @@ -1043,6 +1050,14 @@ atanh0301 atanh 1.0 9.9999999999999997e-155 -> 177.64562575082149 0.785398163397
atanh0302 atanh -1.0 1e-161 -> -185.70467357630065 0.78539816339744828
atanh0303 atanh 1.0 -1e-165 -> 190.30984376228875 -0.78539816339744828
atanh0304 atanh -1.0 -9.8813129168249309e-324 -> -372.22003596069061 -0.78539816339744828
-- gh-157859: imaginary part at and next to sqrt(DBL_MIN) = 2**-511, where
-- the near-pole and general formulas meet; the boundary value overflowed.
atanh0305 atanh 1.0 1.4916681462400412e-154 -> 177.445678223346 0.78539816339744828
atanh0306 atanh 1.0 1.4916681462400413e-154 -> 177.445678223346 0.78539816339744828
atanh0307 atanh 1.0 1.4916681462400417e-154 -> 177.445678223346 0.78539816339744828
atanh0308 atanh 1.0 -1.4916681462400413e-154 -> 177.445678223346 -0.78539816339744828
atanh0309 atanh -1.0 1.4916681462400413e-154 -> -177.445678223346 0.78539816339744828
atanh0310 atanh -1.0 -1.4916681462400413e-154 -> -177.445678223346 -0.78539816339744828

-- special values
atanh1000 atanh 0.0 0.0 -> 0.0 0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :func:`cmath.atanh` and :func:`cmath.atan` returning an infinite
component instead of a finite result for certain inputs near their poles.
2 changes: 1 addition & 1 deletion Modules/cmathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ cmath_atanh_impl(PyObject *module, Py_complex z)
r.real = z.real/4./h/h;
r.imag = copysign(Py_MATH_PI/2., z.imag);
errno = 0;
} else if (z.real == 1. && ay < CM_SQRT_DBL_MIN) {
} else if (z.real == 1. && ay <= CM_SQRT_DBL_MIN) {
/* C99 standard says: atanh(1+/-0.) should be inf +/- 0i */
if (ay == 0.) {
r.real = INF;
Expand Down
Loading