# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Compute the indefinite integral of a rational function

Contributed by:
Sam Blake

ResourceFunction["IntegrateRational"][ gives the indefinite integral of the rational function, |

IntegrateRational uses Mack's "linear" Hermite reduction for the rational part of the integral, the Lazard-Rioboo-Trager algorithm for the logarithmic part of the integral, and Rioboo's algorithm for expressing complex logarithms as real arc-tangents and real logarithms.

ResourceFunction["IntegrateRational"] will convert sums of real logarithms to hyperbolic arc-tangents where possible, providing the conversion does not introduce any discontinuities.

ResourceFunction["IntegrateRational"] may give different results depending on the assumptions of the signs of parameters in the integrand.

Extension | Automatic | specifies the generators for the algebraic number field to be used in the factorization of the integrand’s denominator prior to decomposition into partial fractions |

"PartialFractions" | True | specifies if a partial fraction decomposition is used on the integrand after Hermite reduction and prior to computing the logarithmic terms |

"LogToArcTan" | True | specifies if Rioboo’s algorithm is used for expressing complex logarithms as real arc-tangents and real logarithms, and an algorithm for converting sums of real logarithms to hyperbolic arc-tangents where possible providing the conversion does not introduce any discontinuities. If the integrand contains parameters, then Rioboo’s algorithm is not used |

"Radicals" | True | specifies if the integral is left as a RootSum object, or converted into radicals where possible |

Compute the integral of a rational function:

In[1]:= |

Out[1]= |

Compute the integral of a rational function (using Mack's Hermite reduction) where the solution does not contain any logarithmic terms:

In[2]:= |

Out[2]= |

Computes a continuous solution to rational integral given in *Symbolic Integration** I *by Manuel Bronstein:

In[3]:= |

Out[3]= |

IntegrateRational can compute many integrals for which Integrate fails to return an elementary form:

In[4]:= |

Out[4]= |

In comparison, here's the result from Integrate:

In[5]:= |

Out[5]= |

Similarly, the following integral has a concise form from IntegrateRational:

In[6]:= |

Out[6]= |

While Integrate expresses the result as a RootSum:

In[7]:= |

Out[7]= |

Some integrals will be expressed in finite terms by IntegrateRational, whereas Integrate returns unevaluated:

In[8]:= |

Out[8]= |

In[9]:= |

Out[9]= |

Integrating some rational functions will introduce algebraic numbers. The solution from IntegrateRational is in the minimal algebraic extension field:

In[10]:= |

Out[10]= |

In[11]:= |

Out[11]= |

Other integrals will be expressed with hyperbolic arc-tangents:

In[12]:= |

Out[12]= |

IntegrateRational works with integrands that contain parameters:

In[13]:= |

Out[13]= |

The option "PartialFractions" specifies if a partial fraction decomposition (with Apart) and term-by-term integration should be used:

In[14]:= |

Out[14]= |

In[15]:= |

Out[15]= |

Computing integrals of rational functions using partial fraction decompositions with factorizations over different algebraic extension fields can give alternative forms:

In[16]:= |

Out[16]= |

In[17]:= |

Out[17]= |

By default, sums of complex logarithms are converted into arc-tangents, and sums of real logarithms are converted into hyperbolic arc-tangents:

In[18]:= |

Out[18]= |

This feature can be turned off:

In[19]:= |

Out[19]= |

The output from IntegrateRational will be real and continuous on the real line where possible:

In[20]:= |

Now evaluate at the endpoints 0 and 1, thus effectively computing a closed form for the definite integral using the Newton-Leibniz theorem:

In[21]:= |

Out[22]= |

By comparison, Integrate gives a substantially more complicated (though equivalent) result:

In[23]:= |

Out[23]= |

Verify numerically that this is *π*:

In[24]:= |

Out[24]= |

Use the Newton-Leibniz method to compute alternative forms to Integrate for definite integrals:

In[25]:= |

Out[26]= |

Compare to Integrate:

In[27]:= |

Out[27]= |

Verify equivalence:

In[28]:= |

Out[28]= |

As the result from IntegrateRational is in the minimal algebraic extension field, we know the following integral cannot be expressed without introducing the algebraic number :

In[29]:= |

Out[29]= |

For many simple rational integrals, the result from IntegrateRational and Integrate will often be the same:

In[30]:= |

Out[30]= |

In[31]:= |

Out[31]= |

In[32]:= |

Out[32]= |

Even though a partial fraction decomposition is not immediately possible (via Apart), a concise form for this integral is still possible with IntegrateRational:

In[33]:= |

Out[33]= |

Whereas Integrate requires a complete factorization of the denominator of the integrand:

In[34]:= |

Out[34]= |

Some integrals will be expressed using Root and RootSum:

In[35]:= |

Out[35]= |

In[36]:= |

Out[36]= |

IntegrateRational expands polynomials prior to integration:

In[37]:= |

Out[37]= |

In[38]:= |

Out[38]= |

The algorithms used by IntegrateRational requires either exact expressions or expressions which rationalize to exact expressions:

In[39]:= |

Out[39]= |

In[40]:= |

Out[40]= |

The integral of many rational functions will be significantly larger than the integrand:

In[41]:= |

Out[41]= |

Sometimes additional simplification is required to express the integral in the minimal algebraic extension field:

In[42]:= |

Out[42]= |

Compare the result above to the following result obtained with Rubi:

In[43]:= |

Out[43]= |

For some integrals, especially integrals that contain algebraic number coefficients, IntegrateRational may take significantly longer than Integrate:

In[44]:= |

Out[44]= |

In[45]:= |

Out[45]= |

Further simplification of the result from IntegrateRational may be possible:

In[46]:= |

Out[46]= |

In[47]:= |

Out[47]= |

Integrating some rational functions will introduce many logarithms and arc-tangents:

In[48]:= |

Out[48]= |

While other rational functions are integrable in terms of algebraic functions without the introduction of new logarithms or arc-tangents:

In[49]:= |

Out[49]= |

The following integral cannot be solved without introducing the algebraic number :

In[50]:= |

Out[50]= |

Many rational integrals (and algebraic integrals) will have symmetric instances of ArcTan and ArcTanh:

In[51]:= |

Out[51]= |

Wolfram Language 13.0 (December 2021) or above

- 1.0.0 – 10 April 2024

This work is licensed under a Creative Commons Attribution 4.0 International License