Example 5. If $x^{2}-1 \leqslant 0$, find the maximum and minimum values of the function $y=x^{2}-4 x$ +5.
$\begin{array}{l} \text { Sol } \because y=(x-2)^{2}+1, \text { and }-1 \leqslant x \leqslant 1, \\ \therefore \quad \text { when } x=1, \text { } y_{\text {minimum }}=2 . \\ \text { When } x=-1, \text { } y_{\text {maximum }}=10 .\end{array}$