7. Let $f(x, y, z)=\sum \frac{x(2 y-z)}{1+x+3 y}(x, y, z \geqslant 0)$, and $x+y+z=1$. Find the maximum and minimum values of $f(x, y, z)$.
(Li Shenghong)
7. First, prove: $f \leqslant \frac{1}{7}$, and the equality holds if and only if $x=y=z=\frac{1}{3}$.
Notice that
$$
f=\sum \frac{x(x+3 y-1)}{1+x+3 y}=1-2 \sum \frac{x}{1+x+3 y}
$$

By the Cauchy-Schwarz inequality, we have
$$
\begin{array}{l}
\sum \frac{x}{1+x+3 y} \geqslant \frac{\left(\sum x\right)^{2}}{\sum x(1+x+3 y)} \\
=\frac{1}{\sum x(1+x+3 y)} . \\
\text { Also, } \sum x(1+x+3 y)=\sum x(2 x+4 y+z) \\
=2+\sum x y \leqslant \frac{7}{3},
\end{array}
$$

Thus, $\sum \frac{x}{1+x+3 y} \geqslant \frac{3}{7}, f \leqslant 1-2 \times \frac{3}{7}=\frac{1}{7}$.
Therefore, $f_{\text {max }}=\frac{1}{7}$, and the equality holds if and only if $x=y=z=\frac{1}{3}$.

Next, prove: $f \geqslant 0$, and the equality holds when $x=1, y=z=0$.
Proof 1: In fact,
$$
\begin{array}{l}
f(x, y, z)=\sum \frac{x(2 y-z)}{1+x+3 y} \\
=\sum x y\left(\frac{2}{1+x+3 y}-\frac{1}{1+y+3 z}\right) \\
=\sum \frac{7 x y z}{(1+x+3 y)(1+y+3 z)} \\
\geqslant 0 .
\end{array}
$$

Therefore, $f_{\text {min }}=0$, and the equality holds when $x=1, y=z=0$.
Proof 2: Let $z=\min \{x, y, z\}$. If $z=0$, then
$$
\begin{array}{l}
f(x, y, 0)=\frac{2 x y}{1+x+3 y}-\frac{x y}{1+y} \\
=\frac{2 x y}{2 x+4 y}-\frac{x y}{x+2 y}=0 .
\end{array}
$$

Now assume $x, y \geqslant z>0$.
From equation (1), to prove $f \geqslant 0$, it suffices to prove
$$
\sum \frac{x}{1+x+3 y} \leqslant \frac{1}{2} \text {. }
$$

Notice that $\frac{1}{2}=\frac{x}{2 x+4 y}+\frac{y}{x+2 y}$.
Thus, equation (2) is equivalent to
$$
\begin{array}{l}
\frac{z}{1+z+3 x} \\
\leqslant\left(\frac{x}{2 x+4 y}-\frac{x}{1+x+3 y}\right)+\left(\frac{y}{x+2 y}-\frac{y}{1+y+3 z}\right) \\
=\frac{z}{2 x+4 y}\left(\frac{x}{1+x+3 y}+\frac{8 y}{1+y+3 z}\right),
\end{array}
$$

which is equivalent to $\frac{2 x+4 y}{1+z+3 x} \leqslant \frac{x}{1+x+3 y}+\frac{8 y}{1+y+3 z}$.
By the Cauchy-Schwarz inequality, we have
$$
\begin{array}{l}
\frac{x}{1+x+3 y}+\frac{8 y}{1+y+3 z} \\
=\frac{x^{2}}{x(1+x+3 y)}+\frac{(2 y)^{2}}{\frac{1}{2} y(1+y+3 z)} \\
\geqslant \frac{(x+2 y)^{2}}{\left(x+x^{2}+3 x y\right)+\frac{1}{2}\left(y+y^{2}+3 y z\right)} \\
=\frac{2 x+4 y}{1+z+3 x},
\end{array}
$$

Thus, equation (3) holds. Therefore, $f \geqslant 0$.
Hence, $f_{\text {min }}=0$, and the equality holds when $x=1, y=z=0$.