<s>[INST] Why does $\int_{-\infty}^{+\infty }\arctan\left(\frac{1}{1+x^2}\right)dx$ have a real value when the indefinite integral uses $i$? 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? 

 [/INST] WolframAlpha, though handy, is not yet advanced to perform certain integrals satisfactorily. For less familiar integrands, it tends to fall back to complex variables, leading often to uninteresting, perhaps only symbolically useful, results.
The integral in question can be integrated in real variables explicitly
\begin{align}
\int \tan^{-1}\frac{1}{1+x^2}\ dx &
= x\tan^{-1}\frac{1}{1+x^2}\\
&\>\>\>+\sqrt{2(\sqrt{2}-1)}\tan^{-1}\frac{x^2-\sqrt{2}}{x\sqrt{2(\sqrt{2}+1)}} \\
& \>\>\>- \sqrt{2(\sqrt{2}+1)}\tanh^{-1}\frac{x^2+\sqrt{2}}{x\sqrt{2(\sqrt{2}-1)}}+C
\end{align}
which eludes WA due to limitations in its current algorithm.
</s>