# Is $x \, \tan(x)$ integrable in elementary functions?

I'm teaching Calculus and my students asked me to calculate the integral of $x \, \tan(x)$.

I spent quite a lot of effort to do this, but I'm now even not sure if the integral could be presented in elementary functions.

Does anybody know how to calculate it, or otherwise prove it is not integrable in elementary functions?

-
Maxima gives $-{{x\,\log \left(\sin ^2\left(2\,x\right)+\cos ^2\left(2\,x\right)+ 2\,\cos \left(2\,x\right)+1\right)+2\,i\,x\,{\rm atan2}\left(\sin \left(2\,x\right) , \cos \left(2\,x\right)+1\right)-i\,{\it li}_{2}( -e^{2\,i\,x})-i\,x^2}\over{2}}$, where ${\it li}_{2}$ is something called Spence's function. Unless it's possible to simplify Spence's function for this argument, I think the answer to your question is no. This is more appropriate for math.stackexchange.com than for mathoverflow, which is for research-level questions. You should learn to mark up your posts in LaTeX. –  Ben Crowell Oct 2 '12 at 4:51
@Benjamin: I am less sure this is not research level, unless Picard-Vesiot is being taught at lower-levels than I'd imagined... I for one would be interested to learn of an argument that this function is not integrable in terms of elementary functions, rather than rely on Deep Thought to tell me "42" –  Yemon Choi Oct 2 '12 at 4:53
Hey, am I the only person here who wasn't taught how to immediately recognize rigorously which functions have elementary antiderivatives? –  Yemon Choi Oct 2 '12 at 4:54
Like Maxima, Maple evaluates this in terms of the dilogarithm function, or equivalently in terms of the non-elementary $\int dx/\log(x)$. –  Gerald Edgar Oct 2 '12 at 11:31
Victor: I strongly believe that you should "unaccept" my answer and accept Peter Mueller's instead, as he has answered your question in full by appealing to the theorem of Liouville to which I referred. –  Benjamin Dickman May 16 '13 at 0:59

Edit (6/14/14): I maintain that Peter Mueller's answer should be accepted, since he has essentially carried out the proof using Liouville's Theorem (mentioned below) to show that the integrand under question cannot be expressed in elementary functions. However, in addition to my previous unsuccessful attack, I thought I would also point to a full argument in the following source:

Bronstein, M. (1998). Symbolic integration tutorial. INRIA Sophia Antipolis ISSAC. Link.

as well as the author's self-cited:

(4) M. Bronstein. Symbolic Integration I – Transcendental Functions. Springer, Heidelberg, 1997. 2nd Ed., 2004.

In particular, see Section 3.3. Here is an excerpt (see the paper for the definition of special):

Some thoughts on this antiderivative:

Attacking $\log(\cos x)$ using integration by parts, we find:

$$\int \log(\cos x) = x\log(\cos x) + \int x \tan x dx$$

So the question has now become: how do we find an antiderivative for log(cos x)?

Next, we observe that

$$\cos x = \frac{1}{2}(e^{ix} + e^{-ix}) = \frac{1}{2}e^{ix}(1 + e^{-2ix})$$

Taking the log of this, we end up with:

$$-\log 2 + ix + \log(1 + e^{-2ix})$$

Recall that we can write

$$\log(1 + y) = \sum_{k = 1}^{\infty} \frac{(-1)^{k+1}y^{k}}{k}$$

We can now apply this with $y = e^{-2ix}$ as above and integrate term by term.

Putting all these pieces together will give you a (nasty) way to integrate $x\tan x$.

As far as showing it's not integrable in elementary functions, I suspect your best bet would be an appeal to a theorem of Liouville. See, for example, this link.

All that said, perhaps you could ask your students some form of the following: show

$$\int x\tan^{2}x dx = x\tan x - \frac{x^2}{2} + \log(\cos x) + C$$

(You can find this latter, more tractable problem and its solution written out in nice detail here.)

-
Thanks Benjamin, this is very helpful! –  Victor Oct 2 '12 at 6:50
If you're going to resort to term-by-term integration of an infinite series, why not just take the power series for $x\tan x$ and integrate that? –  Gerry Myerson Oct 3 '12 at 1:40
That's a good question. If you just check wolframalpha.com/input/?i=integral+xtanx you'll get an answer involving $Li_{2}(-e^{2ix})$. I think re-writing it as I did above is helpful for a few reasons. One, it lets you see rather quickly how that $Li_{2}$ pops up; it's somewhat surprising (to me) that $\log$ should rear its head at all in an attempt at integrating $x \tan x$. Two, I think it might help in evaluating specific examples, e.g. $\int_{0}^{\pi/4} x \tan x dx$. Three, I find it pedagogically helpful to see what goes wrong in attempting to find such an antiderivative. –  Benjamin Dickman Oct 3 '12 at 2:34

Finding an anti-derivative of $x\tan x$ amounts to finding an anti-derivative of $f=\frac{x}{e^x+1}$. Consider the field $K=\mathbb C(x,e^x)$. Note that $K$ is closed under taking derivatives. If $f$ is elementary integrable, then Liouville's Theorem gives elements $u_i\in K$, $\gamma_i\in\mathbb C$, $v\in K$ with $$\frac{x}{e^x+1}=\sum\gamma_i\frac{u_i'}{u_i}+v'.$$ Consider the $u_i$ and $v$ as rational functions in $e^x$ with coeffcients in $\mathbb C(x)$. By the property of the logarithmic derivative we may assume that the $u_i$ are actually distinct irreducible monic polynomials with respect to $e^x$, or elements from $\mathbb C(x)$.

Looking at poles (with respect to the `variable' $e^x$) shows that at most one of the $u_i$ is $e^x+1$, and the other $u_i$'s are in $\mathbb C(x)$. Similarly, we see that $v\in\mathbb C(x)$. So there indeed must be one index $i$ with $u_i=e^x+1$. However, $\frac{x}{e^x+1}-\gamma_i\frac{u_i'}{u_i}=\frac{x}{e^x+1}-\gamma_i\frac{e^x}{e^x+1}$ isn't in $\mathbb C(x)$, a contradiction.

Remark: The argument given here is somewhat sketchy, some routine details need to be filled in, like that $u_i'$ and $u_i$, as polynomials in $e^x$, are relatively prime. A beautiful paper about Liouville's Theorem is Rosenlicht's article Integration in finite terms. My argument somewhat follows Rosenlicht's example of finding an anti-derivative of $f(x)e^{g(x)}$, where $f$ and $g$ are rational functions.

-
Thinking about how to simplify this kind of argument for the general masses... Is it possible to convert this kind of calculation into the computation of some "invariant" associated to $x\tan x$ that vanishes iff it has an elementary antiderivative? –  Igor Khavkine Oct 2 '12 at 10:37
Well, this argument is beautiful -- I never came across such things before, that here complex analysis would be of help. I'm still to go through all things to understand it well, but it's very nice. –  Victor Oct 2 '12 at 10:46
@Victor, if you want to follow up on these ideas, you could start with the Wikipedia articles en.wikipedia.org/wiki/… and en.wikipedia.org/wiki/Risch_algorithm. –  Igor Khavkine Oct 2 '12 at 10:58


\begin{align} &\int_{0}^{a}\ln\pars{\cos\pars{x}}\,\dd x \\[3mm]&=-\,\half\,\pi\ln\pars{2} - {1 \over 4}\lim_{\mu \to -1/2}\partiald{}{\mu}\bracks{% 2{\cos^{\pars{\mu + 1}/2}\pars{a}} \ _{\large 2\atop}\!{\rm F}_{1}\pars{\mu + 1,\half;\mu + 2,\cos^{1/2}\pars{a}}} \end{align}
-

$\int x \tan x \,dx=\frac{1}{2} i \text{Li}_2\left(-e^{2 i x}\right)+\frac{i x^2}{2}-x \log\left(1+e^{2 i x}\right)+C$

Where $\text{Li}_2$ is the dilogarithm function

-