# Minimizing $x^2+y^2+z^2$ subject to $xy -z + 1 = 0$ via Lagrange multipliers

$$\begin{array}{ll} \text{minimize} & f(x,y,z) := x^2 + y^2 + z^2\\ \text{subject to} & g(x,y,z) := xy - z + 1 = 0\end{array}$$

I tried the Lagrange multipliers method and the system resulted from has no solution. So I posted it to see if the question is wrong by itself or I'm missing something.

So I made the Lagrangian equation $$L(x,y,z,λ)=x^2 + y^2 + z^2 + λ(xy -z+1)$$

and then

$$θL/θx = 2x + λy =0$$

$$θL/θy = 2y + λx =0$$

$$θL/θz = 2z - λ =0$$

$$θL/θλ = xy -z +1 =0$$

The obvious solution for that system is x=0 , y=0 , z=1 and λ=2

But solving it in an online solver for nonlinear systems of equation the answer I get is that it's unsolvable.

So my question is: What I'm doing wrong

• What did you try? What did you get stuck on? Posting a homework question without showing any effort usually doesn't get a great response here. Aug 9, 2020 at 9:27
• So, I tried the lagrange multipliers method and the system resulted from has no solution. So I posted it to see if the question is wrong by itself or I'm missing something.
– Ron
Aug 9, 2020 at 9:31
• I'll add the comment on the post so this community doesn't judge quickly :)
– Ron
Aug 9, 2020 at 9:33
• It's not clear what it means that it had no solution. Can you show your steps? Aug 9, 2020 at 9:34
• yes posting it as a comment
– Ron
Aug 9, 2020 at 9:38

$$x^2+y^2+z^2=x^2+y^2+z^2+2(xy-z+1)=(x+y)^2+(z-1)^2+1\geq1.$$ The equality occurs for $$x=y=0$$ and $$z=1$$, which says that we got a minimal value.

Since $$f$$ and $$g$$ are polynomial, using SymPy's solve_poly_system:

>>> from sympy import *
>>> x, y, z, mu = symbols('x y z mu', real=True)
>>> L = x**2 + y**2 + z**2 + mu * (x*y - z + 1)
>>> solve_poly_system([diff(L,x), diff(L,y), diff(L,z), diff(L,mu)], x, y, z, mu)
[(0, 0, 1, 2), (-sqrt(2)*I, -sqrt(2)*I, -1, -2), (sqrt(2)*I, sqrt(2)*I, -1, -2)]


Hence, the only real solution is $$(x,y,z,\mu) = (0, 0, 1, 2)$$. Not very insightful, however.

Let $$\mathcal L$$ be the Lagrangian. Computing $$\partial_x \mathcal L$$, $$\partial_y \mathcal L$$ and $$\partial_z \mathcal L$$ and finding where they vanish,

$$\begin{bmatrix} 2 & \mu & 0\\ \mu & 2 & 0\\ 0 & 0 & 2\end{bmatrix} \begin{bmatrix} x\\ y\\ z\end{bmatrix} = \begin{bmatrix} 0\\ 0\\ \mu\end{bmatrix}$$

Note that the matrix is singular when $$\mu = \pm 2$$. Hence, we have three cases to consider.

$$\color{blue}{\boxed{\mu = 2}}$$

The solution set is the line parameterized by

$$\begin{bmatrix} x\\ y\\ z\end{bmatrix} = \begin{bmatrix} t\\-t\\ 1\end{bmatrix}$$

and, since, $$xy - z + 1 = 0$$, we obtain $$t = 0$$ and $$\color{blue}{(x,y,z) = (0,0,1)}$$.

$$\color{blue}{\boxed{\mu =-2}}$$

The solution set is the line parameterized by

$$\begin{bmatrix} x\\ y\\ z\end{bmatrix} = \begin{bmatrix} t\\ t\\ -1\end{bmatrix}$$

and, since, $$xy - z + 1 = 0$$, we obtain the equation $$t^2 = -2$$, which has no solution over the reals.

$$\color{blue}{\boxed{\mu \neq \pm2}}$$

The solution set is the line parameterized by

$$\begin{bmatrix} x\\ y\\ z\end{bmatrix} = \begin{bmatrix} 0\\ 0\\ \frac{\mu}{2}\end{bmatrix}$$

and, since, $$xy - z + 1 = 0$$, we obtain $$\mu = 2$$, which contradicts the assumption.

This can be solved in at least two methods. First, let's solve without Lagrange, using convenient changes of variables. Let $$u=x+y, v=xy$$. This results in $$u^2=x^2+y^2+2xy=x^2+y^2+2v$$.

We now need to minimize $$u^2-2v+z^2$$ under the constraint $$v-z+1=0$$. We can rearrange this constraint to be of the form $$z=1+v$$ and therefore $$z^2=1+2v+v^2$$. Substituting this, we need to minimize $$u^2+v^2$$. The minimum of this is for $$u=0, v=0$$, which returns $$x=0, y=0, z=1$$.

Solving this using Lagrange:

$$L=x^2+y^2+z^2-\lambda(xy-z+1)=x^2+y^2+z^2-\lambda xy-\lambda z-\lambda$$ $$\frac{\partial L}{\partial z}=2z-\lambda\rightarrow\lambda=2z$$ $$\frac{\partial L}{\partial x}=2x-\lambda y=0\rightarrow x=\frac{\lambda y}{2}=yz$$ $$\frac{\partial L}{\partial y}=2y-\lambda x=0\rightarrow2y-2yz^2=0$$$$\rightarrow y=0, x=0\cup z=1,\lambda=2,x=y\cup z=-1,\lambda=-2,x=-y$$ We have three possible solutions to this. We will plug each into the equation for the constraint $$xy-z+1=0$$

If $$x=0, y=0$$, our constraint becomes $$-z+1=0$$, which has the solution $$x=0, y=0, z=1$$, with the value of $$x^2+y^2+z^2=1$$

If $$z=1, x=y$$, our constraint becomes $$x^2-1+1=0$$, which has the exact same solution

If $$z=-1, x=-y$$, cour constraint becomes $$-y^2+1+1=0$$, which has the solutions $$x=\pm\sqrt{2}, y=\mp\sqrt{2}, z=-1$$. The value here is $$x^2+y^2+z^2=5$$, which is not the minimum