Skip to content

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Dec 2, 2024

Note, that transformed expression is not an equivalent for original one (1/exp(-x) != exp(x) in general for floating-point numbers). Though, the difference seems to be ~1ULP for good libm implementations.

It's more interesting why division was used from beginning. Closest algorithm I've found (no error checks, of course;)) - it's Algorithm 190 from ACM: https://dl.acm.org/doi/10.1145/366663.366679. It uses subtraction in the exponent.

(cherry picked from commit f7bb658)

(cherry picked from commit f41d8d8)

Co-authored-by: Miss Islington (bot) [email protected]
Co-authored-by: Sergey B Kirpichev [email protected]

…_pow() (pythonGH-127211) (pythonGH-127216)

Note, that transformed expression is not an equivalent for original one (1/exp(-x) != exp(x) in general for floating-point numbers). Though, the difference seems to be ~1ULP for good libm implementations.

It's more interesting why division was used from beginning. Closest algorithm I've found (no error checks, of course;)) - it's Algorithm 190 from ACM: https://dl.acm.org/doi/10.1145/366663.366679. It uses subtraction in the exponent.

(cherry picked from commit f7bb658)

(cherry picked from commit f41d8d8)

Co-authored-by: Miss Islington (bot) <[email protected]>
Co-authored-by: Sergey B Kirpichev <[email protected]>
@gpshead gpshead enabled auto-merge (squash) December 2, 2024 19:29
@gpshead gpshead merged commit 8fffbb0 into python:3.12 Dec 2, 2024
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants