2. Given numbers $x, y, z \in\left[0, \frac{\pi}{2}\right]$. Find the maximum value of the expression

$$
A=\sin (x-y)+\sin (y-z)+\sin (z-x) .
$$
Answer: $\sqrt{2}-1$.

Solution. We can assume that $x \leqslant y$ and $x \leqslant z$, since the expression $A$ does not change under cyclic permutation of the variables. Notice that

$$
\sin (x-y)+\sin (z-x)=2 \sin \left(\frac{z-y}{2}\right) \cos \left(\frac{z+y}{2}-x\right)
$$

The argument of the sine on the right-hand side lies in $\left[-\frac{\pi}{2}, \frac{\pi}{2}\right]$, and the cosine in $\left[0, \frac{\pi}{2}\right]$, since $\frac{\pi}{2} \geqslant \frac{z+y}{2} \geqslant x$. Consider two cases.

1) $z>y$. The right-hand side will be maximized at the maximum possible $x$, which is $x=y$, and the value of $A$ will be zero.
2) $z \leqslant y$. For fixed $y$ and $z$, the right-hand side will reach its maximum at $x=0$. In this case,

$$
A=\sin z-\sin y+\sin (y-z)=-\sin y+2 \sin \frac{y}{2} \cdot \cos \left(\frac{y}{2}-z\right) \leqslant 2 \sin \frac{y}{2}-\sin y=2 \sin \frac{y}{2} \cdot\left(1-\cos \frac{y}{2}\right)
$$

The expression on the right-hand side increases with $y$, so its maximum is achieved at $y=\frac{\pi}{2}$ and equals $\sqrt{2}-1$. Therefore, $A \leqslant \sqrt{2}-1$. Equality is realized when $x=0, y=\frac{\pi}{2}, z=\frac{\pi}{4}$.