Skip to content

Measure a function's residual against its argument - #2076

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
a-function-of-a-small-argument-is-not-zero
Oct 22, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
a-function-of-a-small-argument-is-not-zero

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #2074. Follows #2072.

  • The defect. A function's value was rounded onto zero below half the working digits, absolutely. The floor exists 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)), tan, arcsin, arctan, erf, erfi, Si and Shi of it were all 0 at the default hundred digits.
  • The change. The sine, cosine, tangent, logarithm, arcsine, arccosine and arctangent of a real argument, the error functions, and Si and Shi create 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) and arccos(1) are still 0.
    • The argument is passed as it is, and its modulus is taken only on the path that tests for a residual.
  • Not changed. 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.

AFunctionOfASmallArgumentTest checks nine values against mpmath, and five residuals that are still zero.

Results:

  • Unit suite: passes (16,823).
  • Corpus: the full Rubi corpus, run against the 2.6.0 run on the same harness (c614b2c8), is 48,305 of 48,305, with no row moved and no answer's allocation grown.
  • Allocation: measured per evaluation against master. It is identical for sin(x) + cos(x) + tan(x) and ln(1 + x^2) * arctan(x), and 0.01% apart for erf(x) + Si(x).
  • BREAKING-CHANGES: the entry gives the values on 2.6.0 and now.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Rafael-SOWNet and others added 2 commits October 22, 2026 18:39
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
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Oct 22, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit a9866da into master Oct 22, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

A function of a small argument evaluates to 0

1 participant