<s>[INST] How to prove that $\tan \left( \frac{\pi}{2} - \theta \right) = \cot \theta$ I am asked to simplify the following expression:
$$\tan \left( \frac{\pi}{2} - \theta \right)$$
The book gives me the answer $\cot \theta$ but, when I try to derive that formula using 
$$\tan \left( A \pm B \right) = \frac{\tan A \pm \tan B}{1 \mp \tan A \cdot \tan B}$$
I get $\tan \frac{\pi}{2}$ as one of the terms (which is undefined). 
$$\tan \left( A \pm B \right) = \frac{\tan A \pm \tan B}{1 \mp \tan A \cdot \tan B} = \frac{\tan \frac{\pi}{2} - \tan \theta}{1 + 0 \cdot \tan \theta}$$
How do I proceed?
Thank you.
 [/INST] The formula for $\tan(A\pm B)$ is obtained by dividing the formula for $\sin(A\pm B)$ by the one for $\cos(A\pm B)$, cancelling a factor of $\cos A\cos B$ from each to obtain the usual expression. As this is an illegal division by $0$ if $A=\frac{\pi}{2}$, it's easiest just to go back to the tangent's definition, viz.$$\tan\left(\frac{\pi}{2}-\theta\right)=\frac{\sin\left(\frac{\pi}{2}-\theta\right)}{\cos\left(\frac{\pi}{2}-\theta\right)}=\frac{\cos\theta}{\sin\theta}=\cot\theta.$$
</s>