Skip to content

Two piecewises split on one quantity combine sign by sign - #1686

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
a-sum-of-sign-splits-stays-split
Oct 2, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
a-sum-of-sign-splits-stays-split

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

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 in t integrates 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 to False, but two kinds of pair survived it:

Six such terms of t^k/(d - f t^2)^4 made 32,769 cases and took 12.6 s, and the whole integral never finished.

What changes, in CombinedCaseByCase:

  • A quantity is read up to a constant factor.
  • A pair that asks a quantity to be zero and not zero, or zero and of a sign, goes. That is false for every value, complex or not.
  • A pair that asks a quantity to be both positive and negative goes only where every later pair tests that quantity too. Off the real line those are each false or undecided, never true, so whatever the undecided pair was stopping is not reached without it either. Where a later case doesn't test the quantity, the pair stays: OppositeSignsStayWhereALaterCaseDoesNotTestTheQuantity.

The sum stays at three cases:

master this
(2 d^2 t^4 - 4 d f t^4 + ...)/(d - f t^2)^4 12.6 s, 32,769 cases 0.6 s, 3 cases
x sqrt(1 + d x) sqrt(1 + f x) timeout 1.3 s, 3 cases
x^2 sqrt(c + d x) sqrt(e + f x) timeout 2.0 s
(A + B x + K x^2) sqrt(c + d x) sqrt(e + f x) timeout 5.4 s

Each answer's derivative agrees with its integrand at sampled points.

Tests

  • ContradictoryConjunctionTest.TwoPiecewisesOnTheSameSplitCombineCaseByCase expected five cases, the two opposite-sign pairs kept. It now expects three, and it checks that the sum still has no value at q = i.
  • AConstantFactorIsTheSameQuantity and OppositeSignsStayWhereALaterCaseDoesNotTestTheQuantity are new.
  • TwoLinearRadicalsIntegralTest.SymbolicCoefficients gains x sqrt(a + b x) sqrt(c + d x) and x^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:

master this
family 1, 40 a file (1381) 1115 1132
family 0, independent suites (1814) 1758 1758
families 2 to 8, sampled (2410) 2139 2141

Both builds give the same two wrong answers in family 1: 1.2.1.1's sqrt(-4 + 12 x - 9 x^2) and 1/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

Rafael-SOWNet and others added 2 commits October 2, 2026 06:34
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
@Rafael-SOWNet
Rafael-SOWNet merged commit 70b4be6 into master Oct 2, 2026
34 checks passed
@Rafael-SOWNet Rafael-SOWNet added this to the 2.6.0 milestone Oct 2, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the a-sum-of-sign-splits-stays-split branch October 29, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant