Skip to content

Two roots of linears with one slope are rationalised together by their sum - #1576

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
the-sum-of-two-roots-of-linears
Sep 29, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
the-sum-of-two-roots-of-linears

Conversation

@Rafael-SOWNet

@Rafael-SOWNet Rafael-SOWNet commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Part of #718: two square roots of linears with one slope, rationalised together by their sum. It also removes the cause of the macOS flake in ABareInverseFunctionByPartsTest.TheRemainderMayBeOutOfReach.

sqrt(L1) and sqrt(L2) with L1 - L2 = k a constant are rational in v = sqrt(L1) + sqrt(L2):

  • the difference is k/v, since the sum times the difference is L1 - L2 for any values of the two roots;
  • sqrt(L1) = (v + k/v)/2 and sqrt(L2) = (v - k/v)/2;
  • x = ((v - k/v)^2/4 - n2)/m, so dx = (v^4 - k^2)/(2 m v^3) dv for the slope m.

These hold for the principal roots wherever v is not zero, so nothing is assumed about signs.

What it answers. An inverse function of the difference was declined where it is elementary. Charlwood's arcsin(sqrt(1 + x) - sqrt(x)) is arcsin(1/v) (v^4 - 1)/(2 v^3) under v, which parts closes; asked as written, the remainder parts leaves in x is a nested root no rule reads. Rubi's 5.3.7 has the arctangent's powers of x beside it. The sum and the difference are taken whole before the roots are, so the rules in v see 1/v. On the way back 1/v is written as the difference over k, so the answer holds arcsin(sqrt(1 + x) - sqrt(x)) as the integrand does, and sgn(v) is one, since v is positive wherever the integrand is real. Scoped to the question asked or one below it, since it lands on the chain in v.

Only inside an inverse function or a logarithm. The rule takes the sum only where the sum or the difference of the two roots stands inside an inverse trigonometric function or a logarithm, which nothing else reads. A rational function of the two roots is the radical rules' already. The first version took the sum everywhere, and the corpus run found three losses:

  • x^2/(sqrt(a + b x) + sqrt(c + b x)), which the conjugate answers in 37 ms;
  • sqrt(x - 1) sqrt(x + 1)/(1 + x - x^2), which the quotient of the two roots answers in 244 ms;
  • Timofeev's arccos(sqrt(x/(1 + x))), a quotient of the two roots under the function.

Asked under v first, each ran out the budget. The narrowing also gives up three powers of the sum below the bar that the first version answered, x/(sqrt(a + b x) + sqrt(c + b x))^3 among them; master declines those too. TwoLinearRadicalsIntegralTest pins the three losses as answered.

The flake. TheRemainderMayBeOutOfReach bounds Integrate by IntegrationDecline.Guard, 60 s, and its asin(sqrt(1 + x) - sqrt(x)) row was declined in 4.8 to 5.4 s here, three fresh processes each at 68e231d (passed on macOS), 8c964e7 (failed there at 63.8 s) and a8a2b7e. It was never a regression: the macOS runner took thirteen times as long. The row is now answered in half a second, and the test differentiates the answer back.

Input Was (2.5.0) Master Now
asin(sqrt(1 + x) - sqrt(x)) integral(...) declined in 5.3 s answered in 0.46 s
x^3*atan(-sqrt(x)+sqrt(1+x)) integral(...) declined in 19.6 s answered in 0.11 s

TwoLinearRadicalsIntegralTest has six new rows differentiated back: the three inverse functions, and the three the narrowing leaves to the other rules. ABareInverseFunctionByPartsTest passes with the arcsine answered. The two classes pass (net10.0, 28 tests, 6 s), and every target builds.

Measured with work/intbench against master at a8a2b7e7, the commit this is cut from, 3 s a problem (5 s in family 0), on this branch with the narrowing (9aecf64c). Every problem that moved was then re-run on both:

  • The 55 problems with two square roots of linears of one slope (families 0 to 7): 41 → 45 solved, none lost, 0 wrong, and the rows take 26 s instead of 56 s. The gains are Charlwood's arcsine and Rubi's 5.3.7:177, 178 and 184, the arctangent beside a power of x.
  • Family 0 (1814): 1750 → 1751, Charlwood's arcsine; nothing else moves.
  • The families sample (families 1 to 7, five a file, 912 problems): one gain, 5.3.7:177. Two more problems moved in the first pass: 6.6.1:25 and 6.7.1:180, hyperbolic integrands with no root in them, which master answers only well past the budget (20 s and 17 s). Re-run on both builds, the first went the other way and the second did not move, so they are the clock and not this branch.

🤖 Generated with Claude Code

…r sum

sqrt(L1) and sqrt(L2) with L1 - L2 = k a constant are rational in their sum
v = sqrt(L1) + sqrt(L2): the difference is k/v, sqrt(L1) = (v + k/v)/2,
sqrt(L2) = (v - k/v)/2, and dx = (v^4 - k^2)/(2 m v^3) dv for the slope m.
The identities hold for the principal roots wherever v is not zero, so
nothing is assumed about signs. An inverse function of the difference was
declined where it is elementary -- Charlwood's arcsin(sqrt(1 + x) - sqrt(x))
after five seconds, which is what ABareInverseFunctionByPartsTest's
TheRemainderMayBeOutOfReach timed on macOS at 63.8 s against a 60 s bound --
and under v it is arcsin(1/v) beside a rational function of v, which parts
closes. The sum and the difference are taken whole before the roots, so the
rules in v see 1/v, and on the way back 1/v is written as the difference
over k, so the answer holds the difference as the integrand does; v is
positive wherever the integrand is real, so its sign is one. At the question
asked or one below it, since it lands on the chain in v.

TwoLinearRadicalsIntegralTest and ABareInverseFunctionByPartsTest pass
(net10.0), and every target builds.

Part of #718.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rafael-SOWNet

Copy link
Copy Markdown
Member Author

Holding this: the corpus check found three losses. The rule also fired on integrands other rules already answer quickly, and ran them past the 3 s budget:

  • Timofeev 127, acos(sqrt(x/(1 + x))): 12 ms → timeout
  • Rubi 1.3.2:556, x^2/(sqrt(a + b*x) + sqrt(c + b*x)): 37 ms → timeout
  • Rubi 1.2.1.4:1, sqrt(-1 + x)*sqrt(1 + x)/(1 + x - x^2): 244 ms → timeout

The fix narrows the rule to where the sum or difference of the two roots stands inside an inverse trigonometric function or a logarithm. That keeps the arcsine and arctangent gains. It will be pushed as a follow-up commit, and re-measured before merging.

…function

The corpus run found three losses. x^2/(sqrt(a + b x) + sqrt(c + b x)) ran
out the budget under v where the conjugate answers it in 37 ms, and
sqrt(x - 1) sqrt(x + 1)/(1 + x - x^2) where the quotient of the two roots
answers it in 244 ms; so did Timofeev's arccos(sqrt(x/(1 + x))), a quotient
of the two roots under the function, which the rule sees as two roots of one
slope. A rational function of the two roots is the radical rules' already.
So the sum is taken only where the sum or the difference of the two roots
stands inside an inverse trigonometric function or a logarithm, which
nothing else reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rafael-SOWNet

Copy link
Copy Markdown
Member Author

The narrowing is in 9aecf64, and re-measured against a8a2b7e it loses none of the three: the 55 rows with two such roots 41 → 45, family 0 1750 → 1751, and the families sample one gain. The figures are in the description. It merges once the last check passes.

@Rafael-SOWNet
Rafael-SOWNet merged commit ff71e4b into master Sep 29, 2026
31 checks passed
Rafael-SOWNet added a commit that referenced this pull request Sep 29, 2026
Brings in #1576, which retires the macOS flake in ABareInverseFunctionByPartsTest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rafael-SOWNet
Rafael-SOWNet deleted the the-sum-of-two-roots-of-linears branch October 29, 2026 00:44
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