Simplifying an Arctan equation

The derivation is perfect. Let me corroborate

Using the definition of the principal values

$\displaystyle\arctan \frac1x=\begin{cases} \text{arccot}x &\mbox{if } x>0 \\ \text{arccot}x-\pi & \mbox{if } x<0 \end{cases} $

See Are $\mathrm{arccot}(x)$ and $\arctan(1/x)$ the same function?

and we know $\displaystyle\arctan(y)+\text{arccot}(y) =\frac\pi2$ for all real $y$ (Proof)


Try $$\begin{align}\tan^{-1}x+\tan^{-1}\frac1x&=\tan^{-1}\left(\tan\left(\tan^{-1}x+\tan^{-1}\frac1x\right)\right)\\ &=\tan^{-1}\left(\frac{x+\frac1x}{1-x\cdot\frac1x}\right)\\ &=\tan^{-1}(\text{sgn}(x)\infty)=\frac\pi2\text{sgn}(x)\end{align}$$

Where $\text{sgn}(x)=\left\{\begin{array}{l}1\text{ if }x>0\\0\text{ if }x=0\\-1\text{ if }x<0\end{array}\right.$ (Note that the sum is actually undefined at $0$, but I'm saying it's $0$ for convenience.)

Alternatively, consider the geometric definition of arctangent: Given a right-angled triangle with sides $a,b,c$ (where $c$ is a hypotenuse) and angles $A,B,C$ ($C=\frac\pi2$), $\tan^{-1}\frac ba=A$. If we let $x=\frac ba$, then $\tan^{-1}x+\tan^{-1}\frac1x=A+B=\frac\pi2$

Your way works, too. It's pretty clever actually.