WolframAlpha gives a real closed form for this definite integral: $$\int_{-\infty}^{+\infty } \arctan\left(\dfrac{1}{1+x^2}\right)dx = \sqrt{2\left(\sqrt{2}-1\right)}\;\pi$$

Yet, the formula it gives for the indefinite integral uses $i$.

$$\int \tan^{-1}\left(\frac{1}{x^2 + 1}\right) dx = x \tan^{-1}\left(\frac{1}{x^2 + 1}\right) + 2 \left( \frac{\tan^{-1}\left(\frac{x}{\sqrt{1 - i}}\right)}{(1 - i)^{3/2}} + \frac{\tan^{-1}\left(\frac{x}{\sqrt{1 + i}}\right)}{(1 + i)^{3/2}} \right) + C$$

Why isn't the definite integral non-real?

  • 2
    $\begingroup$ How is $$\sqrt{2 (\sqrt{2}-1)} π$$ a complex number? $\endgroup$ – Peter Foreman Jul 27 '19 at 18:35
  • $\begingroup$ @PeterForeman , I meant why the result dosn't includes the complex number x+iy with non null imaginary part $\endgroup$ – zeraoulia rafik Jul 27 '19 at 18:37
  • $\begingroup$ But the above result is clearly a real number. I don't understand your confusion $\endgroup$ – Peter Foreman Jul 27 '19 at 18:38
  • 4
    $\begingroup$ Just because an expression has $i$ in it doesn't mean it lies outside $\mathbb{R}$. E.g., $i^2$. $\endgroup$ – Duncan Ramage Jul 27 '19 at 18:38
  • 2
    $\begingroup$ Note that replacing $i$ with $-i$ in $(1+i)^{-3/2}\arctan\frac{x}{\sqrt{1+i}}$ replaces the original complex number with its complex conjugate. The result is real viz. $z+z^\ast\in\Bbb R$. $\endgroup$ – J.G. Jul 27 '19 at 18:39

First of all, it is real because it converges and because $\arctan\left(\frac1{1+x^2}\right)$ is a real number for every $x\in \mathbb R$.

On the other hand, that some number can be represented with an expression involving $i$ doesn't mean it is not a real number. For instance, $$\frac1i+i=0\in \mathbb R.$$

| cite | improve this answer | |

The WolframAlpha integration algorithm, though very handy, is not yet advanced enough to perform most integrals satisfactorily. For indefinite integrals, it tends to resort to complex variables and special functions when encountering less familiar integrands. The results are often quite generalized and uninteresting, to the point that it is only symbolically useful.

The integral in question can actually be integrated in real variables explicitly, which yields,

$$ I = \int \tan^{-1}\left(\frac{1}{1+x^2}\right)dx = x\tan^{-1}\left(\frac{1}{1+x^2}\right) +I_1 - I_2 + C$$

where, $$I_1 = \sqrt{2(\sqrt{2}-1)}\tan^{-1}\left(\frac{x^2-\sqrt{2}}{x\sqrt{2(\sqrt{2}+1)}}\right)$$ $$I_2=\sqrt{2(\sqrt{2}+1)}\tanh^{-1}\left(\frac{x^2+\sqrt{2}}{x\sqrt{2(\sqrt{2}-1)}}\right)$$

WolframAlpha often cannot perform such integrations adequately, due to limitations in its current algorithm. The integral should not be all that challenging for WolframAlpha. Users should remain wary so long as real integrals such as this kind still elude WolframAlpha.

| cite | improve this answer | |
  • 1
    $\begingroup$ How did you figure out $I_1$ and $I_2$ explicitly? $\endgroup$ – Yuriy S Aug 5 '19 at 22:44
  • $\begingroup$ Though I agree with your point. Mathematica can't deal with my last rational integral at all, it gives a general answer in terms of polynomial roots $\endgroup$ – Yuriy S Aug 5 '19 at 22:46

A pretty integral, and I'm not sure I would be able to guess the primitive right away.

Still, substitution is always a good way to simplify things:

$$I=\int_a^b \arctan\left(\dfrac{1}{1+x^2}\right)dx, \\ 0 \leq a<b$$

$$x= \tan t$$

$$I=\int_{\arctan a}^{\arctan b} \arctan\left(\cos^2 t\right)\frac{dt}{\cos^2 t}$$

$$u = \cos t$$

$$I=\int_{\cos \arctan b}^{\cos \arctan a} \arctan\left(u^2 \right)\frac{du}{u^2 \sqrt{1-u^2}}$$

$$I=\int_{1/\sqrt{1+b^2}}^{1/\sqrt{1+a^2}} \arctan\left(u^2 \right)\frac{du}{u^2 \sqrt{1-u^2}}$$


$$I=\frac{1}{2} \int_{1/(1+b^2)}^{1/(1+a^2)} \arctan v \frac{dv}{v^{3/2} \sqrt{1-v}}$$

Now we can use integration by parts:

$$\int \frac{1}{2} \frac{dv}{v^{3/2} \sqrt{1-v}}=-\frac{\sqrt{1-v}}{\sqrt{v}}$$

$$(\arctan v)'= \frac{1}{1+v^2}$$

$$I=-\sqrt{\frac{1}{v}-1} \arctan v \bigg|_{1/(1+b^2)}^{1/(1+a^2)}+ \int_{1/(1+b^2)}^{1/(1+a^2)} \frac{\sqrt{1-v} ~dv}{\sqrt{v} (1+v^2)}$$

$$I=b \arctan \frac{1}{1+b^2}-a \arctan \frac{1}{1+a^2} + 2 \int_{1/\sqrt{1+b^2}}^{1/\sqrt{1+a^2}} \frac{\sqrt{1-u^2} ~du}{1+u^4}$$

For the second part we get back to trigonometric functions again:

$$\int_{1/\sqrt{1+b^2}}^{1/\sqrt{1+a^2}} \frac{\sqrt{1-u^2} ~du}{1+u^4}=\int_{\arcsin(1/\sqrt{1+b^2})}^{\arcsin(1/\sqrt{1+a^2})} \frac{\cos^2 w}{1+\sin^4 w} dw$$

Now we use the tangent half angle substitution:

$$p = \tan \frac{w}{2} \\ \cos w= \frac{1-p^2}{1+p^2} \\ \sin w= \frac{2p}{1+p^2} \\ dw = \frac{2dp}{1+p^2}$$


$$\alpha= \tan \left(\frac{1}{2} \arcsin \frac{1}{\sqrt{1+a^2}} \right) \\ \beta = \tan \left(\frac{1}{2} \arcsin \frac{1}{\sqrt{1+b^2}} \right)$$

$$\int_{1/\sqrt{1+b^2}}^{1/\sqrt{1+a^2}} \frac{\sqrt{1-u^2} ~du}{1+u^4}=\int_{\beta}^{\alpha} \frac{2 (1-p^2)^2 (1+p^2) }{(1+p^2)^4+16 p^4} dp$$

Now we have a rational function under the integral, which can be integrated using partial fractions.

I will stop here, because the point was, we don't really need CAS to integrate this, and no complex numbers were harmed in the process.

Well, it might be much easier to do the partial fractions in the last integral using complex numbers. But I'm sure we can avoid them.

Note that for the case in the OP, we have:

$$a=0, b=\infty$$

Which means we need to find:

$$\int_0^1 \frac{ (1-p^2)^2 (1+p^2) }{(1+p^2)^4+16 p^4} dp= \frac{1}{4} \sqrt{\frac{\sqrt{2}-1}{2}} ~ \pi$$

I confirmed this value numerically, but Mathematica can't find it from the integral.

Though it does find:

$$\int_0^\infty \frac{ (1-p^2)^2 (1+p^2) }{(1+p^2)^4+16 p^4} dp= \frac{1}{2} \sqrt{\frac{\sqrt{2}-1}{2}} ~ \pi$$

To be honest, complex residues seems like the best method in this case to me.

| cite | improve this answer | |

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.