<s>[INST] How can one prove $-\arctan\left(\frac{x}{y}\right)+\pi H(y)=2\arctan\left(\frac{y}{\sqrt{x^2+y^2}+x}\right)+\frac{\pi}{2}$? How can one prove the following?
$$
-\arctan\left(\frac{x}{y}\right)+\pi H(y)=2\arctan\left(\frac{y}{\sqrt{x^2+y^2}+x}\right)+\frac{\pi}{2}$$
with $H(x)$ the Heaviside function.
I have the impression that this might follow from the following
$$H(y)=H(-x)+2H(x)H(y)-H(xy)$$
and
$$\arctan\left(\frac{x}{y}\right)+\arctan\left(\frac{y}{x}\right)=\pi H(xy)-\frac{\pi}{2}$$
but I can't quite get it right...
 [/INST] For $y>0$ you'd like to prove that
$$
\frac{\pi}{2}-\arctan\frac{x}{y}=2\arctan\frac{y}{\sqrt{x^2+y^2}+x}
$$
Note that the left-hand side is a number in the interval $[0,\pi]$ and the same for the right-hand side. The identity is true for $x=0$.
Suppose $x>0$, so both sides are in $(0,\pi/2)$. Then take the tangent of both sides; if $z=y/(\sqrt{x^2+y^2}+x)$, the identity to prove is
$$
\frac{y}{x}=\frac{2z}{1-z^2}
$$
For simplicity, set $D=\sqrt{x^2+y^2}$; then
$$
1-z^2=1-\frac{y^2}{2x^2+y^2+2xD}=\frac{2x^2+2xD}{2x^2+y^2+2xD}=\frac{2x(x+D)}{(D+x)^2}=
\frac{2x}{D+x}
$$
Hence
$$
\frac{2z}{1-z^2}=\frac{2y}{D+x}\frac{D+x}{2x}=\frac{y}{x}
$$
Suppose now $x<0$ and set $x=-t$; then the identity to prove is
$$
\frac{\pi}{2}+\arctan\frac{t}{y}=2\arctan\frac{y}{\sqrt{t^2+y^2}-t}=
2\arctan\frac{\sqrt{t^2+y^2}+t}{y}
$$
Recall that $\arctan\frac{1}{u}=\pi/2-\arctan u$ (for $u>0$), so the identity to prove is
$$
\frac{\pi}{2}+\arctan\frac{t}{y}=\pi-\arctan\frac{y}{\sqrt{t^2+y^2}+t}
$$
that's already been proved.
For $y<0$ you want to prove that
$$
-\frac{\pi}{2}-\arctan\frac{x}{y}=2\arctan\frac{y}{\sqrt{x^2+y^2}+x}
$$
Changing $y=-z$, the identity becomes
$$
-\frac{\pi}{2}+\arctan\frac{x}{z}=-2\arctan\frac{z}{\sqrt{x^2+z^2}+x}
$$
that has already been proved.
</s>