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.

Writing the root-mean square inequality in the form $\;\displaystyle\frac{a^2+b^2}{2} \ge \left(\frac{a+b}{2}\right)^2\;$ which holds for all $\,a,b \in \mathbb{R}\,$ regardless of signs, and using that the largest of $\,x,y,z\,$ must be $\,z \gt 0\,$:
$$
\begin{alignat*}{3}
\frac{x^2+y^2}{2} \ge \left(\frac{x+y}{2}\right)^2 \;\;&\iff\;\; \frac{32-z^2}{2} \ge \left(\frac{8-z}{2}\right)^2 \;\;&&\iff\;\; 2(32-z^2) \ge (8-z)^2 \\
 &\iff\;\; z(16-3z) \ge 0 \;\;&&\iff\;\; z \le \frac{16}{3}
\end{alignat*}
$$
The equality case $\,z = \dfrac{16}{3}\,$ is attained for $\,x = y\,$.
