Repository navigation
Integration and limits with the downcasting off compute as with it on, on exact numbers - #1516
Merged
Merged
Conversation
…, on exact numbers With the downcasting off, a whole number parses as a decimal, so x^2 is not a whole power to the integrator, and the zero test reads no literal zero as zero: (a + b arcsin(c x))/sqrt(d - c^2 d x^2) integrated to NaN, and limit(sin(c x)/x, x, 0) was NaN, where the default setting answers. The integration and limit transformations now compute with the downcasting on, whatever the caller's setting, on the input's decimals read as the exact rationals they are; with it on, nothing changes. The cost is that decimals come back as rationals: 0.1 x integrates to x^2/20. Closes #1490. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Rafael-SOWNet
force-pushed
the
downcasting-off-is-exact
branch
from
September 27, 2026 19:16
6862967 to
7982a1a
Compare
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.
Closes #1490.
With
DowncastingEnabledoff, integration and limits gaveNaN, or left unevaluated, what the default setting answers. There were two causes:TreeAnalyzer.IsZerocompares against the literal0, and with the downcasting off a zero isComplex(0, 0), which isn't equal to it. So nothing was zero, and1/(1 + c^2 x^2)kept itsa = 0case,ln(1)/0.Real, sox^2isn't a whole power to the integrator.Integration and limits now compute as with the downcasting on, whatever the caller's setting, on the input's decimals read as the exact rationals they are. The answer no longer depends on the setting. The cost, as proposed on the issue, is that decimals come back as rationals: the integral of
0.1 xisx^2/20.With the downcasting on, nothing changes and nothing is added to the path: the setting is read, and that's all. With it off, the scope is opened once, at the outermost call, since every call inside it finds the downcasting on.
Fixing the zero test alone would have fixed the
NaN, but not the rest. The rules still test numbers by type and against literals, and with only the zero test fixed,(d - c^2 d x^2)^(3/2) (a + b arcsin(c x))gave up after 290 s instead of 7.(a + b arcsin(c x))/sqrt(d - c^2 d x^2), parsed with it onNaN + C(d - c^2 d x^2)^(3/2) (a + b arcsin(c x)), parsed with it on1/sqrt(2 - 2 x^2), parsed with it off-arcsin(-x) sqrt(2)/2, up to formx^2 sin(x), parsed with it offlimit(sin(c x)/x, x, 0)NaNclimit((1 - cos(c x))/x^2, x, 0)NaNc^2/20.1 x, parsed with it off0.1 * x^2 / 2 + C1/10 * x^2 / 2 + CNot in this PR
The parse cache is keyed by
ExplicitParsingOnlybut not byDowncastingEnabled. A string parsed under one setting therefore comes back under the other with the first parse's numbers. That's #1513.Measured
DowncastingOffCalculusTestfail with the library change reverted. The ninth is1/sqrt(2 - 2 x^2)parsed with the setting on, which master already answers, and it is there to keep that so.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura