If $x$, $y$, and $z$ are real numbers such that $x+y+z=8$ and $x^2+y^2+z^2=32$, what is the largest possible value of $z$? I tried swapping $z$ from the first equation to the second, and got $$x^2 + x y - 8 x + y^2 - 8 y + 16=0$$ Not sure where to go from there, and if I'm on the right track at all.

\begin{align*}
x^2+(8-x-z)^2+z^2&=32\\
x^2-(8-z)x+z^2-8z+16&=0
\end{align*}
As $x$ is real,
\begin{align*}
[-(8-z)]^2-4(1)(z^2-8z+16)&\ge0\\
3z^2-16z&\le 0\\
0\le z&\le\frac{16}{3}
\end{align*}
The largest value of $z$ is $\displaystyle \frac{16}{3}$.
