TITLE: What is up with the antiderivative of $\arctan^2(x)$?
QUESTION [7 upvotes]: 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?

REPLY [2 votes]: $\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}