$\arctan x=\frac{1}{2}i[\ln(1-ix)-\ln(1+ix)]$

As $e^{i\varphi} = \cos\varphi + i\sin\varphi$ we get $$ \sin \varphi = \frac{e^{i\varphi} - e^{-i\varphi}}{2i}, \quad \cos\varphi = \frac{e^{i\varphi} + e^{-i\varphi}}{2} $$ which leads to $$ \tan \varphi = \frac{e^{i\varphi} - e^{-i\varphi}}{i(e^{i\varphi} + e^{-i\varphi})}. $$ Let $\tan \varphi = x$, then $$ \frac{e^{i\varphi} - e^{-i\varphi}}{e^{i\varphi} + e^{-i\varphi}} = ix $$ and solving it we find that $$ e^{i\varphi} = \sqrt{\frac{1 + ix}{1 - ix}} $$ which leads us to $$ \arctan x = \varphi = \frac{1}{i}\ln\sqrt{\frac{1 + ix}{1 - ix}} = \frac{i}{2}\left[\ln(1 - ix) - \ln(1 + ix)\right]. $$


We know

$$\int \frac{dx}{1+x^2}=\arctan(x) +c_1$$

Now notice $$\int \frac{dx}{1+x^2}=1/2\int \frac{1}{1+ix}+\frac{1}{1-ix} dx$$ $$=\frac{1}{2i}[\ln(1+ix)-\ln(1-ix)]+c_2$$

Expanding the fraction $\frac{1}{2i}$ with i and comparing both expressions results in: $$\arctan(x)=\frac{i}{2}[\ln(1-ix)-\ln(1+ix)]+c_3.$$

Plug in $x=0$ to determin $c_3=0$.


There is a nice geometrical interpretation of this too. Sadly I'm on mobile so I can't include an image right now but it works like this:

When a complex number is represented in an Argand diagram (i.e. as a point on the plane where the $x$-coordinate is the real part and the $y$-coordinate is the imaginary part) one can consider the distance from the origin (the modulus) and the angle anti-clockwise from the real ($x$) axis to the number (that is, the line from the origin to the number), called the argument. When a number is below the real axis we consider the angle as negative rather than bigger than $\pi$.

Consider how complex exponential works: $$\mathrm e^{x+\mathrm i y} = \mathrm e^x(\cos y + \mathrm i \sin y).$$ Thus we see that the logarithm of a complex number should be a complex number where the real part is the logarithm of the modulus and the imaginary part is the argument. We ignore the problems where there are multiple values this could be and will say that the imaginary part is between $-\pi$ and $\pi$. It will turn out we don't need to think about what e.g. $\log(-1)$ should be.

Now we come back to the identity in question. First we let $x>0$ be a real number (certainly the identity is true if $x=0$) and we rearrange the right hand side to get: $$\arctan x = \frac1{2\mathrm i}\left[\log(1+\mathrm i x) - \log(1-\mathrm i x)\right].$$

Draw an Argand diagram. Label the origin $O$ and now label the point $(1,x)$ (corresponding to $1+\mathrm i x$) by $A$ and the point $(1,-x)$ by $B$. Finally label the point $(1,0)$ by $C$.

We see that the real parts of both logarithms must be the same (as $OA$ and $OB$ have the same length). The imaginary part of the first logarithm is the angle $\widehat{COA}$ and the imaginary part of the second is negative the angle $\widehat{BOC}$. Thus the difference of the logarithms will be the number $2\mathrm i \theta$ where $\theta$ is the angle $\widehat{COA}$ (equal to $\widehat{BOC}$ by symmetry). Thus the right hand side of the equation is equal to $\theta$. However we consider the right triangle $ACO$ and see that $$\tan \theta = \frac{|AC|}{|OC|}=x. $$

Thus we have proven the identity for positive $x$. The same reasoning follows for the identity for negative $x$.