# Mistake in my NLP using Lagrange Multipliers?

I have the following NLP

\begin{matrix}\text{Minimize:} &x^2+y^2+z^2 \\ \text{Subject To:} & x+2y+z-1=0 \\ &2x -y -3z-4=0\end{matrix}

I need to solve this using the Lagrange Multiplier Method.

My attempt:

$$L(x,y,z,\lambda_1, \lambda_2) = x^2+y^2 +z^2 +\lambda_1(x+y+z-1) + \lambda_2(2x -y-3z-4)$$

Now we need to solve the following system of equations \begin{align}\nabla L(x,y,z,\lambda_1,\lambda_2) &= \bar{0} \\\therefore\begin{bmatrix}2x+\lambda_1 + 2\lambda_2 \\ 2y+2\lambda_1-\lambda_2 \\2z+\lambda_1-3\lambda_2 \\ x +2y+z-1 \\ 2x-y-3z-4\end{bmatrix}&=\begin{bmatrix}0\\0\\0\\0\\0\end{bmatrix}\end{align}

Now, I know that you can use matrix methods in order to solve this, but I tried to do it manually as follows:

From the first three lines we get \begin{align}x &=\frac{-\lambda_1-2\lambda_2}{2} \\ y &= \frac{-2\lambda_1 + \lambda_2}{2}\\ z &=\frac{-\lambda_1 + 3\lambda_2}{2}\end{align}

Now substituting this into the fourth equation \begin{align}\bigg(\frac{-\lambda_1-2\lambda_2}{2}\bigg)+2\bigg(\frac{-2\lambda_1 + \lambda_2}{2}\bigg) + \bigg(\frac{-\lambda_1 + 3\lambda_2}{2}\bigg)-1 &=0 \\ \therefore -6\lambda_1 + 3\lambda_2 -2 &=0 \\ \therefore \lambda_2 &= \frac{2+6\lambda_1}{3}\end{align}

Substituting $x,y,z$ into our fifth equation gives \begin{align}2\bigg(\frac{-\lambda_1-2\lambda_2}{2}\bigg) - \bigg(\frac{-2\lambda_1 + \lambda_2}{2}\bigg) -3\bigg(\frac{-\lambda_1 + 3\lambda_2}{2}\bigg) -4 &=0 \\ \therefore 6\lambda_1 -23\lambda_2 -8 &=0\end{align} Substituting for $\lambda_2$ as calculated earlier this becomes \begin{align}-40\lambda_1 - \frac{70}{3} &=0 \\ \therefore \lambda_1 &= -\frac{7}{12}\end{align} Hence we also get that $$\lambda_2 = -\frac{1}{2}$$

Which we can then use to get our final answers of $$(x,y,z)= \bigg(\frac{19}{24},\frac{1}{3},-\frac{11}{24}\bigg)$$

However, the problem is, when I substitute these values back into my original constraints, the first one is satisfied perfectly, however, the second equality contraint fails to hold. I cannot seem to think where I went wrong?

• don't know. Note that there will be just one critical point along the line (intersection of two given planes), and there $x^2 + y^2 + z^2$ will be at a minimum rather than maximum. There is no upper bound, no maximum. – Will Jagy Nov 1 '15 at 23:49
• @WillJagy - My apologies. It's supposed to be Minimize – user860374 Nov 1 '15 at 23:50
• @WillJagy's point is a very good one: I would find the equation for the line of the intersection of the planes to express two of $x, y, z$ in terms of the third. Then reduce $x^2 + y^2 + z^2$ into an equation in one variable. – Simon S Nov 1 '15 at 23:54
• @SimonS - I know that will be a much easier method. I'm preparing for my exam and working through old exam papers. In the paper the question specifically asks to use Lagrange Multiplier Method :( – user860374 Nov 1 '15 at 23:55
• I see. Well, there's cheating and there's cheating. If you take the last two linear equations from your expression for $\nabla L = 0$, you can get to the same place by solving for $\lambda_1, \lambda_2$ in terms of one of $x,y,z$. – Simon S Nov 1 '15 at 23:56

The right values (solving the system by row reduction) are $$x=\frac{16}{15},\ y=\frac13\, z=-\frac{11}{15},\ \lambda_1=-\frac{52}{75},\ \lambda_2=-\frac{18}{25}.$$
Plugging the values you can check that you made a mistake in your second equation for the lambdas. It should have been $$3\lambda_1-14\lambda_2-8=0.$$