Skip to content

Differentiate the sign and the modulus of an expression in roots where the roots are real - #1988

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
differentiate-the-sign-of-an-expression-in-roots-where-they-are-real
Oct 21, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
differentiate-the-sign-of-an-expression-in-roots-where-they-are-real

Conversation

@Rafael-SOWNet

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

Copy link
Copy Markdown
Member

The derivative of sgn(f) and of abs(f) was left unevaluated wherever f is not real on the whole line, and a root of anything that can be negative is not.

Where f is real wherever the bases of its roots are positive, the derivative is now a piecewise:

  • where every such base is positive, the real-line rule: 0 for sgn, and sgn(f) f' for abs;
  • elsewhere, the derivative left as written, since there a root is imaginary and sgn(z) = z/|z| turns with z.

RealValued.WhereRealValued gives the conjunction of base > 0 over the powers that are not whole. A derivative node no longer simplifies a result that contains itself; without that guard, this change looped.

The integrator's antiderivatives of Rubi's x^(-1 - 3n/2) (b x^n)^(3/2), sqrt(1 + x + sqrt(1 + x)), (x - 4)/((1 + x^(1/3)) sqrt(x)) and their kin carry such a sign. They are right, by quadrature on both sides of their roots, but could not be differentiated back anywhere, so they read as unverified. Three answers built under u = sqrt(1 + x) or u = sqrt(x) lose a provided 1 + x >= 0 that had been attached for want of that derivative. sqrt(1 + x + sqrt(1 + x)) keeps the condition of its answer in u instead, 26 characters longer.

Measured on 8270086f, branch against master:

Run Problems Master Branch
Pocket: Rubi's 1.1.3.x, 1.2.4.2 and 1.3.2 3,549 3,502 solved 3,512 solved
Family 1, 40 a file 1,381 1,368 1,369
Family 0, whole 1,814 1,789 1,789
Families 2 to 8, sampled 2,410 2,380 2,382

Re-run alone, 12 problems go from unverified to verified: 1.1.3.2:211–214, 1.2.4.2:185, 1.3.2:935, 939, 966, 967 and 1228, 4.2.2.1:320 and 5.5.2:64. The 13th move, 7.4.1:369, a problem master answers in 24 s, is answered on both builds. Nothing goes the other way. Across the whole 1.3.2 file and 360 solved root integrands from families 0, 1 and 4–7, the answers are otherwise byte-identical. None of the problems answered on both builds allocates more on the branch. No run had a wrong answer.

ASignOfARootIsFlatWhereTheRootIsRealTest has 28 cases. The 5,665 calculus, derivative, limit and piecewise tests pass. One cache wall-clock test failed under load at 35 s against its 30 s bound, and passes alone in 3 s. BREAKING-CHANGES.md has the entry, with the 2.5.0 column measured on v2.5.0.

Part of #233.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

…e the roots are real

The derivative of sgn(f) and of abs(f) was left unevaluated wherever f is
not real on the whole line, and a root of anything that can be negative is
not. Where f is real wherever the bases of its roots are positive, the
derivative is now a piecewise: the real-line rule, 0 and sgn(f) f', where
every such base is positive, and the derivative left as written elsewhere,
where a root is imaginary and sgn(z) = z/|z| turns with z. A derivative node
no longer simplifies a result that contains itself, which looped.

Antiderivatives that carry such a sign -- Rubi's x^(-1 - 3n/2) (b x^n)^(3/2),
sqrt(1 + x + sqrt(1 + x)), (x - 4)/((1 + x^(1/3)) sqrt(x)) -- could not be
differentiated back anywhere, so a right answer read as unverified. Three
answers built under u = sqrt(1 + x) or sqrt(x) lose a provided 1 + x >= 0
attached for want of that derivative.

Rubi pocket (3,549 rows of 1.1.3.x, 1.2.4.2 and 1.3.2): 3502 -> 3512 solved;
the moves re-run alone go 1 -> 13 verified, none lost; the samples of every
family verify three more and lose none.

Part of #233.

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 21, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit 8ccf7cc into master Oct 21, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Oct 21, 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.

1 participant