<s>[INST] Why does the formula for $\tan 3\theta$ work at $\theta=\frac\pi4$ even though its proof involves cancelling $1-\tan^2\theta$? Here's a proof for the $\tan 3\theta$ formula:

According to the procedure for the proof, when we cancel out $1-\tan^2\theta$, the value of $1-\tan^2\theta$ should not be equal to $0$ (in particular, $\theta$ should not be $\frac{\pi}{4}$) as $\frac{ax}{bx}=\frac{a}{b}$ only if $x$ isn't $0$.
But, when we substitute $\theta=\frac{\pi}{4}$ in the final formula, we still get the correct answer:
$$\frac{3\tan\frac{\pi}{4}-\tan^3\frac{\pi}{4}}{1-3\tan^2\frac{\pi}{4}}=\tan\frac{3\pi}{4}=-1$$
How is this possible?
 [/INST] You could also first compute the triple angle formulas for sine and cosine,
$$
\sin(3x)=\frac1{2i}(e^{i3x}-e^{-i3x})=\sin(x)(e^{i2x}+1+e^{-i2x})=\sin(x)(-4\sin^2(x)+3)\\
\cos(3x)=\frac12(e^{i3x}+e^{-i3x})=\cos(x)(e^{i2x}-1+e^{-i2x})=\cos(x)(4\cos^2(x)-3)\\
$$
so in consequence
$$
\tan(3x)=\tan x\,\frac{3\cos^2x-\sin^2x}{\cos^2x-3\sin^2x}=\tan x\,\frac{3-\tan^2x}{1-3\tan^2x}
$$
</s>