\frac{1+\cos x }{\sin x} \left[ {\frac{\sin x^{2}-1+2\cos x-\cos x^{2}}{\sin x^{2}}} \right]=\frac{\left ( 1+\cos x \right )\left ( 2\cos x-2\cos x^{2} \right )}{\sin x\sin x^{2}}=\frac{\left ( 1+\cos x \right )\left ( 1-\cos x \right )2\cos x}{\sin x\left ( 1-\cos x^{2} \right )}=\frac{2\cos x}{\sin x}=2\cot x
$\frac{1+\cos x }{\sin x} \left[ {\frac{\sin x^{2}-1+2\cos x-\cos x^{2}}{\sin x^{2}}} \right]
$$=\frac{\left ( 1+\cos x \right )\left ( 2\cos x-2\cos x^{2} \right )}{\sin x\sin x^{2}}
$$=\frac{\left ( 1+\cos x \right )\left ( 1-\cos x \right )2\cos x}{\sin x\left ( 1-\cos x^{2} \right )}
$$=\frac{2\cos x}{\sin x}
$$=2\cot x
$