Example 6 If $y=\sqrt{1-x}+\sqrt{x-\frac{1}{2}}$ has a maximum value of $a$ and a minimum value of $b$, then $a^{2}+b^{2}=$ $\qquad$ [6]
Solve: From $1-x \geqslant 0, x-\frac{1}{2} \geqslant 0 \Rightarrow \frac{1}{2} \leqslant x \leqslant 1$.
According to the problem, we have
$$
\begin{aligned}
y^{2} & =\left(\sqrt{1-x}+\sqrt{x-\frac{1}{2}}\right)^{2} \\
& =\frac{1}{2}+2 \sqrt{(1-x)\left(x-\frac{1}{2}\right)}: \\
& =\frac{1}{2}+2 \sqrt{-\left(x-\frac{3}{4}\right)^{2}+\frac{1}{16}} . \\
& \text { Let } t=-\left(x-\frac{3}{4}\right)^{2}+\frac{1}{16}(t \geqslant 0) .
\end{aligned}
$$

By the properties of quadratic functions and $\frac{1}{2} \leqslant x \leqslant 1$, we know that when $x=\frac{3}{4}$, $t_{\text {max }}=\frac{1}{16}, y_{\text {max }}=1$; when $x=\frac{1}{2}$ or $x=1$, $t_{\text {min }}=0, y_{\text {min }}=\frac{\sqrt{2}}{2}$. Therefore, $a=1, b=\frac{\sqrt{2}}{2} \Rightarrow a^{2}+b^{2}=\frac{3}{2}$.