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?

  • 2
    $\begingroup$ 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. $\endgroup$
    – user21349
    Oct 2, 2012 at 4:51
  • 18
    $\begingroup$ @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" $\endgroup$
    – Yemon Choi
    Oct 2, 2012 at 4:53
  • 7
    $\begingroup$ Hey, am I the only person here who wasn't taught how to immediately recognize rigorously which functions have elementary antiderivatives? $\endgroup$
    – Yemon Choi
    Oct 2, 2012 at 4:54
  • 1
    $\begingroup$ Like Maxima, Maple evaluates this in terms of the dilogarithm function, or equivalently in terms of the non-elementary $\int dx/\log(x)$. $\endgroup$ Oct 2, 2012 at 11:31
  • 10
    $\begingroup$ 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. $\endgroup$ May 16, 2013 at 0:59

4 Answers 4


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):

enter image description here

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.)

  • 1
    $\begingroup$ 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? $\endgroup$ Oct 3, 2012 at 1:40
  • $\begingroup$ 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. $\endgroup$ Oct 3, 2012 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 \begin{equation} \frac{x}{e^x+1}=\sum\gamma_i\frac{u_i'}{u_i}+v'. \end{equation} 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.

  • $\begingroup$ 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? $\endgroup$ Oct 2, 2012 at 10:37
  • $\begingroup$ 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. $\endgroup$
    – Victor
    Oct 2, 2012 at 10:46
  • 3
    $\begingroup$ @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. $\endgroup$ Oct 2, 2012 at 10:58

$\newcommand{\+}{^{\dagger}}% \newcommand{\angles}[1]{\left\langle #1 \right\rangle}% \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}% \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}% \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}% \newcommand{\dd}{{\rm d}}% \newcommand{\down}{\downarrow}% \newcommand{\ds}[1]{\displaystyle{#1}}% \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}% \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}% \newcommand{\fermi}{\,{\rm f}}% \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}% \newcommand{\half}{{1 \over 2}}% \newcommand{\ic}{{\rm i}}% \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow}% \newcommand{\isdiv}{\,\left.\right\vert\,}% \newcommand{\ket}[1]{\left\vert #1\right\rangle}% \newcommand{\ol}[1]{\overline{#1}}% \newcommand{\pars}[1]{\left( #1 \right)}% \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}}% \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}% \newcommand{\sech}{\,{\rm sech}}% \newcommand{\sgn}{\,{\rm sgn}}% \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}}% \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$ In general, we can consider the integral $\ds{\int_{0}^{a}x\tan\pars{x}\,\dd x = -a\ln\pars{\cos\pars{a}} + \int_{0}^{a}\ln\pars{\cos\pars{x}}\,\dd x}$ with $\ds{\cos\pars{a} > 0}$: \begin{align} \int_{0}^{a}\ln\pars{\cos\pars{x}}\,\dd x&= -\int_{1}^{\cos\pars{a}}{\ln\pars{x} \over \root{1 - x^{2}}}\,\dd x = -\,\half\int_{1}^{\cos^{1/2}\pars{a}}{x^{-1/2}\ln\pars{x^{1/2}} \over \root{1 - x}}\,\dd x \\[3mm]&= {1 \over 4}\lim_{\mu \to -1/2}\partiald{}{\mu}\int^{1}_{\cos^{1/2}\pars{a}}x^{\mu} \pars{1 - x}^{-1/2}\,\dd x \\[3mm]&= {1 \over 4}\lim_{\mu \to -1/2}\partiald{}{\mu}\bracks{% \int_{0}^{1}x^{\mu}\pars{1 - x}^{-1/2}\,\dd x - \int_{0}^{\cos^{1/2}\pars{a}}x^{\mu}\pars{1 - x}^{-1/2}\,\dd x} \\[3mm]&= {1 \over 4}\lim_{\mu \to -1/2}\partiald{}{\mu}\bracks{% {\rm B}\pars{\mu + 1,\half} - {\rm B}_{\cos^{1/2}\pars{a}}\pars{\mu + 1,\half}} \end{align} where $\ds{{\rm B}\pars{p,q} = {\Gamma\pars{p}\Gamma\pars{q} \over \Gamma\pars{p + q}}}$ and $\ds{{\rm B}_{x}\pars{p,q} = {x^{p} \over q}\ _{\large 2\atop}\!{\rm F}_{1}\pars{p,1 - q;p + 1,x}}$ are the $\it Beta$ and the $\it\mbox{Incomplete Beta}$ functions, respectively. $\ds{_{\large 2\atop}\!{\rm F}_{1}}$ is a $\it hypergeometric$ function.

\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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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