What is up with the antiderivative of $\arctan^2(x)$? Integrating $\arctan^2(x)$ has been a mystery to me since I first learned to compute indefinite integrals. When I plug it into integral calculator or WolframAlpha, I get a primitive written in terms of complex numbers and polylogarythms; but $\arctan^2(x)$ is continuous and defined $\forall\space x\in\mathbb{R}$, the area under the curve $(x,\arctan^2(x))$ is well-defined and obvioulsy real. In fact, I can integrate that function numerically and get the area without using Barrow's Rule at all.
I thought maybe the complex part of that expression is constant, therefore applying Barrow's Rule always yields a real number anyway, but then I could subtract a constant equal to its imaginary part times $i$ and get a real and still valid antiderivative. Anyway, I have no idea of how to compute that antiderivative in the first place, so I can't check for myself.
Can a real, continuous function have a complex primitive but not a real primitive? And, can anyone give me a hint to help me compute its antiderivative by myself?
 A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

You can see an integration of $\ds{\arctan^{2}\pars{x}}$ over $\ds{\pars{0,1}}$ in this link which I guess it's simpler than the present one.


\begin{align}
\int\arctan^{2}\pars{x}\,\dd x & =
x\arctan^{2}\pars{x} - \int x\bracks{2\arctan\pars{x}\,{1 \over x^{2} + 1}}
\dd x
\\[5mm] & =
x\arctan^{2}\pars{x} - \ln\pars{x^{2} + 1}\arctan\pars{x} +
\int{\ln\pars{x^{2} + 1} \over x^{2} + 1}\,\dd x
\end{align}

\begin{align}
\int{\ln\pars{x^{2} + 1} \over x^{2} + 1}\,\dd x & =
2\,\Re\int\ln\pars{x + \ic}\pars{{1 \over x - \ic} -
{1 \over x + \ic}}{1 \over 2\ic}\,\dd x
\\[5mm] & =
\Im\
\underbrace{\int{\ln\pars{x + \ic} \over x - \ic}\,\dd x}
_{\ds{\mbox{Set}\,\,\, t = x + \ic}}\ -\ \Im\
\underbrace{\int{\ln\pars{x + \ic} \over x + \ic}\,\dd x}
_{\ds{=\ {1 \over 2}\,\ln^{2}\pars{x + \ic}}}
\\ & =
-\,\Im\int{\ln\pars{t} \over 2\ic - t}\,\dd t -
{1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\\[5mm] & =
-\,\Im\
\underbrace{\int{\ln\pars{2\ic\braces{t/\bracks{2\ic}}} \over
1 - t/\pars{2\ic}}\,{\dd t \over 2\ic}}
_{\ds{\mbox{Set}\,\,\, z = {t \over 2\ic}}}\ -\
{1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\\[5mm] & =
-\,\Im\int{\ln\pars{2\ic z} \over 1 - z}\,\dd z -
{1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\\[5mm] & =
\Im\braces{\ln\pars{1 - z}\ln\pars{2\ic z} - \int{\ln\pars{1 - z} \over z}} -
{1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\\[5mm] & =
\Im\bracks{\ln\pars{1 - z}\ln\pars{2\ic z} + \,\mrm{Li}_{2}\pars{z}} -
{1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\\[5mm] & =
\Im\bracks{\ln\pars{1 - {t \over 2\ic}}\ln\pars{t} +
\,\mrm{Li}_{2}\pars{t \over 2\ic}} - {1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\\[5mm] & =
\Im\bracks{\ln\pars{{\ic \over 2}\bracks{x - \ic}}\ln\pars{x + \ic} +
\,\mrm{Li}_{2}\pars{1 - x\ic \over 2}} - {1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\\[5mm] & =
\Im\bracks{\bracks{{\pi \over 2}\,\ic - \ln\pars{2}}\ln\pars{x + \ic} +
\,\mrm{Li}_{2}\pars{1 - x\ic \over 2}} - {1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\\[5mm] & =
{\pi \over 2}\,\Re\ln\pars{x + \ic} - \ln\pars{2}\Im\ln\pars{x + \ic} +
\Im\mrm{Li}_{2}\pars{1 - x\ic \over 2} - {1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\\[5mm] & =
{\pi \over 4}\ln\pars{x^{2} + 1} + \ln\pars{2}\arctan\pars{x} +
\Im\mrm{Li}_{2}\pars{1 - x\ic \over 2} - {1 \over 2}\,\Im\ln^{2}\pars{x + \ic}
\end{align}
A: You are totally correct.
Using the result, compute it for $x=0$ and you will get $\frac{i \pi ^2}{12}$; do it for any arbitrary value of $x$ and you will get the decimal representation of this number.
What you could also do is to perform a Taylor expansion of the result around $0$ and get
$$\frac{i \pi ^2}{12}+\frac{x^3}{3}-\frac{2 x^5}{15}+\frac{23 x^7}{315}-\frac{44
   x^9}{945}+O\left(x^{11}\right)$$
Compute its derivative to get 
$$x^2-\frac{2 x^4}{3}+\frac{23 x^6}{45}-\frac{44 x^8}{105}+O\left(x^{10}\right)$$ while 
$$\tan^{-1}(x)=x-\frac{x^3}{3}+\frac{x^5}{5}-\frac{x^7}{7}+\frac{x^9}{9}+O\left(x^{10}\right)$$ from which
$$\left[\tan ^{-1}(x)\right]^2=x^2-\frac{2 x^4}{3}+\frac{23 x^6}{45}-\frac{44 x^8}{105}+O\left(x^{10}\right)$$
A: WA assumes complex functions by default and provides answers more general than you expect.
But when plugging a real variable, the given antiderivative should simplify to a real function (plus a possibly complex constant).
