Basically, this question can be considered to be an extenstion to my other question.

What I wanted to do was this integral as homework (it is indefinite BTW so no approximations using Simpson's Rule or Boole's Rule)


So using Mathematica's Integrate function the answer was


Apparently, after rigorous substitutions and transformations the answer was found to be correct.

What I wanted to know was how Mathematica integrates these functions that require a human tons of intuition to compute, within seconds, and often in the most simple way and also presents them in the most humanly computable form.

(Even differentiation for that matter)

  • 2
    $\begingroup$ See my answer here. $\endgroup$ Commented Jun 14, 2012 at 15:07
  • 2
    $\begingroup$ One common method for expressions with elementary functions is the Risch algorithm. You can Google this and you'll get lots of interesting references. This is not a simple to implement algorithm though, according to the descriptions (I don't know how it works). In fact technically it is not even an algorithm because it involves a step where it's necessary to decide whether an expression is identically zero---which is an undecidable problem. $\endgroup$
    – Szabolcs
    Commented Jun 14, 2012 at 15:07
  • $\begingroup$ Just for kicks I threw this integral at both Mathematica 8 and Maple 15. No problem for Mathematica, but Maple chokes. $\endgroup$
    – Cassini
    Commented Jun 15, 2012 at 1:39
  • $\begingroup$ @DavidSkulsky Any reasons Why it may be so? $\endgroup$ Commented Jun 15, 2012 at 6:47
  • $\begingroup$ @The-Ever-Kid: Beats me. $\endgroup$
    – Cassini
    Commented Jun 15, 2012 at 13:31

1 Answer 1


I can only direct you to Some Notes on Internal Implementation:

Differentiation and Integration

Differentiation uses caching to avoid recomputing partial results.

For indefinite integrals, an extended version of the Risch algorithm is used whenever both the integrand and integral can be expressed in terms of elementary functions, exponential integral functions, polylogarithms, and other related functions.

For other indefinite integrals, heuristic simplification followed by pattern matching is used.

The algorithms in Mathematica cover all of the indefinite integrals in standard reference books such as Gradshteyn-Ryzhik.

Definite integrals that involve no singularities are mostly done by taking limits of the indefinite integrals.

Many other definite integrals are done using Marichev-Adamchik Mellin transform methods. The results are often initially expressed in terms of Meijer G functions, which are converted into hypergeometric functions using Slater's theorem and then simplified.

Integrals over multidimensional regions defined by inequalities are computed by iterative decomposition into disjoint cylindrical or triangular cells.

Integrate uses about 500 pages of Mathematica code and 600 pages of C code.

  • 2
    $\begingroup$ You could probably execute Risch by hand, but it's a nasty business. It's one of those things where using a computer is better. $\endgroup$ Commented Jun 14, 2012 at 15:09
  • 1
    $\begingroup$ To further explain the sixth entry: the elementary functions, as well as most of the usual special functions, are in fact special cases of the Meijer $G$-function or the generalized hypergeometric function. Mathematica knows how to integrate those, and upon integrating those, figures out if the result can then be expressed in terms of "simpler" functions. $\endgroup$ Commented Jun 14, 2012 at 15:12
  • 7
    $\begingroup$ I don't believe that Mathematica has the full Risch. For example it fails on Integrate[x^3 ExpIntegralE[1, x], x], which could rightly evaluate to 1/4 E^-x (-6 - 6 x - 3 x^2 - x^3 + E^x x^4 ExpIntegralE[1, x]). $\endgroup$
    – M.R.
    Commented Jun 14, 2012 at 22:34
  • 2
    $\begingroup$ For example it fails on Integrate[x^3 ExpIntegralE[1, x], x] as of version 10.01, M can now solve this and gives this: -x^3 ExpIntegralE[2, x] - 3 (x^2 ExpIntegralE[3, x] + 2 (x ExpIntegralE[4, x] + ExpIntegralE[5, x])) which is the same as the expression you show. (after some simplifications) $\endgroup$
    – Nasser
    Commented Nov 19, 2014 at 5:16
  • 5
    $\begingroup$ "The algorithms in Mathematica cover all of the indefinite integrals in standard reference books such as Gradshteyn-Ryzhik" ... under /.{"all" -> "most"}. As an example, it will bail on $$\int_{-\infty}^\infty \mathrm{erf}(1+x)e^{-x^2}\mathrm dx,$$ which Gradshteyn and Ryzhik will happily evaluate in terms of an error function. You don't have to go that far to catch that statement out. $\endgroup$ Commented Jul 5, 2016 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.