5. Find the minimum value of the function $y=\sin 2x-(\sin x+\cos x)+1$.
Solution: Let $t=\sin x+\cos x$. Then $t^{2}=1+\sin 2 x$ and $y=t^{2}-t$.

In this case, $t \in[-\sqrt{2} ; \sqrt{2}]$. This function reaches its minimum at $t=1 / 2$ and this minimum is equal to $-1 / 4$. Answer: $-1 / 4$.