<s>[INST] Proving a trigonometric identity: $\frac{\cos x}{1-\sin x} -\tan x = \sec x$ I am trying to prove a trig identity that is confusing me. The identity is 
$$\frac{\cos(x)}{(1-\sin(x))}-\tan(x)=\sec(x)$$
Here is my attempt.
I did $$\frac{\cos(x)}{(1-\sin^2(x))}=\frac{\cos(x)}{\cos^2(x)}=\frac{1}{\cos(x)}=\sec(x)=(\sec(x)+\tan(x))(1+\sin(x))\\\sec(x)=\sec(x)+\sec(x)\sin(x)+\tan(x)+\tan(x)\sin(x)\\0=\tan(x)+\tan(x)+\tan(x)\sin(x)$$ but this does not make sense to me. Can somebody please help me with this thing?
 [/INST] General case
You can employ the tangent half-angle substitution, writing $t:=\tan\frac x2$.
\begin{align*}
\frac{\cos(x)}{1-\sin(x)}-\tan(x)&=\sec(x) \\
\frac{\frac{1-t^2}{1+t^2}}{1-\frac{2t}{1+t^2}} - \frac{2t}{1-t^2} &= \frac{1+t^2}{1-t^2} \\
\frac{1-t^2}{1-2t+t^2} - \frac{2t}{1-t^2} &= \frac{1+t^2}{1-t^2} \\
\frac{(1+t)(1-t)}{(1-t)^2} - \frac{2t}{1-t^2} &= \frac{1+t^2}{1-t^2} \\
\frac{(1+t)^2}{(1+t)(1-t)} - \frac{2t}{1-t^2} &= \frac{1+t^2}{1-t^2} \\
(1+t)^2-2t&=1+t^2 \\
1+2t+t^2-2t&=1+t^2
\end{align*}
Special cases
If you want to, you can also consider possible special cases. The tangent half-angle substitution I did in my first step doesn't directly capture $x=\pm\pi$, but you get that as $\lim_{t\to\infty}$. Verifying that case explicitely you find
$$\frac{\cos\pi}{1-\sin\pi}-\tan\pi=\frac{1}{1-0}-0=1=\sec\pi$$
In the second step I canceled $1+t^2$ which will be non-zero for real $t$. In the fourth step, I canceled $1-t$ which corresponds to $x=\frac\pi2$. In that case you indeed have a singularity, where pretty much all your terms become undefined. One step later I multiply everything with $1-t^2=(1+t)(1-t)$ which would be illegal for $x=\pm\frac\pi2$. But for $x=-\frac\pi2$ again $\tan(x)$ and $\sec(x)$ become undefined. So the equation holds whenever all the terms it contains are defined, and when all the terms of one side are defined then so are those on the other.
Note that the above does not hold if you are operating in the real projective line $\mathbb R\cup\{\infty\}$. There you have for $x=\frac\pi2$:
$$\frac{\cos\tfrac\pi2}{1-\sin\tfrac\pi2}-\tan\tfrac\pi2=\frac{0}{1-1}-\infty=\frac00-\infty\overset?=\infty=\sec\tfrac\pi2$$
but $\frac00$ is still undefined. So you have a removable singularity in this case.
</s>