<s>[INST] Maximize $z$ over $x + y + z = 3$ and $x^2 + y^2 + z^2 = 6$ Suppose that $x$, $y$, and $z$ are real numbers such that $x + y + z = 3$ and $x^2 + y^2 + z^2 = 6$. What is the largest possible value of $z$?

I tried applying Cauchy-Schwarz to get $(x^2+y^2+z^2)(1+1+1)\geq (x+y+z)^2$, but this doesn't say anything. I also tried some different ways to apply Cauchy, but they all didn't do much.
Thanks in advance!!
 [/INST] Define $r = [x,y,z]^T$, then your objective function using Lagrange multipliers is
$ f(r,\lambda_1, \lambda_2) = c^T r + \lambda_1 (b^T r - 3) + \lambda_2 (r^T r - 6) $
where $c = [0, 0, 1]^T , b = [1, 1, 1]^T $
Differentiating, and equating to zero:
$\nabla_r f = c + \lambda_1 b + 2 \lambda_2 r = 0 \hspace{15pt}(1) $
$f_{\lambda_1} = b^T r - 3  = 0 \hspace{15pt}(2)$
$f_{\lambda_2} = r^T r - 6 = 0 \hspace{15pt}(3)$
From $(1)$ it follows that
$r = -\dfrac{1}{2 \lambda_2} (c + \lambda_1 b ) \hspace{15pt}(4) $
Plugging this into $(2)$ and $(3)$ results in
$  ( b^T c + \lambda_1 b^T b ) + 6 \lambda_2 = 0 \hspace{15pt}(5)$
and
$ ( c + \lambda_1 b)^T (c + \lambda_1 b) = 24 \lambda_2^2 \hspace{15pt} (6)$
Plugging in the values of vectors $c$ and $b$, we get
$ 1 + 3 \lambda_1 + 6 \lambda_2  = 0 \hspace{15pt} (7)$
and
$ 1 + 2 \lambda_1 + 3 \lambda_1^2 = 24 \lambda_2^2 \hspace{15pt}(8) $
Substituting for $\lambda_2$ from $(7)$ into $(8)$
$ 1 + 2 \lambda_1 + 3 \lambda_1^2 = 24 \left( \dfrac{-1 - 3 \lambda_1 }{ 6} \right)^2 \hspace{15pt}(9) $
Aftern simplifying, this becomes
$ 9 \lambda_1^2 + 6 \lambda_1 - 1= 0 $
Therefore, solutions for $\lambda_1, \lambda_2 $ are
$ (\lambda_1, \lambda_2) = ( \dfrac{ - 1-  \sqrt{2} }{3} , \dfrac{\sqrt{2}}{6} ) , ( \dfrac{ -1 + \sqrt{2}}{3}, - \dfrac{\sqrt{2}}{6} ) $
The corresponding value for $z$ for the first solution can be computed from equation $(4)$
$r = -\dfrac{1}{2 \lambda_2} (c + \lambda_1 b ) \hspace{15pt}(4) $
$ z_1 = - \dfrac{3}{\sqrt{2}} ( 1 + \dfrac{-1 - \sqrt{2}}{3} ) =1 -  \sqrt{2} $
And for the second solution
$ z_2 =  \dfrac{3}{\sqrt{2}} ( 1 + \dfrac{-1 + \sqrt{2}}{3} ) = 1 + \sqrt{2}$
Hence, the maximum is $z_2$.
</s>