8. $x+y+z=1$, where $x \geqslant 0, y \geqslant 0, z \geqslant 0$, let $f(z)=(z-x)(z-y)$, then the range of $f(z)$ is $\qquad$
$$
\begin{array}{l}
\text { 8. }\left[-\frac{1}{8}, 1\right] \\
f(z)=z^{2}-(x+y) z+x y=z^{2}-(1-z) z+x y \\
=2 z^{2}-z+x y \geqslant 2 z^{2}-z \\
=2\left(z-\frac{1}{4}\right)^{2}-\frac{1}{8} \geqslant-\frac{1}{8} \text {, } \\
\end{array}
$$

The equality is achieved when $x=0, y=\frac{3}{4}, z=\frac{1}{4}$.
$$
\text { Also, } \begin{aligned}
f(z) & =2 z^{2}-z+x y \leqslant 2 z^{2}-z+\left(\frac{x+y}{2}\right)^{2} \\
& =2 z^{2}-z+\left(\frac{1-z}{2}\right)^{2}=\frac{9}{4} z^{2}-\frac{3}{2} z+\frac{1}{4} \\
& =\frac{9}{4}\left(z-\frac{1}{3}\right)^{2} \leqslant 1,
\end{aligned}
$$

The equality is achieved when $x=0, y=0, z=1$.