Skip to content

A piecewise case whose condition is undefined is passed over - #1764

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
a-piecewise-case-whose-condition-is-undefined-never-holds
Oct 5, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
a-piecewise-case-whose-condition-is-undefined-never-holds

Conversation

@Rafael-SOWNet

@Rafael-SOWNet Rafael-SOWNet commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

A piecewise case whose predicate evaluates to NaN made the whole piecewise NaN, even where another case held:

expression 2.5.0 master a4141483 this
piecewise(1 provided i < 0, 2 provided 1 > 0), inner-simplified NaN NaN 2
piecewise(2 * x provided not x = 0, 3 * x ^ 2 provided i - 1 < 0), inner-simplified NaN NaN piecewise(2 * x provided not x = 0)
piecewise(1 provided i < 0, 2 provided i > 0), inner-simplified NaN NaN NaN, as before: no case holds

An order comparison of a number off the real line, i < 0, evaluates to NaN, the complex numbers not being ordered, and that is right. But a case whose predicate does not hold is not taken, and a predicate that evaluates to NaN holds no more than a false one does. Piecewise.InnerSimplify skipped a false case and kept a NaN one, which then made the whole NaN. It skips both now, in the pass that decides the piecewise outright and in the one that keeps the undecided cases, and the cases after one are read as they would be.

Where it showed. An antiderivative written with an arm for each sign of a quantity that is not real -- the integrator writes piecewise(F provided not q in RR or q > 0, G provided q < 0) -- differentiates arm by arm, and the derivative of the arm for q < 0 came back as 3x^2 provided -13/10 i - 3/5 < 0. With an arm before it whose predicate still holds x, not x = 0, the piecewise was left undecided, simplified, and became NaN: the derivative of an answer that is right had no value at any point. Pinned first and then differentiated, it was NaN as well.

Tests: UndefinedPiecewiseConditionTest, four facts, each checking a value rather than a printed form: the undefined case is skipped and the rest kept; an undefined case before a decided one is passed over; with no case that holds it is still NaN; and the derivative of such a piecewise is that of the case that holds.

The full suite on f84c9459 passed, 14,890 tests, but for IntegralAnswerCacheTest.AnIntegralWithNoAnswerStillFinishesQuickly, which allows a declined integral thirty seconds and took fifty-seven with four corpus runs on the machine; alone, that class passes in four seconds. The library builds for netstandard2.0.

The head here, 71fd770b, merges master 763f7bae into that; its checks are this pull request's.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

A case whose predicate evaluates to NaN -- an order comparison of a number off
the real line, i < 0 -- made the whole piecewise NaN, even where another case
held. It holds no more than a false predicate does: the case is never taken,
and the cases after it are read as before. The derivative of an antiderivative
with an arm for each sign of a quantity that is not real came out NaN that way.

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 4, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit a88080e into master Oct 5, 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.

1 participant