You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The derivative of an answer at a large hyperbolic argument evaluates to NaN or loses its imaginary part #1944
Found while checking Rubi 6.1.5, row 94 (1/sqrt(a + i a sinh(c + d x))) for 2.6.0. The answer is right. The library's own numerical evaluation of its derivative is not, at large arguments.
With a, c, d = 21/10, 19/10, 17/10 and x = 227283/1250 (so t = c + d x ≈ 311), the true value of the derivative is r(1 − i) with r ≈ 2.0185e-68. That is what mpmath gives at dps 400, and what the library gives when it evaluates the integrand itself.
The derivative of the answer, Differentiate(x) then substituted with exact rationals and evaluated, gives:
digits
value
50
NaN
300
1.5329…, which is wrong in magnitude too
2000
2.0185…e-68: the real part is right and the imaginary part −2.0185…e-68 i is missing
The relative difference at 2000 digits is exactly −1/2 + i/2. At x = 2 all three precisions agree with the integrand to the last digit.
The derivative holds e^(±t/2) and e^(±t) beside a + i a sinh(t), so large cancellations are expected. Losing a whole component at 2000 digits is not explained by that, though, and NaN at 50 digits should have been "could not evaluate". I have not narrowed it to a single subexpression.
Because of this, the Rubi harness reports this row as wrong, and anything that checks an answer by evaluating would do the same.
Read a computed value as a rational only within half the working digits #2066, merged. A computed value became the small rational it was near within a fixed 1e-16, whatever the precision. At 2000 digits, ln(e^a + sqrt(2) e^(a/2) + 1) was exactly a, where it is a + 1.2e-67, and the derivative lost its imaginary part that way. The tolerance is now half the working digits, as it already was for a nearby integer.
Round a computed value onto zero only where its terms cancelled #2072, open. Every value below half the working digits was zero, products and moduli included. So the modulus of a number near 1e-136 was 0, a quotient by it was NaN (the NaN at 50 to 200 digits), and the derivative was 1.53 at 300 digits. Now a value is zero only as the residual of a difference, measured against its terms.
The derivative at the issue's point, with both PRs:
digits
2.6.0
now
50, 100
NaN
2.0185e-68, with no imaginary part
200
NaN
2.0185e-68 - 2.0185e-68 i
300
1.5329
2.0185e-68 - 2.0185e-68 i
2000
2.0185e-68, with no imaginary part
2.0185e-68 - 2.0185e-68 i
What is left. The derivative's terms cancel in their 68th digit. At 100 digits that difference is below half of them, so it reads as exact cancellation. No absolute or relative floor can tell it apart from sin(pi)'s residual. That needs an error bound carried through the arithmetic, which is the v3 number design in #1376, not another floor. With #2072 in, I'd close this issue and record the rest there.
Activity
Make the rational tolerance only past the cheap check
Read a computed value as a rational only within half the working digi…
Rafael-SOWNet commentedon Oct 22, 2026
There were two causes, each fixed in its own PR.
1e-16, whatever the precision. At 2000 digits,ln(e^a + sqrt(2) e^(a/2) + 1)was exactlya, where it isa + 1.2e-67, and the derivative lost its imaginary part that way. The tolerance is now half the working digits, as it already was for a nearby integer.1e-136was0, a quotient by it was NaN (the NaN at 50 to 200 digits), and the derivative was1.53at 300 digits. Now a value is zero only as the residual of a difference, measured against its terms.The derivative at the issue's point, with both PRs:
2.0185e-68, with no imaginary part2.0185e-68 - 2.0185e-68 i1.53292.0185e-68 - 2.0185e-68 i2.0185e-68, with no imaginary part2.0185e-68 - 2.0185e-68 iWhat is left. The derivative's terms cancel in their 68th digit. At 100 digits that difference is below half of them, so it reads as exact cancellation. No absolute or relative floor can tell it apart from
sin(pi)'s residual. That needs an error bound carried through the arithmetic, which is the v3 number design in #1376, not another floor. With #2072 in, I'd close this issue and record the rest there.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Round a computed value onto zero only where its terms cancelled (#2072)