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!!
 A: 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$.
A: Hint: Since you tried using CS inequality, here is a way:
$$(1+1)\cdot(x^2+y^2)\geqslant (x+y)^2 \implies 2\cdot(6-z^2)\geqslant (3-z)^2 \\ \implies 1+\sqrt2 \geqslant z \geqslant 1-\sqrt2$$
A: Here is a solution avoiding calculus.
Use cylindrical coordinates.
$x = r \cos\theta, y = r \sin\theta, z = z, r \geq 0$
From $x^2 + y^2 + z^2 = 6$, we get
$$z^2 = 6 - r^2 \tag1$$
From $x + y + z = 3$, we get
$ \displaystyle r = \frac {3-z}{\cos\theta + \sin\theta} \tag2$
From $(1), z \leq \sqrt6~$ and so we know $(3 - z)$ is positive.
As we know, $(1)$ is a sphere centered at the origin. The lower the radius of the circle parallel to xy-plane on the sphere, the higher the value of $|z|$.
From $(2)$, we see that at any given $z$, of all the circles parallel to xy-plane that intersect the plane $x + y + z = 3$, the one with minimal $r$ is one when $~(\cos \theta + \sin \theta)~$ is maximum. We know that maximum value of $~(\cos\theta + \sin\theta)~$ is $~\sqrt2~$. That leads to $~ \displaystyle r = \frac{3-z}{\sqrt2}~$. Now plugging into $(1)$ and solving should give us the maximum and minimum value of $z$.
$ \displaystyle z^2 = 6 - \frac{(3-z)^2}{2}$
Simplifying, $z^2 - 2 z - 1 = 0$
Solving, $z = 1 + \sqrt 2~$ is the maximum and $z = 1 - \sqrt 2~$ is the minimum.

To find maximum of $(\cos\theta + \sin\theta)$, we maximize $(\cos\theta + \sin\theta)^2$.
$(\cos\theta + \sin\theta)^2 = 1 + \sin2\theta \leq 2 \implies \cos\theta + \sin\theta \leq \sqrt2$. The maximum occurs at $\theta = \pi/4$.
