2. Determine the maximum value of $\frac{1+\cos x}{\sin x+\cos x+2}$, where $x$ ranges over all real numbers.
2. Answer: 1
Solution. Let $y=\frac{1+\cos x}{\sin x+\cos x+2}$. When $\cos x+1=0, y=0$. Otherwise,
$$
y=\frac{1}{1+\frac{1+\sin x}{1+\cos x}} .
$$

Let $u=\frac{1+\sin x}{1+\cos x}$. It is clear that $u \geq 0$, and so $y \leq 1$ where the equality holds when $u=0$.
Thus the maximum value of $y$ is 1 when $\sin x=-1$.