Skip to content

gh-133895: correct values of cmath.cosh/sinh in case of overflows #135603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

skirpichev
Copy link
Contributor

@skirpichev skirpichev commented Jun 17, 2025

This is a split-off gh-134995.

The C17 standard says (cis(y) is defined as cos(y) + i sin(y)):

  • ccosh(+∞ + i0) returns +∞ + i0.
  • ccosh(+∞ + iy) returns +∞ cis(y), for finite nonzero y. and
  • csinh(+∞ + i0) returns +∞ + i0.
  • csinh(+∞ + iy) returns +∞ cis(y), for positive finite y.

So far values, computed for exceptions, aren't accessible from the pure-Python world, yet we are trying to be correct in other places. The Lib/test/mathdata/cmath_testcases.txt has data points with correct numbers (see cosh0032 and sinh0032).

Also, use AC magic for the rect() value.

This is a split-off pythongh-134995.

The C17 standard says (cis(y) is defined as cos(y) + i sin(y)):
* ccosh(+∞ + i0) returns +∞ + i0.
* ccosh(+∞ + iy) returns +∞ cis(y), for finite nonzero y.
and
* csinh(+∞ + i0) returns +∞ + i0.
* csinh(+∞ + iy) returns +∞ cis(y), for positive finite y.

So far values, computed for exceptions, aren't accessible from the
pure-Python world, yet we are trying to be correct in other places.  The
Lib/test/mathdata/cmath_testcases.txt has data points with correct
numbers (see cosh0032 and sinh0032).

Also, use AC magic for the rect() value.
@skirpichev skirpichev force-pushed the fix-cmath-sinh-and-cosh/133895 branch from 303842c to d5bd0a0 Compare June 17, 2025 06:41
@skirpichev skirpichev changed the title gh-134995: correct values of cmath.cosh/sinh in case of overflows gh-133895: correct values of cmath.cosh/sinh in case of overflows Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant