5. Let $a, b$ be real numbers, and the function $f(x) = ax + b$ satisfies: for any $x \in [0,1]$, we have $|f(x)| \leqslant 1$. Find
\[
S = (a+1)(b+1)
\]

the range of values.
(Yang Xiaoming, problem contributor)
5. Let $t=a+b$. From the given information, we have
$$
\begin{array}{l}
b=f(0) \in[-1,1], \\
t=f(1) \in[-1,1],
\end{array}
$$

and $S=(a+1)(b+1)=(t-b+1)(b+1)$.
The right-hand side of the above equation can be viewed as a linear function of $t$
$$
g(t)=(b+1) t+1-b^{2} \quad (t \in[-1,1]).
$$

Note that, $b+1 \geqslant 0$.
Thus, $g(-1) \leqslant g(t) \leqslant g(1)$
$$
\Rightarrow -b^{2}-b \leqslant g(t) \leqslant -b^{2}+b+2.
$$

When $b \in[-1,1]$,
$$
\begin{array}{l}
-b^{2}-b=-\left(b+\frac{1}{2}\right)^{2}+\frac{1}{4} \\
\geqslant -\left(1+\frac{1}{2}\right)^{2}+\frac{1}{4}=-2, \\
-b^{2}+b+2=-\left(b-\frac{1}{2}\right)^{2}+\frac{9}{4} \leqslant \frac{9}{4}.
\end{array}
$$

Combining with equation (1), we have
$$
S=g(t) \in\left[-2, \frac{9}{4}\right],
$$

where, when $t=-1, b=1$, i.e., $f(x)=-2 x+1$, $S$ reaches its minimum value -2; when $t=1, b=\frac{1}{2}$, i.e., $f(x)=\frac{1}{2} x+\frac{1}{2}$, $S$ reaches its maximum value $\frac{9}{4}$.
In summary, $S \in\left[-2, \frac{9}{4}\right]$.