proof of $\arctan(x)=\frac{i}{2}(\ln(x+i)-\ln(x-i)-i\pi)$ without solving $\int\frac{1}{x^2+1}dx$ So I know $\int\frac{1}{x^2+1}dx=\arctan(x)+c$
Now when i tried to integral $\frac{1}{x^2+1}$ in a different way i got this:
$$\frac{1}{x^2+1}=\frac{1}{(x-i)(x+i)}=\frac{A}{x-i}+\frac{B}{x+i}\\\implies1=Ax+Ai+Bx-Bi=x(A+B)+i(A-B)\\\implies
\begin{cases}
A+B=0
\\[2ex]
A-B=\frac{1}{i}=-i
\end{cases}\\\implies2A=-i\implies A=\frac{-i}{2}\implies B=\frac{i}{2}$$
So in the end i get:$$\int\frac{1}{x^2+1}dx=\int\frac{i}{2(x+i)}-\frac{i}{2(x-i)}dx=\frac{i}{2}\int\frac{1}{(x+i)}-\frac{1}{(x-i)}dx$$
After integrating this i get $\frac{i}{2}(\ln(x+i)-\ln(x-i)+C)$ after comparing this to $\arctan(x)$ at $x=0$ i find $C=-i\pi$
$\therefore~\arctan(x)=\frac{i}{2}(\ln(x+i)-\ln(x-i)-i\pi)$
now my question is how can i prove that without using the integral

By definition of $\ln$ for complex numbers:
$$\ln(x+i)=\ln|x+i|+i\operatorname{Arg}(x+i)$$
where $\operatorname{Arg}$ is the principal value of the $\arg$
It is clear that:
$$\operatorname{Arg}(x+i)=\begin{cases}\arctan\frac{1}{x}&\text{ if }x\ge0\\\pi+\arctan\frac{1}{x}&\text{ if }x<0\end{cases}$$
Analogously:
$$\ln(x-i)=\ln|x-i|+i\operatorname{Arg}(x-i)$$
In this case it is:
$$\operatorname{Arg}(x-i)=\begin{cases}-\arctan\frac{1}{x}&\text{ if }x\ge0\\-\pi-\arctan\frac{1}{x}&\text{ if }x<0\end{cases}$$
Moreover observe that:
$|x+i|=|x-i|$
Putting everything together you get:
$\frac{i}{2}(\ln(x+i)-\ln(x-i)-i\pi)=\begin{cases}\stackrel{x\ge0}=\frac{i}{2}(2i\arctan\frac{1}{x}-i\pi)&=-\arctan\frac{1}{x}+\frac{\pi}{2}=\\\stackrel{x<0}=\frac{i}{2}(2i\pi+2i\arctan\frac{1}{x}-i\pi)&=-\arctan\frac{1}{x}-\frac{\pi}{2}=\end{cases}=\arctan x$
