<s>[INST] Determine the range of a function Find the range of the following function :
$$y= (3\cos{2x} -\sin{2x} -1)^2 -8$$
First solution:
$$ (3\cos{2x} -\sin{2x} -1)^2= (\sqrt{10} \cos{2x+ \theta})^2$$
$$-\sqrt{10}  =<(\sqrt{10} \cos{(2x+ \theta}))=< \sqrt{10}$$
$$-1-\sqrt{10}  =<(\sqrt{10} \cos{(2x+ \theta}))-1 =< \sqrt{10} -1$$
$$-8=< \left((\sqrt{10} \cos{(2x+ \theta}))-1\right)^2 -8=< 3-2\sqrt{10}$$
Second solution:
$$ (3\cos{2x} -\sin{2x} -1)^2=(2\sin{2x}-3\cos{2x} +1)^2 = (\sqrt{10} \sin\left(2x -\theta\right))^2 $$
Similarly as the first we get 
$$-8 =< y =< 3+2\sqrt{10}$$
Which solution is correct ? and whats the mistake ?
 [/INST] $$3\cos2x-2\sin2x=\sqrt{3^2+1^2}\cos\left(2x+\arccos\dfrac3{\sqrt{10}}\right)$$
$\implies-\sqrt{10}-1\le3\cos2x-\sin2x-1\le\sqrt{10}-1$
$$3\cos2x-\sin2x-1\le\sqrt{10}-1\implies(3\cos2x-\sin2x-1)^2-8\le(\sqrt{10}-1)^2-8$$
$$3\cos2x-\sin2x-1\ge-\sqrt{10}-1\implies(3\cos2x-\sin2x-1)^2-8\le(-\sqrt{10}-1)^2-8$$
Take the union of the two ranges
</s>