A zero imaginary part is on the real axis, whatever its sign - #1433
Merged
Merged
Conversation
A decimal's negative zero -- 0E-100 * -0.43 is -0E-102 -- is an artefact of the exponent arithmetic and not a limit from below, but the phase read -pi off its sign the way Math.Atan2 does. With the downcasting off Complex.Create keeps -1.54 - 0i a Complex, and a power went through the polar form a hair below the negative axis: (-1.54)^(-1/2) was +0.80 i with the setting off and -0.80 i with it on. The setting decided a branch, and the numerical checks in the harnesses, which turn the downcasting off, called a right antiderivative wrong on the strength of it (Rubi 7.4.2, e^acoth(a x) sqrt(c - c/(a x))/x^2). Now a number on the negative axis has argument pi for either zero (EDecimal.Sign is 0 for both), the square root reads its sign from a strictly negative imaginary part, and a complex base or power with an exactly zero imaginary part takes the real paths of Pow, where the half-power arithmetic is exact rather than a cosine of pi/2 at a hundred digits. Nothing changes with the downcasting on. #1378 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
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.
Found while checking a Rubi 7.4.2 answer:
e^acoth(a x) sqrt(c - c/(a x))/x^2read wrong in the integration probe on the region wheresqrt(c - c/(a x))is imaginary, and finite differences of the same antiderivative under the default settings matched the integrand exactly. The probe, likeintbench, evaluates withDowncastingEnabledoff ("decimals stay decimals"), and there the evaluation was wrong.The cause. A decimal's negative zero —
0E-100 * -0.43is-0E-102— is an artefact of the exponent arithmetic, not a limit from below (EDecimal.Signis0for it).Arctan2read-pioff its sign the wayMath.Atan2does; with the downcasting offComplex.Createkeeps-1.54 - 0iaComplex, so a power went through the polar form a hair below the negative axis:(2*1.44*(1/sqrt(-5.286))^2-1)^(-1/2)was+0.80 iwith the setting off and-0.80 iwith it on. A setting decided a branch — #1376's point, one layer down.The fix. A number on the negative axis has argument
pifor either zero (the threeArctan2arms); the square root reads its sign from a strictly negative imaginary part (im.Sign < 0); and a complex base or power whose imaginary part is exactly zero takes the real paths ofPow, where the half-power arithmetic is exact rather than a cosine ofpi/2at a hundred digits.Complex.Createis unchanged, so the type semantics of the setting (NumericDowncastingTest) are as they were. Nothing changes with the downcasting on.SignedZeroBranchTest: four expressions evaluate to the same value with the setting on and off (to 1e-40), and-4 - 0ihassqrt,(·)^(1/2)andlnon the principal branch. Full suite 12012 passed, 0 failed; benchmark gate PASSED (SimplifyHard 171,750,488 B, +0.1% on the recorded baseline). BREAKING-CHANGES.md rows measured on a v2.5.0 build (theWasvalues are the setting-off ones; 2.5.0 gave a real5.55for the first).Part of #1378.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura