Lagrange Multipliers to determine min and max I've got this question in a book of questions I'm doing.
Can someone show me step by step how to solve this? 

Using Lagrange Multipliers for two constraints, determine the maximum and minimum of the function 
  $f(x,y,z) = 3x^2 + y^2 + 3z^2$ subject to the constraints $x^2 + y^2 + z^2 = 6$ and $x - y + z = 0 $.

 A: We have three functions:


*

*$f=3x^2+y^2+3z^2$ (function to be maximized/minimized)

*$g=x^2+y^2+z^2-6$ (constraint 1)

*$h=x-y+z$ (constraint 2)


Take the partial derivatives of the three functions, and make a system of equations:
$\begin{cases}f_x=g_x\lambda+h_x\mu \\ f_y=g_y\lambda+h_y\mu \\ f_z=g_z\lambda+h_z\mu \end{cases}$
Solve this system for $x$, $y$ and $z$ respectively, and plug those into the constraints.
This forms a new system of equations:
$\begin{cases}g(\text{with the found }x, y, z \text{ plugged in})=6 \\ h(\text{with the found }x, y, z \text{ plugged in})=0 \end{cases}$
Solve this system for $\lambda$ and $\mu$ and substitute those back into the original equations. This will give the coordinates of the point.
A: Let $g(x,y,z)=x^2+y^2+z^2$ and $h(x,y,z)=x-y+z$.
Setting $f_x=\lambda g_x+\mu h_x, \;\;f_y=\lambda g_y+\mu h_y, \;\;f_z=\lambda g_z+\mu h_z$ $\;\;$gives
$\;\;6x=\lambda(2x)+\mu(1)=2\lambda x+\mu$
$\;\;2y=\lambda(2y)+\mu(-1)=2\lambda y-\mu$
$\;\;6z=\lambda(2z)+\mu(1)=2\lambda z+\mu$.
Subtracting the 3rd equation from the 1st gives $6(x-z)=2\lambda(x-z)$, 
so either $\textbf{1)}\;\;\; x=z$ $\;\;$or$\;\;$ $\textbf{2)}\;\;\; \lambda=3$.
$\textbf{1)}$ If $x=z$, substituting into the constraints gives $y=2x$ and then $x^2+(2x)^2+x^2=6$.
(Now solve for $x$, find $y$ and $z$, and evaluate $f$ at these points.)
$\textbf{2)}$ $If \lambda=3$, then $\mu=0$ from the 1st equation so $2y=6y$ from the 2nd equation and therefore $y=0$;
so substituting into the constraints gives $z=-x$ and $x^2+(-x)^2=6$.
(Now solve for $x$, find $z$, and evaluate $f$ at these points.)
