Some help with sin and cos I'm having trouble to understand the following equalities in these two equations, i.e. how to apply the addition formulas.

Firstly:

$$ \frac {1- \frac {sin^2(\frac x2)} {cos^2(\frac x2)}} {1+ \frac {sin^2(\frac x2)} {cos^2(\frac x2)}} = \frac {cos^2(\frac x2) - sin^2(\frac x2)} {cos^2(\frac x2) + sin^2(\frac x2)}= cos^2(\frac x2) - sin^2(\frac x2)$$

and secondly:

$$ \frac {2tan(\frac x2)} {1+tan^2(\frac x2)} = 2* \frac {sin(\frac x2)} {cos(\frac x2)(1+\frac {sin^2(\frac x2)}{cos^2(\frac x2)})} = 2* \frac {sin(\frac x2)cos(\frac x2)} {cos^2(\frac x2)+sin^2(\frac x2)}= 2sin(\frac x2)cos(\frac x2) $$

I don't understand all the steps in those equations unfortunately. Can someone help me out here?
To get the first equality

$$\frac {1- \frac {sin^2(\frac x2)} {cos^2(\frac x2)}} {1+ \frac {sin^2(\frac x2)} {cos^2(\frac x2)}} \underbrace{=}_{(1)} \frac {cos^2(\frac x2) - sin^2(\frac x2)} {cos^2(\frac x2) + sin^2(\frac x2)}\underbrace{=}_{(2)} cos^2(\frac x2) - sin^2(\frac x2)$$

in step $(1)$ you multiply numerator and denominator by $\cos^2\frac x2$ (note that $\frac ab=\frac{ac}{bc}, \forall c\ne 0.$)

In step $(2)$ it is used the equality $\sin^2 t+\cos^2 t=1.$

To get the second equality

$$\frac {2tan(\frac x2)} {1+tan^2(\frac x2)} \underbrace{=}_{(1)} 2\frac {sin(\frac x2)} {cos(\frac x2)(1+\frac {sin^2(\frac x2)}{cos^2(\frac x2)})} \underbrace{=}_{(2)}2\frac {sin(\frac x2)cos(\frac x2)} {cos^2(\frac x2)+sin^2(\frac x2)}\underbrace{=}_{(3)} 2sin(\frac x2)cos(\frac x2)$$ note that:

$(1)$ is just the definition of tangent $\left(\tan t=\frac{\sin t}{\cos t}\right).$ In $(2)$ multiply numerator and denominator by $\cos \frac{x}{2}$ (note that, $\frac{a}{b}=\frac{ac}{bc}, \forall c\ne 0.$) In step $(3)$ it is used again the equality $\sin^2 t+\cos^2 t=1.$
(2) that's multiply numerator and denominator by $\left(\cos\left(\tfrac x2\right)\right)^2$.