Skip to content

A piecewise is defined where the case it takes is - #1819

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
a-piecewise-is-defined-where-the-case-it-takes-is
Oct 7, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
a-piecewise-is-defined-where-the-case-it-takes-is

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #1817. Part of #718.

A piecewise is defined where the case it takes is, but its DomainCondition was the disjunction of the predicates and the domain condition of every child, and c < 0 is defined only where c is real:

2.5.0 master c21de3ef this
piecewise(1 provided not i in RR, 2 provided i < 0) false false true
piecewise(2 * x provided not x = 0, 3 * x ^ 2 provided i - 1 < 0) false false not x = 0

Piecewise.InnerSimplify already passes over a predicate that evaluates to NaN; the domain condition did not. It reached integration through substitutions that carry the domain condition of the answer they found back with them: 1/(sqrt(a + i a x) (c + d x)^(3/2) (a - i a x)) is answered on master with an arm for each sign of a discriminant and one for its not being real, under provided ... and 8 a^3 c - 8 i a^3 d in RR -- an answer with no value at any real point. It is answered here, 3,267 characters, and differentiates back.

What changes. DomainCondition of a Piecewise is now the disjunction over its cases of: the case's predicate, its expression's domain condition, and for every earlier case, that its predicate does not hold or has no value. A case whose predicate evaluates to NaN or false is never taken and is left out. The earlier cases are kept in each term so that a case taken where its expression is undefined leaves the piecewise undefined there: piecewise(1/x provided x > -1, 0 provided true) is undefined at 0, not defined because the second case would hold.

Tests: UndefinedPiecewiseConditionTest gains the domain of four piecewises, one with an arm for a quantity off the real line at two points, and the first-case-decides case above at three.

Measured on every corpus problem with i in its integrand, 2,253 of them, and on the Rubi corpus, against master c21de3ef at the corpus's 5-second budget: no verdict changes anywhere -- 2,002 solved on both in the pocket, 1782, 1341 and 2328 in families 0, 1 and 2 to 8 sampled -- and the time on the problems both answer is the same, 2,099 seconds and 2,097.
The suite passes on 2d3bf4e9, this change on c21de3ef: 15,146 passed, 13 skipped, none failed. Rebased onto 77899a6f without a conflict, the domain and piecewise tests pass again. The allocation gate passes: every gated benchmark allocates what the baseline says. The library builds for every target.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Its domain condition asked every case's predicate to be defined, and an
ordering is defined only between reals. Fixes #1817.

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 7, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit f8e9734 into master Oct 7, 2026
34 checks passed
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.

A piecewise's domain condition asks every case's predicate to be defined

1 participant