Repository navigation
Two piecewises split on one quantity combine sign by sign - #1686
Merged
Merged
Conversation
A piecewise combined with a piecewise joins every case to every other. The integrator's answers for a rational function with symbols in it are split on the sign of a quantity -- `t^k/(d - f t^2)^4` on that of `d/f` -- and a sum of them kept the pairs of opposite strict signs, `q > 0 and q < 0`, which are NaN rather than False off the real line, and the pairs where a vanishing coefficient met a case that divides by it, `f = 0 and not 2 f = 0`. Six such terms made 32,769 cases, and `x sqrt(1 + d x) sqrt(1 + f x)` ran out of time. A quantity is now read up to a constant factor, and a pair asking it to be zero and not zero, or zero and of a sign, goes: that is false for every value, complex or not. A pair asking it to be both positive and negative goes where every later pair tests it too: those are false or undecided off the real line, never true, so what the undecided pair stopped is not reached without it either. The sum stays at three cases, and the integral answers in a second. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Measured on the 2.5.0 tag, master 94ba5ff and this branch. Co-Authored-By: Claude Opus 5.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.
Part of #718.
x sqrt(1 + d x) sqrt(1 + f x)timed out when both slopes are symbols, while with either slope a number it takes under half a second. The time was not in the integration. Each term of the rational function intintegrates in 0.3 s. The time went into adding the answers.Each answer is a piecewise split on the sign of one quantity, here
d/f, and a piecewise plus a piecewise joins every case of one to every case of the other. #1414 already drops the pairs whose conjunction simplifies toFalse, but two kinds of pair survived it:q > 0 and q < 0. These are false for a realqbut NaN off the real line, and a NaN case stops the cases after it from being reached, so Integrating (c - c/(a^2 x^2))^(9/2) / e^(3 acoth(a x)) allocates 8 GB in 30 s and does not stop at the budget #1414 kept them on purpose.f = 0 and not 2 f = 0. The constant factor hid the contradiction.Six such terms of
t^k/(d - f t^2)^4made 32,769 cases and took 12.6 s, and the whole integral never finished.What changes, in
CombinedCaseByCase:OppositeSignsStayWhereALaterCaseDoesNotTestTheQuantity.The sum stays at three cases:
(2 d^2 t^4 - 4 d f t^4 + ...)/(d - f t^2)^4x sqrt(1 + d x) sqrt(1 + f x)x^2 sqrt(c + d x) sqrt(e + f x)(A + B x + K x^2) sqrt(c + d x) sqrt(e + f x)Each answer's derivative agrees with its integrand at sampled points.
Tests
ContradictoryConjunctionTest.TwoPiecewisesOnTheSameSplitCombineCaseByCaseexpected five cases, the two opposite-sign pairs kept. It now expects three, and it checks that the sum still has no value atq = i.AConstantFactorIsTheSameQuantityandOppositeSignsStayWhereALaterCaseDoesNotTestTheQuantityare new.TwoLinearRadicalsIntegralTest.SymbolicCoefficientsgainsx sqrt(a + b x) sqrt(c + d x)andx^2 sqrt(a + b x) sqrt(c + d x), both of which time out on master.Measured on the Rubi corpus against master
e8025673, with both builds side by side:Both builds give the same two wrong answers in family 1: 1.2.1.1's
sqrt(-4 + 12 x - 9 x^2)and1/sqrt(-4 - 12 x - 9 x^2), roots of negative squares, which #1672 fixed on master after this branch's base.25 problems moved, 18 of them in family 1, and I re-ran each alone on both builds. This branch answers 19 of them, with none wrong, 1 unevaluated and 5 past the budget. Master answers 2. One of master's two is 1.1.2.4's
x^4/((a + b x^2)^2 (c + d x^2)^3), which it answers after 21 seconds, well past the 5 s budget, where this build stops at the budget.The suite passes, 14,313 tests on a fresh build, and so does the allocation gate.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura