Repository navigation
Round the sums in a difference of powers of e, so tanh(10^7) returns - #2570
Merged
Merged
Conversation
…2563) ExpDifference, which evaluates e^u - e^v as e^v (e^(u - v) - 1) for sinh, tanh and coth (#2074), sized its residual with two additions taken without a context. Past the exponent range that added 1 exactly to e^(10^7), an integer of four million digits, and the multiplication after it rounded that back. The time grew with the argument: tanh(10^7) took 18 s on 2.9.0, tanh(10^8) did not return in 60 s, and PeterO's arithmetic does not observe the cancellation token, so limitcheck and compilesweep both ended on it. Both additions are now rounded in the working context. Every hung row returns in milliseconds with the value it had where it returned; small differences (#2074) and arguments from 999 to 2400 evaluate exactly as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2570 +/- ##
==========================================
- Coverage 86.73% 86.71% -0.03%
==========================================
Files 344 344
Lines 74833 74833
Branches 21837 21837
==========================================
- Hits 64905 64889 -16
- Misses 5361 5376 +15
- Partials 4567 4568 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2563.
ExpDifference(#2074) evaluatese^u - e^vase^v (e^(u - v) - 1)forsinh,tanhandcoth. It sized the result's residual with two additions taken without a context. Past the exponent range, that added 1 exactly toe^(10^7), an integer of four million digits, and the multiplication after it rounded that back down. The time grew with the argument. PeterO's arithmetic does not check the cancellation token, sowork/limitcheckandwork/compilesweepboth ended their runs on it.Both additions are now rounded in the working context.
.Evaledoftanh(10^6)1, 408 ms1, 2 mstanh(10^7)1, 18 s1, 122 mstanh(-10^8)-1, 3 mscoth(-10^7)-1, 14 s-1, 6 mssinh(10^7)+oo, 14 s+oo, 9 mse^(10^7) - 1,1 - e^(-10^7)+ooand1, 5 s each+ooand1, 5 and 16 msTwenty-seven inputs were compared with master to 60 characters: the hung ones, small differences (
sinh(10^(-60)),sinh(10^(-20)),e^(1500 + 10^(-60)) - e^1500), and arguments from 999 to 2400, some of them complex. Every value matched except the rows that did not return before.The new test fails without the fix: the three
10^8cases do not return within 60 s.Local checks:
🤖 Generated with Claude Code