Function Repository Resource:

IntegrateAlgebraic

Source Notebook

Compute the indefinite integral of an algebraic function in terms of elementary functions

Contributed by: Sam Blake

ResourceFunction["IntegrateAlgebraic"][f,x]

gives the indefinite integral , using heuristics for computing elementary solutions to pseudo-elliptic and pseudo-hyperelliptic integrals.

Details and Options

ResourceFunction["IntegrateAlgebraic"] uses a collection of heuristic methods for algebraic integrals.
ResourceFunction["IntegrateAlgebraic"] can integrate all integrands in with the substitution un=ax+b, where n=LCM[n1,n2,].
ResourceFunction["IntegrateAlgebraic"] can integrate all integrands in with the substitution , where n=LCM[n1,n2,].
ResourceFunction["IntegrateAlgebraic"] can integrate all integrands in with the substitution
ResourceFunction["IntegrateAlgebraic"] uses Goursat's reductions whenever applicable.
ResourceFunction["IntegrateAlgebraic"] attempts to simplify integrals using a Laurent polynomial substitution of the form .
For integrands in , ResourceFunction["IntegrateAlgebraic"] attempts to rationalize integrals using substitution of the form , , and .
ResourceFunction["IntegrateAlgebraic"] calls Integrate for rational functions.
ResourceFunction["IntegrateAlgebraic"] does not compute definite integrals. However, ResourceFunction["IntegrateAlgebraic"] tries to return continuous antiderivatives whenever possible.
ResourceFunction["IntegrateAlgebraic"] takes the following options:
"DegreeBound"8degree bound for solving polynomial systems of equations for some Abelian integrals
"Elementary"Truewhether the solution should be only composed of elementary functions
"Expansion"Falsewhether to expand the integrand and integrate term-by-term
"SingleStepTimeConstraint"0.25time constraint in seconds used by some computationally-intensive routines
"SubstitutionSize""Small"the number of terms in the Laurent polynomial substitution
VerifySolutionsTruewhether numeric and symbolic checks are performed on the solution

Examples

Basic Examples (4) 

This is a well-known pseudo-elliptic integral:

In[1]:=
ResourceFunction[
 "IntegrateAlgebraic"][(-1 + x^2)/((1 + x^2) Sqrt[1 + x^4]), x]
Out[1]=

Some integrals are expressed as a rational function of x and the radicals in the integrand:

In[2]:=
ResourceFunction["IntegrateAlgebraic"][(x^3 - 1)/(
 x^6 (x^3 + x^2)^(1/3)), x]
Out[2]=

Other integrals can be expressed in terms of Log, ArcTan and ArcTanh:

In[3]:=
ResourceFunction["IntegrateAlgebraic"][(
 x^2 - x + 2)/((x^2 - 1)^(1/3) (x^2 + 4 x + 3)), x]
Out[3]=

The following is an Abelian integral:

In[4]:=
ResourceFunction["IntegrateAlgebraic"][(3 x + 1)/Sqrt[
 x^4 - 2 x^3 - 5 x^2 - 4 x - 1], x]
Out[4]=

Scope (15) 

IntegrateAlgebraic can integrate all integrands in regardless of their size or complexity:

In[5]:=
ResourceFunction["IntegrateAlgebraic"][(
 1 - x^3 (4 x + 5)^(2/3) - x^3 (4 x + 5)^(1/3))/(
 1 - x (4 x + 5)^(1/2)), x]
Out[5]=

IntegrateAlgebraic can integrate all integrands in :

In[6]:=
ResourceFunction[
 "IntegrateAlgebraic"][1/((1 + x) Sqrt[4 x - 3] + (4 + 3 x) Sqrt[
   2 x - 1]), x]
Out[6]=

IntegrateAlgebraic can integrate all integrands in :

In[7]:=
ResourceFunction[
 "IntegrateAlgebraic"][(((x - 1)/(2 x + 1))^(1/4) - 3 ((x - 1)/(2 x + 1))^(3/4))/((x - 1) (x + 1)^2 (2 x - 1)), x]
Out[7]=

IntegrateAlgebraic can integrate all integrands in , as these are converted to rational functions via Euler’s substitution:

In[8]:=
ResourceFunction["IntegrateAlgebraic"][(
 Sqrt[x^2 - 4 x + 1] + (x^2 - 4 x + 1)^(3/2))/(
 Sqrt[x^2 - 4 x + 1] - (x^2 - 4 x + 1)^(5/2) + (x^2 - 4 x + 1)^(3/2)),
  x]
Out[8]=

For the following integral, IntegrateAlgebraic uses the substitution to reduce the integral to :

In[9]:=
ResourceFunction["IntegrateAlgebraic"][1/((1 + x) (1 - x^3)^(1/3)), x]
Out[9]=

For the following integral, IntegrateAlgebraic uses the substitution to reduce the integral to :

In[10]:=
ResourceFunction[
 "IntegrateAlgebraic"][((-2 + x^3) Sqrt[1 - x^2 + x^3])/(1 + x^3)^2,
  x]
Out[10]=

For the following integral, IntegrateAlgebraic uses the substitution to reduce the integral to :

In[11]:=
ResourceFunction["IntegrateAlgebraic"][(
 3 x + 2)/((9 x^2 + 52 x - 12) (3 x^2 + 4)^(1/3)), x]
Out[11]=

Some integrals will introduce algebraic numbers that are not present in the integrand:

In[12]:=
ResourceFunction[
 "IntegrateAlgebraic"][((-3 + 2 x + 2 x^5) Sqrt[x - x^2 + x^6])/(
 1 - 2 x + x^2 - x^3 + x^4 + 2 x^5 - 3 x^6 - x^8 + x^10), x]
Out[12]=

IntegrateAlgebraic works with radicals other than square roots:

In[13]:=
ResourceFunction["IntegrateAlgebraic"][(x^3 - x^2)^(1/3), x]
Out[13]=

Some integrals will be expressed in terms of RootSum expressions:

In[14]:=
ResourceFunction["IntegrateAlgebraic"][((-1 + x^8) (-1 + x^4)^(1/4))/(
 x^6 (1 + x^8)), x]
Out[14]=

IntegrateAlgebraic can often work with parameters in the integrand:

In[15]:=
ResourceFunction[
 "IntegrateAlgebraic"][((2 c - a x^3) Sqrt[
  a x^3 + b x^2 + c])/((a x^3 + (b - 3) x^2 + c) (a x^3 + (b - 2) x^2 + c)), x]
Out[15]=

IntegrateAlgebraic has a limited ability to integrate nested radicals:

In[16]:=
ResourceFunction["IntegrateAlgebraic"][Sqrt[
 Sqrt[x^2 + 1] + 1]/((x - 1) Sqrt[x^2 + 1]), x]
Out[16]=

IntegrateAlgebraic can succeed on some integrals where the Risch-Bronstein-Trager algorithm struggles:

In[17]:=
ResourceFunction["IntegrateAlgebraic"][
 1/(x^9 (-2 + x^6)) (4 + x^6) (-4 + x^4 + 2 x^6) Sqrt[
   32 - 14 x^4 - 32 x^6 - 4 x^8 + 7 x^10 + 8 x^12], x]
Out[17]=

IntegrateAlgebraic can handle many otherwise difficult integrals involving parameters:

In[18]:=
ResourceFunction["IntegrateAlgebraic"][(
 x^2 + 4 c)/((d x^2 - 4 c) (a x^3 - b x^2)^(1/3)), x]
Out[18]=

IntegrateAlgebraic can handle many integrals when the radicand is a rational function:

In[19]:=
ResourceFunction["IntegrateAlgebraic"][((-2 + x) (1 - x + x^2))/(
 x^3 (-1 + x + x^2) ((1 - x + 2 x^2)/(1 - x + 3 x^2))^(1/3)), x]
Out[20]=
In[21]:=
ResourceFunction[
 "IntegrateAlgebraic"][(-36 - 6 x^2 + 6 x^3 + x^6)/(x (-6 + x^3) (36 - 90 x + 122 x^2 - 96 x^3 + 51 x^4 - 26 x^5 + 15 x^6 - 6 x^7 + x^8) ((6 + x^3)/(-6 + x^3))^(1/6)), x]
Out[21]=

Options (9) 

Expansion (2) 

The option "Expansion" True specifies if the integrals is expanded and integrated term-by-term after exhausting all other possible methods. By default "Expansion" is False, as this method may require many time consuming recursive calls to IntegrateAlgebraic:

In[22]:=
ResourceFunction[
 "IntegrateAlgebraic"][((1 + 2 x + 2 x^2) (x^2 + x^4)^(1/4))/(
 1 + 2 x^2), x]
Out[22]=
In[23]:=
ResourceFunction[
 "IntegrateAlgebraic"][((1 + 2 x + 2 x^2) (x^2 + x^4)^(1/4))/(
 1 + 2 x^2), x, "Expansion" -> True]
Out[23]=

With "Expansion" True, IntegrateAlgebraic may return partial results:

In[24]:=
ResourceFunction[
 "IntegrateAlgebraic"][((x + 2 x^2) (x^2 + x^4)^(1/4))/(1 + 2 x^2), x,
  "Expansion" -> True]
Out[24]=

DegreeBound (2) 

The default for "DegreeBound" is 8:

In[25]:=
ResourceFunction[
 "IntegrateAlgebraic"][x/Sqrt[-71 - 96 x + 10 x^2 + x^4], x]
Out[25]=

Increasing the degree bound can solve some large Abelian integrals:

In[26]:=
ResourceFunction["IntegrateAlgebraic"][(29 x^2 + 18 x - 3)/Sqrt[
 x^6 + 4 x^5 + 6 x^4 - 12 x^3 + 33 x^2 - 16 x], x, "DegreeBound" -> 30]
Out[26]=
In[27]:=
ResourceFunction["IntegrateAlgebraic"][(39 x^2 + 9 x - 1)/Sqrt[
 x^6 + 4 x^4 + 10 x^3 + 4 x^2 - 4 x + 1], x, "DegreeBound" -> 40]
Out[27]=

Elementary (1) 

"Elementary" specifies if the solution should be composed of elementary functions only. By default "Elementary" is True:

In[28]:=
ResourceFunction["IntegrateAlgebraic"][(
  6 x^8 + 1)/((2 x^8 - 1) Power[
   4 x^16 + 2 x^10 - 4 x^8 - x^4 - x^2 + 1, (4)^-1]), x, "Elementary" -> False] // Simplify
Out[28]=

SingleStepTimeConstraint (1) 

The option "SingleStepTimeConstraint" specifies the time in seconds that IntegrateAlgebraic spends in various computationally-intensive routines. The default for "SingleStepTimeConstraint" is 0.25. Increasing this time constraint may solve some integrals that otherwise return unevaluated:

In[29]:=
ResourceFunction[
 "IntegrateAlgebraic"][(1 + x^4)^2/((-1 + x^4)^2 Sqrt[
  x^2 + Sqrt[1 + x^4]]), x]
Out[29]=
In[30]:=
ResourceFunction[
 "IntegrateAlgebraic"][(1 + x^4)^2/((-1 + x^4)^2 Sqrt[
  x^2 + Sqrt[1 + x^4]]), x, "SingleStepTimeConstraint" -> 0.5]
Out[30]=

SubstitutionSize (2) 

The option "SubstitutionSize" determines the number of rational substitutions tried within IntegrateAlgebraic. By default "SubstitutionSize" is "Small". Other settings are "Medium" and "Large". By default, the Laurent polynomial substitution code considers a polynomial with 3 terms only:

In[31]:=
ResourceFunction[
 "IntegrateAlgebraic"][((-1 + x^2 + 2 x^3 + 3 x^4) (1 - 2 x + x^2 + x^4 + 3 x^6 + 2 x^7 + x^8))/(x Sqrt[
    1 - 2 x + 2 x^2 + x^4 + 3 x^6 + 2 x^7 + x^8] (1 - 2 x + 4 x^2 + x^4 + 3 x^6 + 2 x^7 + x^8)), x, "RationalUndeterminedOnly" -> True]
Out[31]=

With "SubstitutionSize""Medium", we use a Laurent polynomial substitution with 4 terms:

In[32]:=
ResourceFunction[
 "IntegrateAlgebraic"][((-1 + x^2 + 2 x^3 + 3 x^4) (1 - 2 x + x^2 + x^4 + 3 x^6 + 2 x^7 + x^8))/(x Sqrt[
    1 - 2 x + 2 x^2 + x^4 + 3 x^6 + 2 x^7 + x^8] (1 - 2 x + 4 x^2 + x^4 + 3 x^6 + 2 x^7 + x^8)), x, "SubstitutionSize" -> "Medium", "RationalUndeterminedOnly" -> True]
Out[32]=

VerifySolutions (1) 

VerifySolutions numerically verifies the solution obtained by IntegrateAlgebraic. By default this is False. Verifying the solution will increase the runtime of IntegrateAlgebraic:

In[33]:=
ResourceFunction["IntegrateAlgebraic"][Sqrt[x^3 + 1]/x, x, VerifySolutions -> False] // Timing // First
ResourceFunction["IntegrateAlgebraic"][Sqrt[x^3 + 1]/x, x, VerifySolutions -> True] // Timing // First
Out[33]=
Out[33]=

Applications (1) 

If the integral is continuous, then the definite integral can be computed using Newton–Leibniz:

In[34]:=
ResourceFunction[
 "IntegrateAlgebraic"][((x^4 - 1) Sqrt[1 + x^4])/(1 + 3 x^2 + x^4)^2,
  x]
Out[34]=
In[35]:=
(% /. x -> 1) - (% /. x -> 0)
Out[35]=
In[36]:=
% - NIntegrate[((x^4 - 1) Sqrt[1 + x^4])/(1 + 3 x^2 + x^4)^2, {x, 0, 1}]
Out[36]=

Properties and Relations (3) 

IntegrateAlgebraic uses SolveAlways to determine if a rational substitution can simplify a radical. Consider the integral and a candidate substitution of the form . The following computation shows that we can reduce to , where :

In[37]:=
Together[a u^2 + b u + c /. u -> (d x^4 + e)/x]
Out[37]=
In[38]:=
x^8 + 2 x^4 + x^2 + 1 == Numerator[%]
Out[38]=
In[39]:=
SolveAlways[%, x]
Out[39]=
In[40]:=
{a u^2 + b u + c, u -> (d x^4 + e)/x} /. %
Out[40]=
In[41]:=
% /. a -> 1
Out[41]=

Once the candidate substitution is known, GroebnerBasis and Solve may be used to simplify the integral. For example, use the substitution to evaluate the integral :

In[42]:=
GroebnerBasis[{Dt[y] == (x^2 - x + 1)/((x^2 - 1) Sqrt[x^3 + x]) Dt[x],
   u == (x^2 + 1)/x, Dt[u == (x^2 + 1)/x]}, {u, Dt[u]}, {Dt[x], x}, MonomialOrder -> EliminationOrder, Method -> "Buchberger"]
Out[42]=
In[43]:=
Solve[%[[1]] == 0, Dt[y]] // Factor // PowerExpand
Out[43]=
In[44]:=
Integrate[%[[1, 1, -1]]/Dt[u], u] /. u -> (x^2 + 1)/x
Out[44]=

This is essentially how IntegrateAlgebraic has computed the integral, except additional post-processing is done to express the integral in terms of the radicals in the integrand (which makes the solution valid for all x):

In[45]:=
ResourceFunction["IntegrateAlgebraic"][(
 x^2 - x + 1)/((x^2 - 1) Sqrt[x^3 + x]), x]
Out[45]=

IntegrateAlgebraic will often return an answer in terms of elementary functions when Integrate will return an answer in terms of special functions:

In[46]:=
ResourceFunction["IntegrateAlgebraic"][(
 2 x^2 + x + 2)/((2 x - 1) Sqrt[x^4 + x]), x]
Out[46]=
In[47]:=
Integrate[(2 x^2 + x + 2)/((2 x - 1) Sqrt[x^4 + x]), x]
Out[47]=

Possible Issues (3) 

Some integrals will take longer than others:

In[48]:=
ResourceFunction["IntegrateAlgebraic"][(
  2 + x)/((-3 + x) (1 - x^2)^(1/4) (1 + x^2)), x] // Timing
Out[48]=
In[49]:=
ResourceFunction["IntegrateAlgebraic"][
  1/((x + 1) (x^4 + 6 x^2 + 1)^(1/4)), x] // Timing
Out[49]=

Trager’s Hermite reduction will always find the rational (algebraic) part of the integral, whereas the methods used by IntegrateAlgebraic will sometimes fail:

In[50]:=
Integrate[(
 x^2 (3 + 2 x^2) (1 + x^2 + 2 x^6))/((1 + x^2)^2 Sqrt[1 + x^2 + x^6]),
  x]
Out[50]=
In[51]:=
ResourceFunction["IntegrateAlgebraic"][(
 x^2 (3 + 2 x^2) (1 + x^2 + 2 x^6))/((1 + x^2)^2 Sqrt[1 + x^2 + x^6]),
  x]
Out[51]=

IntegrateAlgebraic will fail to compute some algebraic integrals which possess elementary solutions:

In[52]:=
ResourceFunction["IntegrateAlgebraic"][x/((x^3 + 8) Sqrt[x^3 - 1]), x]
Out[52]=
In[53]:=
\!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]\((
\*FractionBox[\(1\), \(18\)]\ ArcTan[
\*FractionBox[\(1 - 2\ x + 
\*SuperscriptBox[\(x\), \(2\)]\), \(3\ 
\*SqrtBox[\(\(-1\) + 
\*SuperscriptBox[\(x\), \(3\)]\)]\)]] + 
\*FractionBox[\(1\), \(18\)]\ ArcTan[
\*FractionBox[\(1\), \(3\)]\ 
\*SqrtBox[\(\(-1\) + 
\*SuperscriptBox[\(x\), \(3\)]\)]] + 
\*FractionBox[\(ArcTanh[
\*FractionBox[\(
\*SqrtBox[\(3\)]\ 
\*SqrtBox[\(\(-1\) + 
\*SuperscriptBox[\(x\), \(3\)]\)]\), \(1 + x + 
\*SuperscriptBox[\(x\), \(2\)]\)]]\), \(6\ 
\*SqrtBox[\(3\)]\)])\)\) // Simplify
Out[53]=
In[54]:=
ResourceFunction[
 "IntegrateAlgebraic"][x/((1 + x) Sqrt[
  1 + 8 x + 12 x^2 + 8 x^3 + 4 x^4]), x]
Out[54]=
In[55]:=
\!\(
\*SubscriptBox[\(\[PartialD]\), \({x}\)]\((\(-Log[1 + x]\) + 
\*FractionBox[\(1\), \(6\)]\ Log[43 + 258\ x + 612\ 
\*SuperscriptBox[\(x\), \(2\)] + 772\ 
\*SuperscriptBox[\(x\), \(3\)] + 624\ 
\*SuperscriptBox[\(x\), \(4\)] + 360\ 
\*SuperscriptBox[\(x\), \(5\)] + 112\ 
\*SuperscriptBox[\(x\), \(6\)] + 
\*SqrtBox[\(1 + 8\ x + 12\ 
\*SuperscriptBox[\(x\), \(2\)] + 8\ 
\*SuperscriptBox[\(x\), \(3\)] + 4\ 
\*SuperscriptBox[\(x\), \(4\)]\)]\ \((\(-11\) - 22\ x + 30\ 
\*SuperscriptBox[\(x\), \(2\)] + 92\ 
\*SuperscriptBox[\(x\), \(3\)] + 52\ 
\*SuperscriptBox[\(x\), \(4\)])\)])\)\) // Simplify
Out[55]=

Neat Examples (2) 

Some integrals require many logarithms (including ArcTan and ArcTanh):

In[56]:=
ResourceFunction["IntegrateAlgebraic"][(
 x^6 - x^3 + 1)/((x^6 - 1) (x^4 + x^2)^(1/3)), x]
Out[56]=

Some integrals introduce complicated algebraic numbers:

In[57]:=
ResourceFunction["IntegrateAlgebraic"][(
 x^4 - 1)/((x^4 + 1) Power[x^9 - x^7, (8)^-1]), x]
Out[57]=

Publisher

Sam Blake

Version History

  • 2.0.0 – 10 August 2021
  • 1.0.0 – 17 March 2021

Source Metadata

Related Resources

License Information