Skip to content

Keep a sum of piecewise answers a sum where their cases do not line up - #1882

Merged
Rafael-SOWNet merged 3 commits into
masterfrom
a-sum-of-piecewise-answers-stays-a-sum
Oct 14, 2026
Merged

Rafael-SOWNet merged 3 commits into
masterfrom
a-sum-of-piecewise-answers-stays-a-sum

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #1874. Part of #718

An antiderivative whose terms each split on the signs of their constants was combined into one piecewise, listing every case of one term against every case of the other. CombinedCaseByCase now leaves a sum or a difference as a sum of the two piecewises wherever combining them would give more cases than the two have between them. The count is taken after unreachable cases are removed, so #1414's three-plus-three-to-five combinations still happen. A sum that already holds a piecewise is not copied into the cases of another piecewise.

Integrands are not affected: Normalized combines a sum of piecewises the old way while it runs, so the search sees the shapes it saw before. Without that, a by-parts remainder u' v, with v a sum of piecewises, was split term by term and each term searched, and (a + b atanh(c x^2))^2/x^5 went from 19 s to 134 s.

Measured

master 790feec this branch
1/(b x^2 + m) - 1/(sqrt(a + b x^2) (b x^2 + m)) 3,685 chars 975
(A + B x)(d + k x)^(7/2)/(b x + c x^2)^3 (1.2.1.3:1395) 7,348,174 chars 15,079
(A + B x)/((d + k x)^(5/2) (b x + c x^2)^3) (1.2.1.3:1401) 8,944,942 chars 17,637
(a + b x + c x^2)^(3/2)/((d + k x)(f + g x)^3) (#1881) 79,744 chars 9,304
(a + b x^2 + c x^4)^(3/2)/(x^3 (d + k x^2)) (#1881) 27,184 chars 3,100
asec(a + b x)/x^4 (#1881) 11,873 chars 4,073

I ran intbench against master (#1881's head, same tree as 790feec) with a 5 s budget. The pocket was 1.2.1.2–1.2.1.4, 1.2.1.9, 1.2.2.2, 1.2.2.4, 1.3.2, 3.5, 5.5.2, 5.6.2 and 7.3.2 in full (7,699 rows), plus the usual family sample:

master this branch
pocket 7,520 solved, 73 timeouts 7,527 solved, 66 timeouts
families 0–8 sample identical
wrong / error 0 / 0 0 / 0
time on the rows both solve 1,760 s 1,691 s

Nine rows moved:

  • 1.2.1.3:1395–1401, seven rows, went from timeout to about 1 s each. On master they were solved, but in 7–9 million characters.
  • 3.5:118 went from timeout to solved. On its own it gives the same 87K-character answer in 33 s on both builds, so that move is noise at the budget.
  • 7.3.2:234, (a + b atanh(c/x^2))^2/x^5, went from solved to timeout. Timed alone, it gives the same 283-character answer in 36–39 s on master and 61–62 s here. The by-parts remainders it declines now hold the inner antiderivative written as a sum, and the declines cost more. 7.3.2:89, the same shape with c x^2, went the other way, from 19 s to 14 s.

The gate passes. Two tests read a sum of piecewises as one piecewise:

  • ContradictoryConjunctionTest.OppositeSignsStay… tests the pruning in CombinedCaseByCase, so it now asks a product, which still combines.
  • UnreachablePiecewiseCaseTest is what moved the count to after the unreachable cases are removed.

The suite passes in two runs, 13,521 and 1,856, which is master's 15,373 plus the 4 new tests. Run whole, the test host is killed by the 8 GB memory guard on this branch and on master alike: master's whole suite peaked at 7,947 MB and was killed in one of two runs. Tests.Convenience alone peaks at 5.8 GB on master, and DocumentationExamplesRunTest at 2.5 GB.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Rafael-SOWNet and others added 3 commits October 14, 2026 06:37
An answer's sum of two piecewises was combined case by case into one
piecewise with every case of one against every case of the other. It
stays a sum where that combination has more cases than the two together,
counted after the unreachable ones are gone; and a sum holding a
piecewise is not copied into another's cases. Integrands are normalised
with the old combination, so the search sees what it saw before.

Fixes #1874

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
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.6.0 milestone Oct 14, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit 033953d into master Oct 14, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Oct 14, 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.

The antiderivative of a sum multiplies its terms' piecewise cases

1 participant