Can someone show me how using the $\displaystyle t=\tan \left(\frac12 x\right)$ substitution, you can establish:

$\displaystyle \sin x = \frac{2t}{1+t^2}$

$\displaystyle \cos x = \frac{1-t^2}{1+t^2}$

It's memorised in my mind (the subsitution) but I don't know the method which bought these substituion in the first place. Thanks in advance.