just for fun integrate $\int \frac{1}{x^2+1}dx$ using Partial Fraction Decomposition
Solution 1:
The form you got (up to an absolute value) is indeed correct. It may look confusing (what are imaginary numbers doing here?) but it is correct. To see this geometrically, construct a right triangle in the complex plane with base (real) $x$ and height of $i$.
Solution 2:
Hint: let $$x=\tan u$$ so $$\arctan(\tan u)=u:0<u<\pi/2$$
then put $$\tan u=\frac{e^{ui}+e^{-ui}}{i(e^{ui}-e^{-ui})}$$
so you get $$u=\frac{1}{2i}\ln(\frac{(\frac{e^{ui}+e^{-ui}}{i(e^{ui}-e^{-ui})})-i}{(\frac{e^{ui}+e^{-ui}}{i(e^{ui}-e^{-ui})})+i})+c$$
Solution 3:
${\large x > 0}$: $$ {\rm F}\left(x\right) = \int_{0}^{x}{{\rm d}z \over z^{2} + 1} = {1 \over 4{\rm i}}\int_{-x}^{x}{{\rm d}z \over z - {\rm i}} - {1 \over 4{\rm i}}\int_{-x}^{x}{{\rm d}z \over z + {\rm i}} = {1 \over 4{\rm i}}\int_{-x -{\rm i}}^{x - {\rm i}}{{\rm d}z \over z} - {1 \over 4{\rm i}}\int_{-x + {\rm i}}^{x + {\rm i}}{{\rm d}z \over z} $$
Define $z^{-1} = \left\vert z\right\vert^{-1}{\rm e}^{-{\rm i}\phi\left(z\right)}$ where $z \in \left\lbrace z' \in {\mathbb C}\ \ni\ z' \not=x\,,\ x\geq 0\right\rbrace$ and $0\ <\ \phi\left(z\right)\ <\ 2\pi$.
\begin{align} \int_{-x - {\rm i}}^{x - {\rm i}}{{\rm d}z \over z} &= -\int_{-1}^{0^{+}}{{\rm i}\,{\rm d}y \over x + {\rm i}y} - \int_{x}^{-x}{{\rm d}x' \over x' - {\rm i}0^{+}} - \int_{0^{+}}^{-1}{{\rm i}\,{\rm d}y \over {\rm i}y} \\[3mm] \int_{-x + {\rm i}}^{x + {\rm i}}{{\rm d}z \over z} &= -\int_{1}^{0^{+}}{{\rm i}\,{\rm d}y \over x + {\rm i}y} - \int_{x}^{-x}{{\rm d}x' \over x' + {\rm i}0^{+}} - \int_{0^{+}}^{1}{{\rm i}\,{\rm d}y \over {\rm i}y} \\[5mm]& \end{align}
\begin{align} & \int_{-x - {\rm i}}^{x - {\rm i}}{{\rm d}z \over z} - \int_{-x + {\rm i}}^{x + {\rm i}}{{\rm d}z \over z} = -{\rm i}\,{\cal P}\int_{-1}^{0^{+}}{{\rm d}y \over x + {\rm i}y} - {\rm i}\,{\cal P}\int^{1}_{0^{+}}{{\rm d}y \over x + {\rm i}y} \\[3mm]& + \int_{-x}^{x}\left({1 \over x' - {\rm i}0^{+}} - {1 \over x' + {\rm i}0^{+}}\right)\,{\rm d}x' + {\cal P}\int_{-1}^{1}{{\rm d}y \over y} \\[3mm]&= -{\rm i}\int_{-1}^{0^{+}} {{\rm d}y \over \sqrt{x^{2} + y^{2}\,}\ {\rm e}^{-{\rm i}\left\lbrack 2\pi - \Theta\left(x,y\right)\right\rbrack}} - {\rm i}\int^{1}_{0^{+}} {{\rm d}y \over \sqrt{x^{2} + y^{2}\,}\ {\rm e}^{-{\rm i}\Theta\left(x,y\right)}} + 2\pi{\rm i} \end{align}
where $\theta\left(x,y\right) \equiv \arctan\left(\left\vert y\right\vert/x\right)$
\begin{align} & \int_{-x - {\rm i}}^{x - {\rm i}}{{\rm d}z \over z} - \int_{-x + {\rm i}}^{x + {\rm i}}{{\rm d}z \over z} = -4{\rm i}\int^{1}_{0^{+}} {\cos\left(\theta\left(x,y\right)\right)\over \sqrt{x^{2} + y^{2}\,}}\,{\rm d}y + 2\pi{\rm i} = -4{\rm i}\int^{1}_{0^{+}}{x \over y^{2} + x^{2}\,}\,{\rm d}y + 2\pi{\rm i} \\[3mm]&= -4{\rm i}\int_{0}^{1/x}{{\rm d}y \over y^{2} + 1} + 2\pi{\rm i} \\[3mm]&{\large \Longrightarrow}\quad {\rm F}\left(x\right) = -{\rm F}\left(1 \over x\right) + {\pi \over 2} \end{align}
Then, $$ {\rm F}\left(x\right) = {\large\int_{0}^{x}{{\rm d}x \over x^{2} + 1} = \arctan\left(x\right)\,, \qquad x > 0} $$