21

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)

$$\int(x^{3m}+x^{2m}+x^{m})(2x^{2m}+3x^{m}+6)^{\frac1{m}}dx$$

So using Mathematica's Integrate function the answer was

Answer

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)

The-Ever-Kid
  • 1,129
  • 10
  • 19
  • 2
  • 2
    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. – Szabolcs Jun 14 '12 at 15:07
  • Just for kicks I threw this integral at both Mathematica 8 and Maple 15. No problem for Mathematica, but Maple chokes. – Cassini Jun 15 '12 at 01:39
  • @DavidSkulsky Any reasons Why it may be so? – The-Ever-Kid Jun 15 '12 at 06:47
  • @The-Ever-Kid: Beats me. – Cassini Jun 15 '12 at 13:31
  • @DavidSkulsky You are not right:

    int((x^(3m)+x^(2m)+x^m)(2x^(2m)+3x^m+6)^(1/m), x); (1/6)xx^m(2(x^m)^2+3x^m+6)(2(x^m)^2+3x^m+6)^(1/m)/(1+m)

    –  Jun 17 '12 at 08:13
  • Hmmm... I wonder what I did wrong. I'll try it again. – Cassini Jun 17 '12 at 13:35

1 Answers1

19

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.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • 2
    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. – J. M.'s missing motivation Jun 14 '12 at 15:09
  • Symbolic integration is performed by a fairly small number of very systematic procedures. For indefinite integration, the idea of these procedures is to find the most general form of the integral, then to differentiate this and try to match up undetermined coefficients. Often this procedure produces at an intermediate stage immensely complicated algebraic expressions, and sometimes very sophisticated kinds of mathematical functions. But the great advantage of the procedure is that it is completely systematic – Dr. belisarius Jun 14 '12 at 15:11
  • and its operation requires no special cleverness of the kind that only a human could be expected to provide. – Dr. belisarius Jun 14 '12 at 15:11
  • @J.M. Do you understand how that works? If there are any easy to follow descriptions, I'd appreciate a link. – Szabolcs Jun 14 '12 at 15:11
  • 1
    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. – J. M.'s missing motivation Jun 14 '12 at 15:12
  • @Szabolcs: the most primitive version, I learned from the book by Geddes, Czapor, and Labahn (the guys involved with Maple). I'm told Mathematica made further refinements, but I can find no further information on them. – J. M.'s missing motivation Jun 14 '12 at 15:13
  • I'd not be surprised if WRI treated the details as trade secret. – celtschk Jun 14 '12 at 15:22
  • @celt, very likely, yes, their refinements to Risch are proprietary. – J. M.'s missing motivation Jun 14 '12 at 15:27
  • @ everyone-who-commented After going through all your comments and checking these links I've decided to stick on to my textbook calculus.cause this is like biting off more than i can chew. – The-Ever-Kid Jun 14 '12 at 15:31
  • @The-Ever-Kid: "this is like biting off more than i can chew" - yes, that's pretty much what I was trying to say in the answer of mine I linked to. – J. M.'s missing motivation Jun 14 '12 at 15:40
  • @J.M. I found this on the Documentation Most such formulas used in Mathematica were actually derived by Mathematica itself. What does it mean? – The-Ever-Kid Jun 14 '12 at 20:44
  • @The-Ever-Kid: It means what it says. A good number of the approximations to transcendental functions used internally were derived with programs written in Mathematica. – J. M.'s missing motivation Jun 14 '12 at 22:21
  • 7
    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]). – M.R. Jun 14 '12 at 22:34
  • Here is a great resource for learning about CAS integrators. – M.R. Jun 14 '12 at 22:35
  • @Mike, and in fact a number of Bronstein's methods are implemented within Mathematica. That exponential integral example is weird; the thing is able to do -Integrate[x^3 ExpIntegralEi[-x], x], as well as Integrate[x^3 Gamma[0, x], x], but it can't do your integral. Huh. – J. M.'s missing motivation Jun 15 '12 at 12:07
  • 1
    Re @belisarius comments: One might wonder why students aren't taught to do symbolic integration the way CASs do it. Also, many years ago I attended a short course on the math behind CASs, and I recall one of the experts saying that for symbolic integration it was much harder to handle rational functions than transcendental functions, at least in terms of the amount of code involved. – murray Oct 13 '12 at 00:11
  • 2
    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) – Nasser Nov 19 '14 at 05:16
  • 5
    "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. – Emilio Pisanty Jul 05 '16 at 00:39
  • I wonder how long until they "patch that hole". (Hopefully in a manner that rounds out their integrator to a new swath of solutions, not just that and very similar forms..) – Alex Meiburg Jul 07 '16 at 10:44