The integral
integral sqrt(x)/(1 + x + x^4) dx
is elementary, and this library declines it. Under u = sqrt(x) it is 2u^2/(1 + u^2 + u^8), a rational function whose denominator is irreducible over the rationals, is not a biquadratic and is not a binomial — so none of the three splits the rational integrator has can take it apart, and it comes back unevaluated. Wolfram Alpha gives
sum_({ω: ω^8 + ω^2 + 1 = 0}) (ω log(sqrt(x) - ω))/(4 ω^6 + 1) + constant
which is the general form: a sum over the roots of a polynomial, with a logarithm at each root. It was the pinned boundary of PowerSubstitutionIntegralTest.WhereTheChainStops in #1284, and the review there is right that a boundary this library cannot represent an answer for should be an issue rather than a test (#1284 (comment)).
What the answer is
For P/Q with deg P < deg Q and Q squarefree, the antiderivative is
sum over roots r of Q of (P(r)/Q'(r)) * ln(x - r)
exactly — the residue at each simple pole times the logarithm there. That is what the Rothstein–Trager theorem states; the Lazard–Rioboo–Trager refinement writes the same sum over the roots of the resultant R(t) = res_x(P - t Q', Q) rather than of Q, which groups the roots that share a residue and keeps the algebraic extension as small as it can be. Every computer algebra system that answers this integral answers it in that form. IntegrateAPolynomialOverABinomial (#1284) is the special case where Q = a x^n + b, whose roots are known in closed form and pair off into real logarithms and arctangents; this issue is the general case, where they are not.
What is missing is a node, not a rule
The rule is two lines once the answer can be written down. What cannot be written down today is a sum over the roots of a polynomial when those roots have no closed form. Three shapes to consider:
- A
RootSum(polynomial, variable, expression) node — the way Maxima's rootsum, Maple's RootOf/sum, and SymPy's RootSum(Poly, Lambda) do it. Evaluates numerically by finding the roots; simplifies when the polynomial factors; differentiates termwise under the sum, so the differentiate-back check still applies. Prints as the sum above.
- A
RootOf(polynomial, index) node and an ordinary Sumf over indices — finer, since a single root is then a value in its own right (a quintic's roots could be spoken of), but the index has to mean something stable, and ordering complex roots is exactly the mess every system with RootOf has to document.
- Decline, and record the reason in the answer — which is what happens now, without the reason.
The first is the smallest change that makes the integral answerable, and it is also what a sum over roots is. It touches the printers, Evaled/EvalNumerical, Differentiate, Substitute and the parser, which is why it is an issue and not a PR.
What it would answer
Rubi's test suite has these by the dozen: every P/Q whose Q is irreducible of degree three or more and not a binomial. In the 463-problem sample run here, 1/(x^3 + x + 1) is the smallest, and x/(1 + x + x^5), (x^2 + 1)/(x^4 + x + 1) and the like sit behind it. With the node, the rational integrator is complete for squarefree denominators; a repeated factor is then the Hermite reduction on top of it, which is a rule again.
Part of #718.
The integral
is elementary, and this library declines it. Under
u = sqrt(x)it is2u^2/(1 + u^2 + u^8), a rational function whose denominator is irreducible over the rationals, is not a biquadratic and is not a binomial — so none of the three splits the rational integrator has can take it apart, and it comes back unevaluated. Wolfram Alpha giveswhich is the general form: a sum over the roots of a polynomial, with a logarithm at each root. It was the pinned boundary of
PowerSubstitutionIntegralTest.WhereTheChainStopsin #1284, and the review there is right that a boundary this library cannot represent an answer for should be an issue rather than a test (#1284 (comment)).What the answer is
For
P/Qwithdeg P < deg QandQsquarefree, the antiderivative isexactly — the residue at each simple pole times the logarithm there. That is what the Rothstein–Trager theorem states; the Lazard–Rioboo–Trager refinement writes the same sum over the roots of the resultant
R(t) = res_x(P - t Q', Q)rather than ofQ, which groups the roots that share a residue and keeps the algebraic extension as small as it can be. Every computer algebra system that answers this integral answers it in that form.IntegrateAPolynomialOverABinomial(#1284) is the special case whereQ = a x^n + b, whose roots are known in closed form and pair off into real logarithms and arctangents; this issue is the general case, where they are not.What is missing is a node, not a rule
The rule is two lines once the answer can be written down. What cannot be written down today is a sum over the roots of a polynomial when those roots have no closed form. Three shapes to consider:
RootSum(polynomial, variable, expression)node — the way Maxima'srootsum, Maple'sRootOf/sum, and SymPy'sRootSum(Poly, Lambda)do it. Evaluates numerically by finding the roots; simplifies when the polynomial factors; differentiates termwise under the sum, so the differentiate-back check still applies. Prints as the sum above.RootOf(polynomial, index)node and an ordinarySumfover indices — finer, since a single root is then a value in its own right (a quintic's roots could be spoken of), but the index has to mean something stable, and ordering complex roots is exactly the mess every system withRootOfhas to document.The first is the smallest change that makes the integral answerable, and it is also what a sum over roots is. It touches the printers,
Evaled/EvalNumerical,Differentiate,Substituteand the parser, which is why it is an issue and not a PR.What it would answer
Rubi's test suite has these by the dozen: every
P/QwhoseQis irreducible of degree three or more and not a binomial. In the 463-problem sample run here,1/(x^3 + x + 1)is the smallest, andx/(1 + x + x^5),(x^2 + 1)/(x^4 + x + 1)and the like sit behind it. With the node, the rational integrator is complete for squarefree denominators; a repeated factor is then the Hermite reduction on top of it, which is a rule again.Part of #718.