# Finding the extreme values of $f(x,y,z)=x^2+y^2+z^2$ constraint to $x^2+y^2+z^2+xy=12$

$$f(x,y,z)=x^2+y^2+z^2$$ constraint to $$x^2+y^2+z^2+xy=12$$

So I have made 4 equations using Lagrange Multipliers,

$$2x=\lambda(2x+y)$$ , $$2y=\lambda(2y+x)$$ , $$2z=\lambda(2z)$$ , and $$x^2+y^2+z^2+xy=12$$

The third equation is $$2z=2z\lambda$$ which ends up with $$z=0$$ or $$\lambda=1$$

With $$z=0$$ put in the constraint equation, I get $$x= \pm 2$$ and a minimum of $$f(\pm 2,\pm 2,0)=8$$

and with $$\lambda=1$$ put in the $$F_x=\lambda G_x$$ and $$F_y=\lambda G_y$$, I get $$x,y=0$$ and from the constraint equation I get $$z=\pm\sqrt{12}$$

which gives the max at $$f(0,0,\pm\sqrt{12})=12$$

which is incorrect and the answer was $$24$$ and I do not know of what mistakes I did.

• The equations aren't correct Mar 26, 2023 at 12:06
• @MathStackexchangeIsNotSoBad The four equations are correct. The problem is when solving the case $z=0$. Mar 26, 2023 at 12:07
• The calculations can be slightly simplified if we consider $f(x,y,z)=12-xy$ under condition $x^2+y^2+z^2+xy=12.$ Mar 26, 2023 at 12:28

You can avoid any complicated inequalities or Lagrange multipliers by diagonalizing the constraint: $$g(x,y,z) = x^2+xy+y^2+z^2$$ can be written as $$\frac{1}{4}(x-y)^2+\frac{3}{4}(x+y)^2+z^2$$. Thus setting $$a = (x-y)/\sqrt{2}, b=(x+y)/\sqrt{2}$$ and $$c=z$$, this becomes the problem of finding the extreme values of $$a^2+b^2+c^2$$ subject to $$\frac{1}{2}a^2 + \frac{3}{2}b^2 +c^2 = 12$$. But for all $$(a,b,c) \in \mathbb R^3$$ $$\frac{1}{2}(a^2+b^2+c^2) \leq \frac{1}{2}a^2 + \frac{3}{2} b^2 + c^2 \leq \frac{3}{2}(a^2+b^2+c^2),$$ hence if $$\frac{1}{2}a^2 + \frac{3}{2}b^2 +c^2 = 12$$ then $$8\leq a^2+b^2+c^2 \leq 24$$, with equality if and only if $$(a,b,c) = \pm(0,2\sqrt{2},0)$$, respectively $$(a,b,c) = \pm(2\sqrt{6},0,0)$$.

Converting back to the original coordinate system, this gives the maximum value at $$\pm (2\sqrt{3},-2\sqrt{3},0)$$ and a minimum value at $$\pm (2,2,0)$$

The stationary points according to Lagrange, are the tangent points between the ellipsoid

$$x^2+y^2+z^2+x y =12$$

and the family of spheres given by

$$x^2+y^2+z^2 = r^2$$

so the stationary points are

$$\left[ \begin{array}{ccccc} r^2& x & y & z & \lambda\\ 8 & -2 & -2 & 0 & -\frac{2}{3} \\ 8 & 2 & 2 & 0 & -\frac{2}{3} \\ 12 & 0 & 0 & -2 \sqrt{3} & -1 \\ 12 & 0 & 0 & 2 \sqrt{3} & -1 \\ 24 & -2 \sqrt{3} & 2 \sqrt{3} & 0 & -2 \\ 24 & 2 \sqrt{3} & -2 \sqrt{3} & 0 & -2 \\ \end{array} \right]$$

If $$z=0$$, then your system becomes$$\left\{\begin{array}{l}2x=\lambda(2x+y)\\2y=\lambda(2y+x)\\x^2+y^2+xy=12.\end{array}\right.\label{a}\tag1$$The system which consists of the first two equations is equivalent to$$\left\{\begin{array}{l}(2-2\lambda)x-\lambda y=0\\-\lambda x+(2-2\lambda)y=0.\end{array}\right.\label{b}\tag2$$If the determinant of the matrix of the coefficients of the system \eqref{b} turns out to be different from $$0$$, then the system has one and only one solution, which is $$x=y=0$$, but there is no such solution of the system \eqref{a}.

The determinant mentioned above is $$3\lambda^2-8\lambda+4$$ which is equal to $$0$$ if and only if $$\lambda=2$$ or $$\lambda=\frac23$$. If $$\lambda=2$$, then the system \eqref{b} becomes equivalent to $$x+y=0$$, and the solutions of the system$$\left\{\begin{array}{l}x+y=0\\x^2+y^2+xy=12\end{array}\right.$$are $$\pm\left(2\sqrt3,-2\sqrt3\right)$$, which you have missed. And $$f\left(\pm2\sqrt3,\mp2\sqrt3\right)=24$$.

And if $$\lambda=\frac23$$, then the system \eqref{b} is equivalent to $$x-y=0$$, and the solutions of the system$$\left\{\begin{array}{l}x-y=0\\x^2+y^2+xy=12\end{array}\right.$$are $$\pm\left(2,2\right)$$, which you have found.

• Did you mean ”turns out to be different from $0$"? Mar 26, 2023 at 12:09
• @jjagmath Yes. I have edited my answer. Thank you. Mar 26, 2023 at 12:10

This particular problem does not require the Lagrange multipiers method.

Observe that $$f(x,y,z)=12-xy.$$ Thus the task can be reduced to the two variables problem, namely $$g(x,y)=12-xy,\quad x^2+y^2\le 12 -xy$$ Denote $$r=\sqrt{x^2+y^2}.$$ For fixed $$r$$ the largest value of $$g(x,y)=12-xy$$ is attained for $$y=-x.$$ In that case we are reduced to finding the maximal value of $$12+{r^2\over 2}\ \ {\rm under\ condition}\ r^2\le 12+{r^2\over 2},\ \ {\rm i.e.}\ r^2\le 24$$ Clearly the maximal value $$24$$ is attained when $$r^2=24$$ Therefore the maximal value of $$g(x,y)$$ is attained, when $$y=-x$$ and $$x^2+y^2=24.$$ Thus at $$\left (\pm 2\sqrt{3},\mp 2\sqrt{3}\right ).$$ Now we can go back to the original problem and determine that $$z=0.$$

Concerning the minimal value of $$g(x,y),$$ we can repeat similar steps to obtain that for fixed $$r$$ the minimal value $$8$$ is attained for $$x=y=\pm 2,$$ $$z=0.$$