TITLE: Why does $\arctan(x)= \frac{1}{2i}\log \left( \frac{x-i}{x+i}\right)+k$?
QUESTION [26 upvotes]: Letting $x=\tan(u)$,
$$\int\frac{1}{1+x^2} \, dx=\int\frac{1}{1+\tan(u)^2}\sec^2(u) \, du=u+k=\arctan(x)+k$$
Also, 
$$\int\frac{1}{1+x^2} \, dx=\int\frac{1}{(x-i)(x+i)} \, dx=\frac{1}{2i}\int\frac{1}{(x-i)}-\frac{1}{(x+i)} \, dx$$
$$=\frac{1}{2i}\left(\ln(x-i)-\ln(x+i)\right)+c$$
$$=\frac{1}{2i}\ln \left(\frac{x-i}{x+i} \right)+c$$
Giving
$$\arctan(x)=\frac{1}{2i}\ln \left(\frac{x-i}{x+i} \right)+q$$
Why is this correct? What is the nature of $q$ (is it 'flexible' so the equality doesn't really mean much)?
I think it probably has something to do with the relationship between $\log(z)$ and $\arg(z)$, but $\arg(z\pm i)$ is hard to calculate neatly.

REPLY [26 votes]: The basic identity used here was discovered in the 18th century by Leonhard Euler:
$$
e^{iz} = \cos z+i\sin z
$$
where of course the cosine and the sine are of $x$ in radians.
It follows that $\cos z = \dfrac{e^{iz}+e^{-iz}}{2}$ and $\sin z = \dfrac{e^{iz}-e^{-iz}}{2i}$.
Therefore
$$
a= \tan z = \frac{e^{iz}-e^{-iz}}{i(e^{iz}+e^{-iz})} = -i\frac{e^{2iz}-1}{e^{2iz}+1} = -i\frac{b-1}{b+1}.
$$
$$
\begin{align}
a & = -i\frac{b-1}{b+1} \\[10pt]
(b+1)a & = -i(b-1) \\[10pt]
b(i+a) & = i-a \\[10pt]
b & = \frac{i-a}{i+a} \\[10pt]
e^{2iz} & = \frac{i-a}{i+a} \\[10pt]
2iz & = \log \frac{i-a}{i+a}
\end{align}
$$
The logarithm, like the arctangent, is "multiple-valued".