Why does $\arctan(x)= \frac{1}{2i}\log \left( \frac{x-i}{x+i}\right)+k$? 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.
 A: We have that $$i\sin z=\sinh iz$$ $$\cos z=\cosh iz$$
This means that $$i\tan z=\tanh iz$$
But $$\tanh^{-1}z=\frac 1 2\log\left(\frac{1+z}{1-z}\right)$$
A: This is correct, and by letting $x$ tend to $+\infty$ you can find the constant term: $$\arctan(x) = \frac{1}{2i} \log(\frac{x-i}{x+i}) + \frac{\pi}{2},$$ since $\log(\frac{x-i}{x+i})$ tends to $\log(1) = 0$ and $\arctan(x)$ tends to $\pi / 2$.
This is valid for $x > 0$. Unfortunately, there is a difficulty with the $\log$ function at $-1$, and for $x < 0$ we get the formula $$\arctan(x) = \frac{1}{2i} \log(\frac{x-i}{x+i}) - \frac{\pi}{2}$$ by a similar argument.
That the logarithm and inverse trigonometric functions are related shouldn't be surprising, though. Remember Euler's formula: $e^{ix} = \cos(x) + i \sin(x)$ that relates the exponential to the trigonometric functions.
A: 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".
