Example 11 Let
$$f(x, y, z)=\frac{x(2 y-z)}{1+x+3 y}+\frac{y(2 z-x)}{1+y+3 z}+\frac{z(2 x-y)}{1+z+3 x}$$

where $x, y, z \geqslant 0$, and $x+y+z=1$. Find the maximum and minimum values of $f(x, y, z)$.
First, we prove that \( f \leqslant \frac{1}{7} \), with equality holding if and only if \( x = y = z = \frac{1}{3} \). Because
\[ f = \sum \frac{x(x + 3y - 1)}{1 + x + 3y} = 1 - 2 \sum \frac{x}{1 + x + 3y} \]

By the Cauchy-Schwarz inequality,
\[ \sum \frac{x}{1 + x + 3y} \geqslant \frac{\left( \sum x \right)^2}{\sum x(1 + x + 3y)} = \frac{1}{\sum x(1 + x + 3y)} \]

Since
\[ \sum x(1 + x + 3y) = \sum x(2x + 4y + z) = 2 + \sum xy \leqslant \frac{7}{3} \]

Thus,
\[ \sum \frac{x}{1 + x + 3y} \geqslant \frac{3}{7} \]
\[ f \leqslant 1 - 2 \times \frac{3}{7} = \frac{1}{7} \]

Therefore, \( f_{\text{max}} = \frac{1}{7} \), with equality holding if and only if \( x = y = z = \frac{1}{3} \).

Next, we prove that \( f \geqslant 0 \), with equality holding when \( x = 1 \) and \( y = z = 0 \). In fact,
\[ \begin{aligned}
f(x, y, z) = & \frac{x(2y - z)}{1 + x + 3y} + \frac{y(2z - x)}{1 + y + 3z} + \frac{z(2x - y)}{1 + z + 3x} \\
= & xy \left( \frac{2}{1 + x + 3y} - \frac{1}{1 + y + 3z} \right) \\
& + xz \left( \frac{2}{1 + z + 3x} - \frac{1}{1 + x + 3y} \right) \\
& + yz \left( \frac{2}{1 + y + 3z} - \frac{1}{1 + z + 3x} \right) \\
= & \frac{7xyz}{(1 + x + 3y)(1 + y + 3z)} \\
& + \frac{7xyz}{(1 + z + 3x)(1 + x + 3y)} \\
& + \frac{7xyz}{(1 + y + 3z)(1 + z + 3x)} \\
\geqslant & 0
\end{aligned} \]

Thus, \( f_{\text{min}} = 0 \), with equality holding when \( x = 1 \) and \( y = z = 0 \).

Alternative proof: Let \( z = \min \{x, y, z\} \). If \( z = 0 \), then
\[ f(x, y, 0) = \frac{2xy}{1 + x + 3y} - \frac{xy}{1 + y} = \frac{2xy}{2x + 4y} - \frac{xy}{x + 2y} = 0. \]

Now, assume \( x, y \geqslant z > 0 \). By (41), to prove \( f \geqslant 0 \), it suffices to show
\[ \sum \frac{x}{1 + x + 3y} \leqslant \frac{1}{2} \]

Notice that
\[ \frac{1}{2} = \frac{x}{2x + 4y} + \frac{y}{x + 2y} \]

Thus, (42) is equivalent to
\[ \begin{aligned}
\frac{z}{1 + z + 3x} & \leqslant \left( \frac{x}{2x + 4y} - \frac{x}{1 + x + 3y} \right) + \left( \frac{y}{x + 2y} - \frac{y}{1 + y + 3z} \right) \\
& = \frac{z}{2x + 4y} \left( \frac{x}{1 + x + 3y} + \frac{8y}{1 + y + 3z} \right) \\
& \frac{2x + 4y}{1 + z + 3x} \leqslant \frac{x}{1 + x + 3y} + \frac{8y}{1 + y + 3z}
\end{aligned} \]

By the Cauchy-Schwarz inequality, we have
\[ \begin{aligned}
\frac{x}{1 + x + 3y} + \frac{8y}{1 + y + 3z} & = \frac{x^2}{x(1 + x + 3y)} + \frac{(2y)^2}{y(1 + y + 3z) / 2} \\
& \geqslant \frac{(x + 2y)^2}{(x + x^2 + 3xy) + (y + y^2 + 3yz) / 2} \\
& = \frac{2x + 4y}{1 + z + 3x},
\end{aligned} \]