Given the function $f = x + y + z$ and conditions $g = 0 = x^2 + y^2 + z^2 -1$ and $h =x-y-z-1=0$ one can find the max/min of the function $f$ with Lagrange's method, leading to the set of equations:

$1 = 2\lambda_1x + \lambda_2$

$1 = 2\lambda_1y - \lambda_2$

$1 = 2\lambda_1z - \lambda_2$

$0 = x^2 + y^2 + z^2 - 1$

$0 = x-y-z -1$

I can solve this numerically in matlab but how (if at all possible) would you solve this analytically? There is no way I know of to set this up as $Ax = b$, there is a quadratic equation in all 3 variables and $\lambda$ is coupled with $x,y,z$.

Edit: Ty for pointing out in comments the incorrect sign.

  • 1
    $\begingroup$ OK, now divide the first three equations by $\lambda_1$, and call $1\over\lambda_1$ and $\lambda_2\over\lambda_1$ your new variables. You'll still have five equations, and all but one will be linear. Use the linear equations to exclude all but one variable, and solve the remaining quadratic equation. $\endgroup$ – Ivan Neretin Aug 31 '16 at 18:12

You have the equations

$$1 = 2\lambda_1x + \lambda_2\tag{1}$$

$$1 = 2\lambda_1y - \lambda_2\tag{2}$$

$$1 = 2\lambda_1z - \lambda_2\tag{3}$$

$$x^2 + y^2 + z^2=1\tag{4}$$


Adding $(1)$ and $(2)$ gives


Adding $(1)$ and $(3)$ gives


From these two equations we get $x+y=x+z$ so that $y=z$.

Substituting into $(5)$ and rearranging gives


Substituting this into $(4)$ gives


which has solutions $y=0$ and $y=-2/3$.

  • If $y=z=0$ then $(7)$ gives $x=1$. Equations $(6)$ and $(2)$ give $\lambda_1=1$, and $\lambda_2=-1$.
  • If $y=z=-2/3$ then $(7)$ gives $x=-1/3$. Equations $(6)$ and $(2)$ give $\lambda_1=-1$ and $\lambda_2=1/3$.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.