Skip to content

A product of powers of quotients of linears is written over each linear once - #1683

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
each-linear-written-once
Oct 2, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
each-linear-written-once

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Part of #718.

Rubi 7.3.6 and 7.4.2 have about two hundred problems of one shape that the integrator ran out of time on: an exponential of atanh(a x) or acoth(a x) beside a power of c ± c/(a x) or c ± c/(a^2 x^2). For example,

e^atanh(a x) sqrt(c - c/(a x))  =  sqrt((1 + a x)/(1 - a x)) sqrt(c (a x - 1)/(a x))

The linear 1 - a x stands in both radicals, once as 1 - a x and once as a x - 1, with exponents -1/2 and 1/2. The substitution search took one radical at a time and didn't finish. Rubi's rules write the integrand over each linear once, with a factor in front:

x^p (c + d/x)^p / (1 + c x/d)^p

That factor is constant wherever it is defined. This PR does the same in a new rule, SolveByWritingEachLinearOnce.

What it does

  • It reads the integrand through products, quotients, powers, and the exponential of a multiple of a logarithm. e^(1/2 ln q) counts as q^(1/2), which is how the inverse hyperbolic functions arrive.
  • It splits every base into linears whose roots are rational in the symbols, and sums each root's exponents. Writing each linear once leaves K (a x + 1)^(1/2) x^(-1/2), which the rule for two linear radicals answers in milliseconds.
  • K is the integrand over that product. Its logarithmic derivative is zero, because both sides have the same sum e_i/(x - r_i). So K is constant wherever it is defined, and it stands in front of the answer.

Where the answer holds. The product is real only where its linears have the signs they are written with. Each linear therefore takes the sign that is positive on an interval where the integrand is real, and K takes the imaginary unit the other sign would leave. Each such choice is an arm of a piecewise answer. Its condition is that every linear under a power that is not whole is >= 0. The arm holds there whatever the symbols are.

  • The arms are found with the other symbols pinned to either sign. For c > 0, e^atanh(a x) sqrt(c - c/(a x)) is real between -1/a and 0. For c < 0 it is real between 0 and 1/a.
  • An arm for negative x is integrated in t = -x, because the rules read t^(1/2) and not (-x)^(1/2).
  • Each arm is checked at two points of its interval.
  • It is every arm or none, so that no answer this rule gives covers less than one another rule would.

Where it fires. A root has to stand in two bases under powers that are not whole, or in a root of a quotient with x below the bar and in another base. At most two linears may be left under powers that are not whole. A root beside a whole power of one of its own linears is left to the rules that read it as written, such as sqrt(x)/(x (x + 1)), or (1 - a^2 x^2)^(3/2)/((1 - a x)^2 (c + d x)), which a rule writes over the radicand. With every power whole, a shared root of a quotient is enough. e^(2 acoth(a x))/(c - c/(a^2 x^2))^2 is K x^4/((a x + 1)(a x - 1)^3), which the partial fractions answer at once, and there K is a plain constant.

Why it is first in the chain. The rule answers the question asked only. The polynomial term rewrites 1/u as u^(-1) and asks that a level down, so 1/(e^atanh(a x) (c - c/(a x))^(3/2)) never reached the rule when it came later.

Tests

  • EachLinearWrittenOnceIntegralTest checks nineteen integrands, among them both signs of c. Each answer's derivative is compared with the integrand on both sides of every root, wherever the integrand is real.
  • Two tests in LinearRadicalSubstitutionIntegralTest pinned the conditioned answers that the linear-radical step gives for two integrands this rule now answers on both sides of the root. They now assert that.
  • The step's own condition stays pinned on 1/sqrt(x + x^(3/2)).

Measured on the Rubi corpus against master bc6c190c, with both builds side by side:

master this
family 7, inverse hyperbolic functions (4289) 3683, 13 wrong, 338 past the budget 4032, 5 wrong, 158 past the budget
family 0, independent suites (1814) 1758 1758
families 1 to 6, sampled (2877) 2447 2449

375 problems moved, all but four in family 7, and I re-ran each alone on both builds. This branch answers 361 of them, with none wrong and 14 past the budget. Master answers 7, with 8 wrong and 196 past the budget. The 8 are #1664's e^atanh(x) beside a half-integer power of 1 - x, which #1669 has since fixed on master another way, and which this rule answers too.

The 5 still wrong in family 7 are #1665's, fixed on master by #1682 after this branch's base.

The suite passes, 14,322 tests on a fresh build, and so does the allocation gate.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Rafael-SOWNet and others added 2 commits October 2, 2026 04:56
…ar once

`e^atanh(a x) sqrt(c - c/(a x))` is `sqrt((1 + a x)/(1 - a x)) sqrt(c (a x - 1)/(a x))`, and the root
`1/a` stands in both, with exponents `-1/2` and `1/2`. The substitution search did not finish on it.
Written over each linear once it is `K sqrt(a x + 1)/sqrt(x)`, and `K` -- the integrand over that
product -- has a zero logarithmic derivative, so it is constant wherever it is defined and stands in
front of the answer, as Rubi writes `x^p (c + d/x)^p/(1 + c x/d)^p` in front of its.

`SolveByWritingEachLinearOnce` reads the integrand through products, quotients, powers and the
exponential of a multiple of a logarithm into linears whose roots are rational in the symbols, sums
each root's exponents, and fires where a root stands in two bases under powers that are not whole,
or in a root of a quotient with x below the bar and another base, and at most two linears are left
under such powers. Each linear takes the sign that is positive on an interval where the integrand is
real, so that the product is real there; each such sign is an arm saying where it holds, found with
the other symbols pinned to either sign, and an arm for negative x is integrated in `t = -x`, where
the power of the variable is one the rules read. The product is asked as a quotient, and without
this rule. Every arm or none. With every power whole, a root of a quotient shared with another base
is enough -- `e^(2 acoth(a x))/(c - c/(a^2 x^2))^2` is `K x^4/((a x + 1)(a x - 1)^3)`, which the
partial fractions answer at once -- and `K` is a constant, with one arm and no condition. First in
the chain, at the question asked: the polynomial term writes `1/u` as `u^(-1)` and asks that a level
down.

Two tests pinned the conditioned answers the linear-radical step gives for integrands this rule now
answers on both sides; they assert that instead, and the step's condition stays pinned on
`1/sqrt(x + x^(3/2))`.

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 2, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit 7edf328 into master Oct 2, 2026
34 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the each-linear-written-once branch October 29, 2026 00:43
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