# Integral of $\frac{1}{x^2+1}$ using complex partial fractions.

Is there any way to evaluate the following integral via a complex partial fraction decomposition? $$\int \dfrac{1}{x^2 + 1} \text{ d}x$$ So far I have: \begin{aligned} \int \dfrac{1}{x^2 + 1} \text{ d}x & = \dfrac{1}{2i} \int \dfrac{1}{x-i} \text{ d}x - \dfrac{1}{2i} \int \dfrac{1}{x+i} \text{ d}x \\ & = \dfrac{1}{2i} \log \left| \dfrac{x-i}{x+i} \right| + \mathcal{C} \end{aligned} I know that the integral of a real valued function is a real valued function, so how do I take the real part of this final result?

Using the following identity for the logarithm of a complex number: $$\log(a+ib)=\log|a+ib|+i\arg(a+ib)=\log\sqrt{a^2+b^2}+i\tan^{-1}\left(\frac{b}{a}\right)$$ results in $$\frac{1}{2i}\log\left|\frac{x-i}{x+i}\right|=\frac{1}{2i}(\log|x-i|-\log|x+i|)=-\frac{1}{2i}(2i\tan^{-1}\frac{1}{x})=-\tan^{-1}\left(\frac{1}{x}\right)$$ Using the reciprocal property of the arctangent function, we have for $x>0$ $$-\tan^{-1}\left(\frac{1}{x}\right)=\tan^{-1}x-\frac{\pi}{2}$$ and for $x<0$ $$-\tan^{-1}\left(\frac{1}{x}\right)=\tan^{-1}x+\frac{\pi}{2}$$ Incorporating the $\pm\frac{\pi}{2}$ into the constant term, the integral is thus $$\tan^{-1}x+C$$
Well the imaginary part is $0$, so you just need to simplify it. Consider the inverse of $\tan x$ where $\displaystyle\tan{x}=\frac{i(e^{-ix}-e^{ix})}{e^{ix}+e^{-ix}}$.