22.12 ** Given $x \in \mathbf{R}$. Then the sum of the maximum and minimum values of the function $f(x)=\max \left\{\sin x, \cos x, \frac{\sin x+\cos x}{\sqrt{2}}\right\}$ is
Notice that
\[
\begin{aligned}
f(x) & =\max \left\{\sin x, \cos x, \frac{\sin x+\cos x}{\sqrt{2}}\right\} \\
& =\max \left\{\sin x, \cos x, \sin \left(x+\frac{\pi}{4}\right)\right\},
\end{aligned}
\]
Clearly, the maximum value of \( f(x) \) is 1. By plotting the graphs of \( y=\sin x \) and \( y=\cos x \), we can see that the minimum value of \( \max \{\sin x, \cos x\} \) is \( -\frac{\sqrt{2}}{2} \), which is achieved at \( x=\frac{5 \pi}{4} \). At \( x=\frac{5 \pi}{4} \), the value of \( \sin \left(x+\frac{\pi}{4}\right) \) is -1. Therefore, the minimum value of \( f(x) \) is \( -\frac{\sqrt{2}}{2} \), and the required sum is \( 1-\frac{\sqrt{2}}{2} \).