Mixed trigonometric arguments unified, a half-power of 1 + sin closed, a power of an inverse tangent by parts, and a symbolic repeated linear factor - #1286
Merged
Conversation
…, a power of an inverse tangent by parts, and a symbolic repeated linear factor Four families the Rubi sample was declining, each answered by one rule or one bound, with the two runaway declines each opened measured and closed before it shipped. ## Different multiples of one argument `sin(x)/cos(2x)`, `(cos(x) + sin(x))/sin(2x)`, `cos(x)/(sin(x) tan(x/2))` had no antiderivative, while each with the double or half angle written out by hand came out. Every trigonometric rule reads one argument. The new rule rewrites the integrand to one: down to the greatest common divisor of the slopes through the Chebyshev recurrences `cos(nt) = T_n(cos t)`, `sin(nt) = sin(t) U_(n-1)(cos t)`; or -- when only an argument and its double are present and the integrand is *even* in the smaller, every monomial `sin^p cos^q` having `p + q` even -- up to the double, at half the degree. Moses's `sec(2t)/(1 + sec(t)^2 + 3 tan(t))` is answered in a third of a second the second way and declined after five the first. What it hands on is one quotient with the common factors cancelled, because `tan(x)/tan(2x)` becomes `(s/c) / (2sc/(2c^2 - 1))` and on that shape, or on the single quotient with the `s` still in it, the search ran twenty-five seconds to decline `1 - 1/(2c^2)`. `Simplify` is not the tool: it folds `2sc` back into `sin(2x)` and hands the rule its own input. Two bounds, both from the corpus rather than from caution. Rational in the trigonometric functions only -- a radical or fractional power of one is a different integrand, and `sqrt(cos(x) sin(x)^3)` beside `sin(2x)` and `(2 - 3 sin^2)^(3/5) sin(4x)` were each a five-second timeout for a decline that took a tenth of that before. And a cap on the degree the rewriting produces: `1/(cos(x) + cos(3x))^5` is degree fifteen in the sine and cosine, and went the same way. ## `(a + b sin(cx + d))^n` for `a^2 = b^2` `sqrt(1 + sin(x))` had no antiderivative. It is `-2 cos(x)/sqrt(1 + sin(x))`, and the cancellation `cos^2 = (1 - sin)(1 + sin)` that checks it is what `a^2 = b^2` buys. Above the base case, one step of parts lowers `n` by one -- Rubi's rule for the same case -- so `(1 - sin(2x/3))^(5/2)` is two steps and the base. The cosine is the same rule with `sin` replaced by `-cos` in the boundary term. `a^2 = b^2` is decided, not assumed; `sqrt(1 + 2 sin(x))` is elliptic and is declined. ## A power of an inverse tangent, by two rounds of parts `x arctan(x)^2` leaves `x^2 arctan(x)/(1 + x^2)` after one step, which has more nodes and needs one more step to finish; on nodes alone the second step was refused. The power fell from two to one, and that is the descent the step made. The measure is now the pair, power first: a step that lowers the power may grow the expression, and one that keeps it must shrink it, so the pair is well-founded. Two things were measured on the way. A remainder whose power has fallen to *zero* is whatever the derivative and the integral made together -- for `asec(x)^2` times a radical, a hundred-node radical expression -- and admitting it on the power opened a by-parts search at every level: thirty seconds to decline, one without. So the power admits a remainder only while a factor is left for the next round. And the remainder is re-spelled as the product its next step reads, since `Simplify` writes it as a quotient and parts runs on a product -- but only where what stands beside the factor is rational in the variable, for the same measured reason. ## A repeated linear factor with a symbol in it `1/(a + b e^(px))^2` is `1/(p u (a + b u)^2)` under `u = e^(px)`. The symbolic partial-fraction split (#1284) read `(a + b u)^2` as a quadratic; it is a repeated linear factor, and is now one block `P/(a + b u)^2` with `P` of degree one -- which is then a shape nothing read: `(c + d x)/(a + b x)^2` came out with numbers and not with symbols, the rational-root split being the only thing that ever answered it. Under `t = a + b x` it is a sum of powers of `t`, and that rule is here too. A repeated symbolic quadratic has nothing to land on and stays declined. ## Measured Every answer differentiated back, with parameters pinned. Rubi corpus, 463-problem sample, against #1284's branch it was cut from, both timed on the same afternoon: #1284 290/463, 0 wrong, 0 timeouts, 95 s with this 300/463, 0 wrong, 0 timeouts, 95 s Ten more and nothing lost: `sin(x)/cos(2x)`, `(cos(x) + sin(x))/sin(2x)`, `cos(x)/(sin(x) tan(x/2))`, `sec(2t)/(1 + sec(t)^2 + 3 tan(t))`, `sqrt(1 + sin(x))`, `(1 - sin(2x/3))^(5/2)`, `x arctan(x)^2`, `arctan(x)^2/x^3`, `1/(a + b e^(px))^2`, and `ln(sin(x))/(1 + sin(x))`, which the by-parts measure reached on its own. The sum of per-problem time over the sample is 94 s on both sides. `ExpandedPowerIntegralTest.APowerInsideAQuotientIsNotReached` pinned `(a - b x^2)^3/x^7` as declined and said it would move rather than be deleted when something answered it; `x^7` is a power of a linear, and it moved. The five test suites are green. Part of #718. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Rafael-SOWNet
added a commit
that referenced
this pull request
Sep 11, 2026
…ermite reduction first for a repeated factor, and a cache that had been remembering a scoped decline (#1287) `e^x x/(1 + x)^2` is `(e^x/(1 + x))'`. `e^(x^2)(1 + 2x^2)` is `(x e^(x^2))'`. `(4x^5 - 1)/(1 + x + x^5)^2` is `(-x/(1 + x + x^5))'`. None had an antiderivative: the first two are not a polynomial times an exponential, which is the shape by parts reads, and the third has a denominator nothing factors. ## The ansatz Liouville's theorem says the elementary antiderivative of `e^h R`, with `h` and `R` rational, is `e^h` times a rational function where it exists at all. So the rule writes `F = e^h N/D`, with `D` read off the denominator of `R` -- every written power lowered by one, then the denominator itself, and every level of a single written power, since with an exponential in front the antiderivative's denominator need not be one below the integrand's (`e^(1/x)(1 + x)/x^4` has `x^2` under it) -- and `N` a polynomial of unknown coefficients. `F' = e^h R` is then a polynomial identity linear in those coefficients, solved by the elimination the symbolic partial-fraction split uses and **checked at sampled points with every symbol pinned before anything is returned**. An ansatz that finds no `N` has, by Liouville, shown there is no elementary antiderivative of that shape: `e^x/x`, `e^(x^2)` and `e^x/(1 + x)` are declined in a millisecond each, and a test pins that they stay declined. A sum whose terms share one exponential is read whole: `e^(x^2) + 2x^2 e^(x^2)` is `(x e^(x^2))'`, and neither term is elementary on its own, so splitting it first -- which linearity does -- loses it. The identity is built **one column at a time** as a numeric polynomial rather than once with the unknowns in it. With fourteen unknowns over a degree-eleven denominator the single symbolic expansion did not return; the fourteen numeric ones take a moment. ## The Hermite reduction, and first With no exponential the same ansatz is the rational part of the Hermite reduction, and the full form is taken: `R = (N/D)' + M/D_1`, with `D_1` the product of the distinct factors and `M` a second unknown polynomial, so that a logarithmic part beside the rational one does not defeat it. `(1 + x^2 + x^4)/((1 + x^2)(4 + x^2)^2)` has both. What is left, `M/D_1`, is a proper fraction over a squarefree denominator, and it is handed to the splits and not to the whole integrator: handing it to the whole integrator sent one such remainder through every substitution and by-parts attempt there is, thirty seconds to decline what the splits decline in milliseconds. A denominator with a written repeated factor takes this **first**, ahead of the coprime split and the root peeling. `(1 + x^2)/(x (1 + x^3)^2)` reached the same answer through those after seventeen seconds of peeling and re-factoring; this way it is under a tenth of one. `x^7`, `(x^3 + 2)^2` and `(1 + x^4)^3` are the same story. ## Integration by parts with neither factor worth differentiating The classic "neither is a polynomial, try both orderings" case of by parts ran on any product. Once the Hermite reduction answered `∫u` for a small rational piece of a radical trigonometric integrand, by parts carried on with `v' ∫u`, three hundred nodes of mixed arguments against forty, and every substitution below was tried on it: thirty seconds to decline where it had taken a tenth of one. The case now runs only with a factor worth differentiating -- a logarithm or an inverse function, whose derivative is algebraic, or an exponential, whose integral is itself and which the cyclic cases need. Measured on the Rubi sample with the restriction and without: the same answers, eight seconds less. ## The cache That restriction surfaced a defect that by parts had been hiding. Five rules answer only the question asked (#1265) and decline the same integrand one level down, and the integrator's cache held such a `null` without the scope it was made in. `cos(x)^(-3)`, tried inside the search for `1/cos(x)^3` and declined there by the scoped secant reduction, was then declined *from the cache* in two milliseconds when asked for directly -- unseen until now because by parts used to answer it at depth two regardless. The key carries the scope; a lookup takes a decline only from its own scope and an answer from either, since an antiderivative that was found is right wherever it is asked for. A test asks the two integrals in that order. ## Measured Every answer differentiated back, with parameters pinned. Rubi corpus, 463-problem sample, against the master it was cut from (#1286), both timed on the same evening: master 300/463, 0 wrong, 0 timeouts, 102 s with this 312/463, 0 wrong, 0 timeouts, 76 s Twelve more and nothing lost: `e^x x/(1 + x)^2`, `e^(x^2)(1 + 2x^2)` twice and once as a sum (Moses), `e^(1/x)(1 + x)/x^4` (Hearn), Hebisch's `e^(1/(x^2 - 1))` times a rational function, `(4x^5 - 1)/(1 + x + x^5)^2` (Apostol), Stewart's `(1 + x^2 + x^4)/((1 + x^2)(4 + x^2)^2)`, Timofeev's `x^5/(1 + x^4)^3` and `(1 + x^2)/(x (1 + x^3)^2)`, and two the reduction reached on its own: `ln(x)/(1 + ln(x))^2` and `(3x - 1)^(4/3)/x^2`. The sum of per-problem time over the sample is 100 s to 75 s. Two pinned declines moved as their tests said they would: `BinomialDenominatorIntegralTest` had `1/(x^3 + 2)^2` as outside the binomial rule's shape, and it is the reduction's first and then the rule's; `ExpandedPowerIntegralTest` had `(a - b x^2)^3/x^7` as unreached, and `x^7` is a power of a linear. The five test suites are green. Part of #718. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Four families the Rubi sample was declining, each answered by one rule or one bound,
with the two runaway declines each opened measured and closed before it shipped.
Different multiples of one argument
sin(x)/cos(2x),(cos(x) + sin(x))/sin(2x),cos(x)/(sin(x) tan(x/2))had noantiderivative, while each with the double or half angle written out by hand came
out. Every trigonometric rule reads one argument. The new rule rewrites the
integrand to one: down to the greatest common divisor of the slopes through the
Chebyshev recurrences
cos(nt) = T_n(cos t),sin(nt) = sin(t) U_(n-1)(cos t); or --when only an argument and its double are present and the integrand is even in the
smaller, every monomial
sin^p cos^qhavingp + qeven -- up to the double, athalf the degree. Moses's
sec(2t)/(1 + sec(t)^2 + 3 tan(t))is answered in a thirdof a second the second way and declined after five the first.
What it hands on is one quotient with the common factors cancelled, because
tan(x)/tan(2x)becomes(s/c) / (2sc/(2c^2 - 1))and on that shape, or on thesingle quotient with the
sstill in it, the search ran twenty-five seconds todecline
1 - 1/(2c^2).Simplifyis not the tool: it folds2scback intosin(2x)and hands the rule its own input.Two bounds, both from the corpus rather than from caution. Rational in the
trigonometric functions only -- a radical or fractional power of one is a different
integrand, and
sqrt(cos(x) sin(x)^3)besidesin(2x)and(2 - 3 sin^2)^(3/5) sin(4x)were each a five-second timeout for a decline that took a tenth of that before. And
a cap on the degree the rewriting produces:
1/(cos(x) + cos(3x))^5is degreefifteen in the sine and cosine, and went the same way.
(a + b sin(cx + d))^nfora^2 = b^2sqrt(1 + sin(x))had no antiderivative. It is-2 cos(x)/sqrt(1 + sin(x)), and thecancellation
cos^2 = (1 - sin)(1 + sin)that checks it is whata^2 = b^2buys.Above the base case, one step of parts lowers
nby one -- Rubi's rule for the samecase -- so
(1 - sin(2x/3))^(5/2)is two steps and the base. The cosine is the samerule with
sinreplaced by-cosin the boundary term.a^2 = b^2is decided, notassumed;
sqrt(1 + 2 sin(x))is elliptic and is declined.A power of an inverse tangent, by two rounds of parts
x arctan(x)^2leavesx^2 arctan(x)/(1 + x^2)after one step, which has morenodes and needs one more step to finish; on nodes alone the second step was refused.
The power fell from two to one, and that is the descent the step made. The measure
is now the pair, power first: a step that lowers the power may grow the expression,
and one that keeps it must shrink it, so the pair is well-founded.
Two things were measured on the way. A remainder whose power has fallen to zero is
whatever the derivative and the integral made together -- for
asec(x)^2times aradical, a hundred-node radical expression -- and admitting it on the power opened
a by-parts search at every level: thirty seconds to decline, one without. So the
power admits a remainder only while a factor is left for the next round. And the
remainder is re-spelled as the product its next step reads, since
Simplifywritesit as a quotient and parts runs on a product -- but only where what stands beside
the factor is rational in the variable, for the same measured reason.
A repeated linear factor with a symbol in it
1/(a + b e^(px))^2is1/(p u (a + b u)^2)underu = e^(px). The symbolicpartial-fraction split (#1284) read
(a + b u)^2as a quadratic; it is a repeatedlinear factor, and is now one block
P/(a + b u)^2withPof degree one -- whichis then a shape nothing read:
(c + d x)/(a + b x)^2came out with numbers and notwith symbols, the rational-root split being the only thing that ever answered it.
Under
t = a + b xit is a sum of powers oft, and that rule is here too. Arepeated symbolic quadratic has nothing to land on and stays declined.
Measured
Every answer differentiated back, with parameters pinned.
Rubi corpus, 463-problem sample, against #1284's branch it was cut from, both timed
on the same afternoon:
Ten more and nothing lost:
sin(x)/cos(2x),(cos(x) + sin(x))/sin(2x),cos(x)/(sin(x) tan(x/2)),sec(2t)/(1 + sec(t)^2 + 3 tan(t)),sqrt(1 + sin(x)),(1 - sin(2x/3))^(5/2),x arctan(x)^2,arctan(x)^2/x^3,1/(a + b e^(px))^2, andln(sin(x))/(1 + sin(x)), which the by-parts measure reached on its own. The sum ofper-problem time over the sample is 94 s on both sides.
ExpandedPowerIntegralTest.APowerInsideAQuotientIsNotReachedpinned(a - b x^2)^3/x^7as declined and said it would move rather than be deleted whensomething answered it;
x^7is a power of a linear, and it moved.The five test suites are green.
Part of #718.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura