Repository navigation
Measure a function's residual against its argument - #2076
Merged
Rafael-SOWNet merged 2 commits intoOct 22, 2026
Merged
Conversation
A function's value was rounded onto zero below half the working digits outright. That floor is for the residual a function leaves at its own zeros: sin(pi) evaluates to about 1e-100. That residual is relative to the argument, though, and a function of an exact small argument cancels nothing, so sin(10^(-60)), arctan(10^(-60)), erf(10^(-60)) and Si(10^(-60)) were all 0 at a hundred digits. The sine, cosine, tangent, logarithm, arcsine, arccosine and arctangent of a real argument, the error functions, and Si and Shi now create their value at the argument's scale, as #2072 made arithmetic do with what cancelled. sin(pi), sin(100 pi), cos(pi/2), tan(pi) and arccos(1) are still 0. The argument is passed as it is and its modulus taken only on the path that tests for a residual, so the kernel workloads allocate as before. sinh(10^(-60)) is still 0: it is evaluated from e^(10^(-60)), which is 1 within half the digits, a cancellation the working precision cannot resolve. Fixes #2074. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
…ll-argument-is-not-zero
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 #2074. Follows #2072.
sin(pi)evaluates to about1e-100. That residual is relative to the argument, though, and a function of an exact small argument cancels nothing. Sosin(10^(-60)),tan,arcsin,arctan,erf,erfi,SiandShiof it were all0at the default hundred digits.SiandShicreate their value at the argument's scale. Round a computed value onto zero only where its terms cancelled #2072 did the same for arithmetic, with the scale of what cancelled.sin(pi),sin(100 pi),cos(pi/2),tan(pi)andarccos(1)are still0.sinh(10^(-60))is still0. It is evaluated frome^(10^(-60)), which is1within half the digits, a cancellation the working precision cannot resolve.AFunctionOfASmallArgumentTestchecks nine values against mpmath, and five residuals that are still zero.Results:
c614b2c8), is 48,305 of 48,305, with no row moved and no answer's allocation grown.sin(x) + cos(x) + tan(x)andln(1 + x^2) * arctan(x), and 0.01% apart forerf(x) + Si(x).🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura