# Definite integral $\int_0^1 \frac{\arctan x}{x\,\sqrt{1-x^2}}\,\text{d}x$

Wanting to calculate the integral $\int_0^1 \frac{\arctan x}{x\,\sqrt{1-x^2}}\,\text{d}x$ it will certainly already known to many of you that an interesting way to attack it is to refer to the method of integration and differentiation with respect to a parameter, getting $\frac{\pi}{2}\,\log\left(1+\sqrt{2}\right)$.

Instead, what it does not at all clear is how software such as Wolfram Mathematica can calculate that result in an exact manner and not only approximate. Can someone enlighten me? Thanks!

• Software such as Mathematica has all kinds of formulas, theorems, calculational tricks, etc. programmed into it, along with ways of recognizing when these things can be applied to the input formula. There are many such methods that give exact results for special cases of some definite integrals. Which methods does Mathematica actually use for this particular problem? Anyone who does not have access to the source code of the program (which is practically everyone here) can only guess. – David K Jan 9 '16 at 16:45
• I second David K's comment. You can see this for instance. Also, I have encountered some computation errors which I guess can be attributed to the wrong implementation of the integral table, such as sign mistakes. – Sangchul Lee Feb 12 '17 at 1:11

Note that

$$\frac{\arctan{x}}{x} = \int_0^1 \frac{du}{1+x^2 u^2}$$

Thus, the integral may be written as

$$\int_0^1 dx \frac1{\sqrt{1-x^2}} \int_0^1 \frac{du}{1+x^2 u^2} = \frac12 \int_0^1 du \, \int_{-1}^1 \frac{dx}{(1+u^2 x^2) \sqrt{1-x^2}}$$

Let's attack the inner integral. We may do this using the residue theorem. Consider the following contour integral:

$$\oint_C \frac{dz}{(1+u^2 z^2) \sqrt{z^2-1}}$$

where $C$ is the following contour: with the circular-arc detours about the branch points at $z=\pm 1$ have radius $\epsilon$ and the outer circle has radius $R$. The contour integral is equal to

$$\int_{-R}^{-1-\epsilon} \frac{dx}{(1+u^2 x^2) \sqrt{x^2-1}} + i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac1{[1+u^2 (-1+\epsilon e^{i \phi})^2] \sqrt{(-1+\epsilon e^{i \phi})^2-1}} \\ + e^{-i \pi/2} \int_{-1+\epsilon}^{1-\epsilon} \frac{dx}{(1+u^2 x^2) \sqrt{1-x^2}} + i \epsilon \int_{\pi}^{-\pi} d\phi \, e^{i \phi} \frac1{[1+u^2 (1+\epsilon e^{i \phi})^2] \sqrt{(1+\epsilon e^{i \phi})^2-1}} \\ + e^{i \pi/2} \int_{1-\epsilon}^{-1+\epsilon} \frac{dx}{(1+u^2 x^2) \sqrt{1-x^2}} + i \epsilon \int_{2 \pi}^{\pi} d\phi \, e^{i \phi} \frac1{[1+u^2 (-1+\epsilon e^{i \phi})^2] \sqrt{(-1+\epsilon e^{i \phi})^2-1}} \\ +\int_{-1-\epsilon}^{-R} \frac{dx}{(1+u^2 x^2) \sqrt{x^2-1}} +i R \int_{-\pi}^{\pi} d\theta \, e^{i \theta} \frac1{(1+u^2 R^2 e^{i 2 \phi})\sqrt{R^2 e^{i 2 \phi}-1}}$$

The first and seventh integrals cancel.

We now evaluate the contour integral in the limits as $\epsilon \to 0$ and $R \to \infty$. As $\epsilon \to 0$, the second, fourth, and sixth integrals vanish. As $R \to \infty$, the eighth integral vanishes.

By the residue theorem, the contour integral is equal to $i 2 \pi$ times the sum of the residues of the integrand at the poles $z_{\pm} = \pm i/u$. Thus,

$$-i 2 \int_{-1}^1 \frac{dx}{(1+u^2 x^2)\sqrt{1-x^2}} = i 2 \pi \frac1{u^2} \left [\frac1{(i 2/u) e^{i \pi/2} \sqrt{1/u^2+1}} + \frac1{(-i 2/u) e^{-i \pi/2} \sqrt{1/u^2+1}} \right ]$$

Note that the poles lie on different branches so that the residue add and do not cancel. So...

$$\int_{-1}^1 \frac{dx}{(1+u^2 x^2)\sqrt{1-x^2}} = \frac{\pi}{\sqrt{1+u^2}}$$

Thus,

$$\int_0^1 dx \frac{\arctan{x}}{x \sqrt{1-x^2}} = \frac12 \pi \int_0^1 \frac{du}{\sqrt{1+u^2}} = \frac{\pi}{2} \sinh^{-1}{(1)} = \frac{\pi}{2} \log{\left (1+\sqrt{2} \right )}$$

• Ron, as usual, beautifully done! I posted a slight variation in which I first substituted $x=\sin u$ in the inner integral. It does seem to reduce the complexity of the contour integration a bit - so the sub seems worthwhile. I also added a way forward that forwent complex analysis and relied instead on the "good ole" Weirestrass Substitution. Of course, the results match. It still fascinates me that quite different approaches yield the same result! But perhaps I am easily impressed. Happy Holidays! - Mark – Mark Viola Jan 3 '16 at 7:43
• @RonGordon Can you explain to me why there's a factor of $e^{\pm\pi i/2}$ in front of your arc integrals? Where do they come from? And what are the branch cuts in this case? I'm having difficulty seeing where you're getting the limits for your arc integrals from. – Frank W. Oct 11 '18 at 15:31
• @FrankW.: There was a sign change inside the square root: those factors are the result. – Ron Gordon Oct 12 '18 at 0:34

I thought it might be instructive to present two approaches that begin with the Feyman "trick" for differentiating under the integral. We write

$$I(a)=\int_0^1\frac{\arctan (ax)}{x\sqrt{1-x^2}}\,dx$$

Then, we differentiate with $I(a)$ to find

$$I'(a)=\int_0^1\frac{1}{(1+x^2a^2)\sqrt{1-x^2}}\,dx$$

can be evaluated by first substituting $x=\sin u$ so that

\begin{align} I'(a)&=\int_0^{\pi/2}\frac{1}{1+a^2\sin^2 u}\,du\\\\ &=\frac12 \int_{-\pi/2}^{\pi/2}\frac{1}{1+a^2\sin^2 u}\,du \end{align}

Next, we use the trigonometric identity $\sin^2u=\frac{1-\cos(2u)}{2}$ so that

\begin{align} I'(a)&=\int_0^{\pi/2}\frac{1}{1+\frac12a^2-\frac12a^2\cos (2u)}\,du \tag 1\\\\ &=\frac14 \int_{-\pi}^{\pi}\frac{1}{1+\frac12a^2-\frac12a^2\cos (u)}\,du \tag 2 \end{align}

We pursue evaluation of $(1)$ using the Weirestrass Substitution and evaluation of $(2)$ using contour integration.

First, we enforce the substitution $2u=\tan(x/2)$ in $(1)$. Then, we obtain

\begin{align} I'(a)&=2\int_{0}^{\infty}\frac{1}{1+4(1+a^2)x^2}\,dx\\\\ &=\frac{2}{2\sqrt{1+a^2}}\left.\arctan\left(2\sqrt{1+a^2}\,x\right)\right|_{0}^{\infty}\\\\ &=\frac{\pi}{2\sqrt{1+a^2}} \end{align}

Alternatively, we let $u=e^{iz}$ in $(2)$ and write

\begin{align} I'(a)&=\frac{i}{2a^2}\oint_{|z|=1}\frac{1}{z^2-\left(1+\frac{2}{a^2}\right)z+1}\,dz\\\\ &=\frac{i}{a^2}(2\pi i) \,\,\text{Res}\left(\frac{1}{z^2-2\left(1+\frac{2}{a^2}\right)z+1},z=\left(1+\frac{2}{a^2}\right)-\frac{2\sqrt{1+a^2}}{a^2}\right)\\\\ &=\pi/2\sqrt{1+a^2} \end{align}

Finally, following the approach used by @Manu we find from $I'(a)$, $I(1)$ is

$$I(1)=\pi \log(1+\sqrt{2})$$

And we are done!

• nice answer. Again i have no idea wh this is not upvoted more often. But anyway (+1) from me and a happy new year! – tired Jan 5 '16 at 17:34
• @tired Thank you! Happy New Year!! - Mark – Mark Viola Jan 5 '16 at 18:28

$\newcommand{\angles}{\left\langle\,{#1}\,\right\rangle} \newcommand{\braces}{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}{\displaystyle{#1}} \newcommand{\expo}{\,\mathrm{e}^{#1}\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{\mathrm{i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\Li}{\,\mathrm{Li}_{#1}} \newcommand{\mc}{\mathcal{#1}} \newcommand{\mrm}{\mathrm{#1}} \newcommand{\ol}{\overline{#1}} \newcommand{\pars}{\left(\,{#1}\,\right)} \newcommand{\partiald}[]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\ul}{\underline{#1}} \newcommand{\verts}{\left\vert\,{#1}\,\right\vert}$ \begin{align} &\color{#f00}{\int_{0}^{1}{\arctan\pars{x} \over x\root{1 - x^{2}}}\,\dd x} = \int_{0}^{1}{1 \over \root{1 - x^{2}}}\ \overbrace{\int_{0}^{1}{\dd t \over 1 + x^{2}t^{2}}} ^{\ds{\arctan\pars{x} \over x}}\ \,\dd x \\[5mm] = &\ \int_{0}^{1}\int_{0}^{1}{\dd x \over \root{1 - x^{2}}\pars{1 + t^{2}x^{2}}} \,\dd t \,\,\,\stackrel{x\ \mapsto\ 1/x}{=}\,\,\, \int_{0}^{1} \int_{1}^{\infty}{x\,\dd x \over \root{x^{2} - 1}\pars{x^{2} + t^{2}}}\,\dd t \label{1}\tag{1} \end{align}

Note that the last substitution $\ds{\pars{~x \mapsto 1/x~}}$ leads to a $\ds{\ul{trivial\ integration}}$.

With the substitution $\ds{x^{2} \mapsto x}$ in the last integration $\ds{~\pars{\mbox{see}\ \eqref{1}}~}$, \begin{align} &\color{#f00}{\int_{0}^{1}{\arctan\pars{x} \over x\root{1 - x^{2}}}\,\dd x} = \half\int_{0}^{1} \int_{1}^{\infty}{\dd x \over \root{x - 1}\pars{x + t^{2}}}\,\dd t \\[5mm] & \stackrel{x\ \equiv\ 1 + y^{2}}{=}\,\,\,\ \int_{0}^{1}\int_{0}^{\infty}{\dd y \over y^{2} + 1 + t^{2}}\,\dd t = \int_{0}^{1}{1 \over \root{1 + t^{2}}} \int_{0}^{\infty}{\dd y \over y^{2} + 1}\,\dd t \\[5mm] = &\ {\pi \over 2}\int_{0}^{1}{\dd t \over \root{1 + t^{2}}} \stackrel{t\ =\ \sinh\pars{\theta}}{=}\,\,\, {\pi \over 2}\int_{0}^{\mrm{arcsinh}\pars{1}}\,\dd\theta = \color{#f00}{{\pi \over 2}\,\mrm{arcsinh}\pars{1}} = \color{#f00}{{\pi \over 2}\,\ln\pars{1 + \root{2}}} \end{align}

• I have no idea as to the reason this was down voted. (+1) to counter. – Mark Viola Jul 17 '18 at 23:52
• @MarkViola Me too. I have a private 'probabilistic' stalker that believes he's the MSE owner. – Felix Marin Aug 1 '18 at 19:15

We first might notice that $$\frac{\arctan(x)}{x}=\int_{0}^{1}\frac{dt}{1+(xt)^{2}}$$

Now using Tonelli's Theorem to switch around the order we get $$\int_{0}^{1}\frac{\arctan(x)}{x\sqrt{1-x^{2}}}\,dx= \int_{0}^{1}\int_{0}^{1}\frac{1}{1+(tx)^{2}}\frac{1}{\sqrt{1-x^{2}}}\,dt \,dx= \int_{0}^{1}\left(\int_{0}^{1}\frac{1}{1+(tx)^{2}}\frac{1}{\sqrt{1-x^{2}}}\,dx\right)\, dt$$

Focusing on the inner integral, denoted $\mathcal{I}(t)$

Making the change of variable $\sin(x)=u$, we the obtain $$\mathcal{I}(t)=\int_{0}^{\frac{\pi}{2}}\frac{\,du}{1+t^{2}\sin^{2}(u)}=\int_{0}^{\frac{\pi}{2}}\frac{\,du}{\cos^{2}(u)+(t^{2}+1)\sin^{2}(u)}=\int_{0}^{\frac{\pi}{2}}\frac{\,d\tan(u)}{1+(t^{2}+1)\tan^{2}(u)}$$

Now doing the substitution $\tan(u)= s$ gives $$\mathcal{I}(t)=\int_{0}^{\infty}\frac{ds}{1+(1+t^{2})s^{2}}= \frac{\pi}{2}\frac{1}{\sqrt{1+t^{2}}}$$

Thus $$\int_{0}^{1}\frac{\arctan(x)}{x\sqrt{1-x^{2}}}\,dx=\int_{0}^{1}\frac{\pi}{2}\frac{1}{\sqrt{1+t^{2}}} \,dt=\frac{\pi}{2}\log(1+\sqrt{2})$$

@Ron Gord: so that's the way it "thinks" Wolfram Mathematica?

Because otherwise, as I saw in a forum Italian, simply consider

$$I(y) := \int_0^1 \frac{\arctan(x\,y)}{x\,\sqrt{1-x^2}}\,\text{d}x \; \; \; \; (y \ge 0)$$

calculate using classical techniques

$$I'(y) = \int_0^1\frac{\text{d}x}{\left(1+x^2\,y^2\right)\sqrt{1-x^2}} = \frac{\pi}{2}\,\frac{1}{\sqrt{1+y^2}}$$

then go back indefinitely by integrating with respect to $y$

$$I(y) = \frac{\pi}{2}\,\log\left(y+\sqrt{1+y^2}\right) + c$$

of having to be $I(0)=0$ follow $c=0$. In conclusion, you get

$$I(1) = \int_0^1 \frac{\arctan x}{x\,\sqrt{1-x^2}}\,\text{d}x = \frac{\pi}{2}\,\log\left(1+\sqrt{2}\right)$$

and for this reason I was wondering how software could be so "smart".

Thanks again!

• "Calculate using classical techniques." What classical techniques? Is complex integration techniques not classical enough? In my mind, they provide the most straightforward way to evaluate the integral in closed form. Maybe you know of another way (e.g., series expansion, orthogonal functions, etc.). But if you're asking how Wolfram does it, good luck - you're asking about the family jewels. – Ron Gordon Jan 3 '16 at 0:26
• @RonGordon Perhaps Manu meant "real analysis" and not "classical analysis," which is nebulous as you implied. Heck, I'm not sure what "classic rock" means anymore. Of course the evaluation of the inner integral can proceed using the Weierstrass substitution or using the contour integration approach. Happy New Year my friend! - Mark – Mark Viola Jan 3 '16 at 5:50

First of all mathematica is a closed source software, so I do not know how exactly it does it, but I will address how computers calculate integrals.

The problem of integrating belongs to a subset of search problems and decision trees in artificial intelligence. It consists of a couple of parts:

• knowledge base. A big table of integrals, the bigger the better
• a table of transformations. They are divided into safe (taking a constant out of integral, integral of sum = sum of integrals, ...) and heuristics (various substitutions methods). These are basically set of your methods that you learned in calculus class.
• than the program starts to search. You search by generating a search tree and try to find your solution.

How is a search tree generated? The starting node is your integral. Then to this integral you apply all your transformations and create the children of this node. Then do the same for all children. This is a crude explanation, in reality search uses a combination of DFS and heuristics.

Take a look at the nice video explaining this concept.

$\displaystyle f(x)=\dfrac{1}{(1+x^2y^2)\sqrt{1-x^2}}$

has antiderivative:

$F(x)=\dfrac{1}{\sqrt{1+y^2}}\arctan\left(\dfrac{x\sqrt{1+y^2}}{\sqrt{1-x^2}}\right)$

There is a closed form antiderivative (it can be proved by differentiation): $$\int\frac{\arctan x}{x\,\sqrt{1-x^2}}\,dx=\frac i2\left[\operatorname{Li}_2\left(\frac{-1-\sqrt2}{1+\sqrt{1-x^2}}\,ix\right)-\operatorname{Li}_2\left(\frac{1+\sqrt2}{1+\sqrt{1-x^2}}\,ix\right)\\ -\operatorname{Li}_2\left(\frac{1-\sqrt2}{1+\sqrt{1-x^2}}\,ix\right)+\operatorname{Li}_2\left(\frac{-1+\sqrt2}{1+\sqrt{1-x^2}}\,ix\right)\right]\color{gray}{+C}$$

• There is a down-voter/stalker around $\textit{CORRECT}$ answers. – Felix Marin Feb 18 '17 at 1:13