A power of a quotient is split only where that keeps its branch - #1755
Merged
Merged
Conversation
Simplify wrote (c/a)^d * a^e as c^d * a^(e - d) for every numeric d, which splits the power of the quotient as (c/a)^d = c^d a^(-d). That holds for a whole d, and for a rational d with an odd denominator over a positive c, where a negative base takes its real root; for any other d it moves the branch wherever a is negative: (1/(-2))^(1/2) is 0.707i and (-2)^(-1/2) is -0.707i. So sqrt(x) sqrt(1/x) simplified to 1 where it is -1 for every negative x, and sec(x)^(3/2) cos(x)^(3/2) to 1 where it is -1 wherever the cosine is negative. Both spellings of the two rules now fire only where the split holds. Fixes #1734. 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
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1734.
Simplifywrote(c/a)^d * a^easc^d * a^(e - d)for every numericd, which splits the power of the quotient as(c/a)^d = c^d a^(-d). That holds for a wholed, and for a rationaldwith an odd denominator over a positivec, where a negative base takes its real root. For any otherdit moves the branch whereverais negative:(1/(-2))^(1/2)is0.707iand(-2)^(-1/2)is-0.707i. 2.5.0 does the same:Simplifyon 2.5.0 and masterf18a7d2bsqrt(x)*sqrt(1/x)x = -2-11 provided not x = 0sqrt(1/x)*xx = -0.63-0.794isqrt(x),0.794ithere(2/x)^(1/2)*xx = -3-2.449isqrt(2) * sqrt(x),2.449itheresec(x)^(3/2)*cos(x)^(3/2)x = 2-11 provided not cos(x) = 0(1/x)^(1/3)*x^(1/3)x = -211 provided not x = 0The fourth is the constant some antiderivatives carry,
K = sec(x)^p cos(x)^pbeside an answer for a power of the cosine, so aSimplifyof such an answer made it wrong where the cosine is negative.What changes. Both spellings of the two rules, the data form in
MatchedRules.csand theswitcharms inPatterns.Power.cs, fire only where the split holds, through one predicate,Patterns.AReciprocalPowerSplits: a wholed, or a rationaldwith an odd denominator over a positivec. Where two powers ofathen combine, the second exponent has to read a negativeathe same way, whole or an odd root, since an odd root beside a principal one does not combine either. Elsewhere the expression is left as written, which is what the contract's O6 asks of a rule whose assumption cannot be decided.Tests:
ReciprocalPowerBranchTest, seven rows compared as complex numbers at a negative point, all seven changed in value bySimplifyon master, and three the rule still simplifies, unchanged.BoundCheckcarries the four shapes now, and on master it finds four disagreements in them.Harnesses: on the branch before master was merged,
CanonCheckandConfluencematched their baselines, andRuleCheck,SimpSweepandBoundCheckfound nothing; CI runs all five on the merge.Measured on the integrator, whose answers
Simplifyreads and whose corpus harness simplifies an answer that does not check out as written, first on the 1,019 problems of family 4 with a fractional power of the secant, the cosecant or the cotangent beside its reciprocal, 414 run, at the corpus's 5-second budget, against master8f3757cd, the branch's base:Measured then on the Rubi corpus against master
8f3757cd:The harness counts no answer wrong in the pocket or the sample on either build. Of the 17 problems the two builds disagreed on, run again one build at a time, each answers 7. Master's own is
1/sqrt(csch(2 ln(c x))), answered in 1.4 s through the split: wherec x < 1the integrand is imaginary and the answer's derivative is not it, atx = 0.31,0.57and0.83, the split moving the branch exactly as in the table above; the harness, which compares on the real domain, counted it solved. This one declines it; on the merge with masterf18a7d2b, which carries #1752, both answer it on both sides of zero. This one's own is(A + B x^2)/(x^(3/2) (b x^2 + c x^4)^2), at twenty seconds, at the edge of the harness's patience, and the six both answer take seventeen to twenty-four. The four family 1 loses in the sample are four of those twenty-second problems, and family 6's two are one more and thecschabove. Three that master declines after sixteen to twenty seconds run past the patience here, declined either way.The suite passes on the merge with master
f18a7d2b,722b6915, 14,836 tests with 13 skipped. Every row of the first table is as it says there. With master moved on toa27661f3, two more integration rules in it, the 4,153 calculus and corpus tests that run pass on that merge as well, with 2 skipped.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura