I am trying to prove the fact that $\tan \frac{x}{2} = \frac{1-\cos x}{\sin x}$ or alternatively $\tan \frac{x}{2} = \frac{1- \cos x}{\sin x}$. (I understand that it can be proved using the half-angle identities of $\sin$ and $\cos$ but I want to understand how to get to the solution from this specific method of derivation.)
\begin{align*} \tan(2x) &= \frac{2\tan(x)}{1-\tan(x)^2} \\ \tan(x) &= \frac{2\tan(\frac{x}{2})}{1-\tan(\frac{x}{2})^2} \\ \end{align*} I now let $A=\tan x$ and $B=\tan \frac{x}{2}$ \begin{align*} A\cdot(1-B^2) &= 2B\\ AB^2+2B-A &= 0 \\ \end{align*} Now I solve for B using the quadratic formula. \begin{align*} B &= \frac{-2\pm \sqrt{4+4A^2}}{2A} \\ B &= \frac{-1\pm \sqrt{1+A^2}}{A} \\ \tan(\frac{x}{2}) &= \frac{-1\pm \sqrt{1+\tan(x)^2}}{\tan(x)}\\ \tan(\frac{x}{2}) &= \frac{-1\pm \sqrt{(\sec x)^2}}{\tan(x)}\\ \tan(\frac{x}{2}) &= \frac{-1\pm |\sec x|}{\tan(x)} \end{align*} I am confused as to how to continue at this point (firstly, not sure how to deal with the absolute value, and secondly not sure how to deal with the plus-minus). Any help is greatly appreciated, as I feel like I do not fully understand how to manipulate absolute values and the meaning of the plus-minus.