**3.5.7 Integrals That Can and Cannot Be Done**

Evaluating integrals is much more difficult than evaluating derivatives. For derivatives, there is a systematic procedure based on the chain rule that effectively allows any derivative to be worked out. But for integrals, there is no such systematic procedure.

One of the main problems is that it is difficult to know what kinds of functions will be needed to evaluate a particular integral. When you work out a derivative, you always end up with functions that are of the same kind or simpler than the ones you started with. But when you work out integrals, you often end up needing to use functions that are much more complicated than the ones you started with.

This integral can be evaluated using the same kind of functions that appeared in the input.
In[1]:= **Integrate[Log[x]^2, x]**

Out[1]=

But for this integral the special function LogIntegral is needed.
In[2]:= **Integrate[Log[Log[x]], x]**

Out[2]=

It is not difficult to find integrals that require all sorts of functions.
In[3]:= **Integrate[Sin[x^2], x]**

Out[3]=

Simple-looking integrals can give remarkably complicated results. Often it is convenient to apply Simplify to your answers.
In[4]:= **Simplify[ Integrate[Log[x] Exp[-x^2], x] ]**

Out[4]=

This integral involves an incomplete gamma function. Note that the power is carefully set up to allow any complex value of x.
In[5]:= **Integrate[Exp[-x^a], x]**

Out[5]=

Mathematica includes a very wide range of mathematical functions, and by using these functions a great many integrals can be done. But it is still possible to find even fairly simple-looking integrals that just cannot be done in terms of any standard mathematical functions.

Here is a fairly simple-looking integral that cannot be done in terms of any standard mathematical functions.
In[6]:= **Integrate[Sin[x]/Log[x], x]**

Out[6]=

The main point of being able to do an integral in terms of standard mathematical functions is that it lets one use the known properties of these functions to evaluate or manipulate the result one gets.

In the most convenient cases, integrals can be done purely in terms of elementary functions such as exponentials, logarithms and trigonometric functions. In fact, if you give an integrand that involves only such elementary functions, then one of the important capabilities of Integrate is that if the corresponding integral can be expressed in terms of elementary functions, then Integrate will essentially always succeed in finding it.

Integrals of rational functions are straightforward to evaluate, and always come out in terms of rational functions, logarithms and inverse trigonometric functions.
In[7]:= **Integrate[x/((x - 1)(x + 2)), x]**

Out[7]=

The integral here is still of the same form, but now involves an implicit sum over the roots of a polynomial.
In[8]:= **Integrate[1/(1 + 2 x + x^3), x]**

Out[8]=

This finds numerical approximations to all the root objects.
In[9]:= **N[%]**

Out[9]=

Integrals of trigonometric functions usually come out in terms of other trigonometric functions.
In[10]:= **Integrate[Sin[x]^3 Cos[x]^2, x]**

Out[10]=

Here is another form of the result.
In[11]:= **Simplify[%]**

Out[11]=

This is a fairly simple integral involving algebraic functions.
In[12]:= **Integrate[Sqrt[x] Sqrt[1 + x], x]**

Out[12]=

Here is an integral involving nested square roots.
In[13]:= **Integrate[Sqrt[x + Sqrt[x]], x]**

Out[13]=

By nesting elementary functions you sometimes get integrals that can be done in terms of elementary functions.
In[14]:= **Integrate[Cos[Log[x]], x]**

Out[14]=

But more often other kinds of functions are needed.
In[15]:= **Integrate[Log[Cos[x]], x]**

Out[15]=

Integrals like this typically come out in terms of elliptic functions.
In[16]:= **Integrate[Sqrt[Cos[x]], x]**

Out[16]=

But occasionally one can get results in terms of elementary functions alone.
In[17]:= **Integrate[Sqrt[Tan[x]], x]**

Out[17]=

Beyond working with elementary functions, Integrate includes a large number of algorithms for dealing with special functions. Sometimes it uses a direct generalization of the procedure for elementary functions. But more often its strategy is first to try to write the integrand in a form that can be integrated in terms of certain sophisticated special functions, and then having done this to try to find reductions of these sophisticated functions to more familiar functions.

To integrate this Bessel function requires a generalized hypergeometric function.
In[18]:= **Integrate[BesselJ[0, x], x]**

Out[18]=

To integrate an elliptic integral also requires a generalized hypergeometric function.
In[19]:= **Integrate[EllipticK[x], x]**

Out[19]=

Sometimes the integrals can be reduced to more familiar forms.
In[20]:= **Integrate[x BesselJ[0, x], x]**

Out[20]=

A large book of integral tables will list perhaps a few thousand indefinite integrals. Mathematica can do essentially all of these integrals. And because it contains general algorithms rather than just specific cases, Mathematica can actually do a vastly wider range of integrals.

You could expect to find this integral in any large book of integral tables.
In[21]:= **Integrate[Log[1 - x]/x, x]**

Out[21]=

To do this integral, however, requires a more general algorithm, rather than just a direct table look up.
In[22]:= **Integrate[Log[1 + 3 x + x^2]/x, x] // Short**

Out[22]//Short=

Particularly if you introduce new mathematical functions of your own, you may want to teach Mathematica new kinds of integrals. You can do this by making appropriate definitions for Integrate.

In the case of differentiation, the chain rule allows one to reduce all derivatives to a standard form, represented in Mathematica using Derivative. But for integration, no such similar standard form exists, and as a result you often have to make definitions for several different versions of the same integral. Changes of variables and other transformations can rarely be done automatically by Integrate.

This integral cannot be done in terms of any of the standard mathematical functions built into Mathematica.
In[23]:= **Integrate[Sin[Sin[x]], x]**

Out[23]=

Before you add your own rules for integration, you have to remove write protection.
In[24]:= **Unprotect[Integrate]**

Out[24]=

You can set up your own rule to define the integral to be, say, a "Jones" function.
In[25]:= **Integrate[Sin[Sin[a_. + b_. x_]], x_] := Jones[a, x]/b**

Now Mathematica can do integrals that give Jones functions.
In[26]:= **Integrate[Sin[Sin[3x]], x]**

Out[26]=

As it turns out, the integral can in principle be represented as an infinite sum of

hypergeometric functions, or as a suitably generalized Kampé de Fériet hypergeometric function of two variables.