# Lagrange Multipliers

1. Nov 5, 2013

### Differentiate1

I'm stuck on this problem for the past hour. I've tried solving for all variables and none of the steps I'm doing are getting me to the right answer.

Find the point on sphere x^2+y^2+z^2=25 farthest from point (1,1,-1).

My steps:
http://i.imgur.com/c5kUj9g.png

y= -5/sqrt(3)
z= 5/sqrt(3)

EDIT: On the part where I set negative lambda equal to "...", I made x=y to make solving for "z" easier since x and y are symmetrical.

2. Nov 5, 2013

### Dick

I would solve for x, y and z in terms of λ. You should be able to show x=1/(1+λ) and y=1/(1+λ) so x=y (that's the symmetrical part). But you are making an algebraic mistake with z. What is z in terms of λ? How is z related to x and y? And remember solving x^2=c gives you two solutions. Try it again.

3. Nov 5, 2013

### Ray Vickson

I agree, but I would urge the OP to solve for λ, from an equation of the form λ^2 = K (for some computable K > 0). There is, of course, a sign ambiguity in λ itself, but the same choices are made for all three of x, y and z (rather than making a separate choice for each equation x^2 = u, y^2 = v and z^2 = w). Furthermore, one of the λ roots is for the maximization problem and the other is for the minimization problem.

4. Nov 5, 2013

### Dick

There's more than one way to skin a cat. There's often a degree of cleverness involved in seeing an easy way to solve the Lagrange multiplier equations. I don't think in this case solving for λ is best. But it's just taste.

5. Nov 5, 2013

### Ray Vickson

But, is that not what you suggested in your first reply, when you suggested he solve for x, y and z in terms of λ?

6. Nov 5, 2013

### Dick

Well, no. Why do you say that? Maybe I'm missing what you mean by 'solve for λ'. The OP already knows x=y from a symmetry in the equations. They are related to z in a similar sort of way. Solve for the variables in terms of λ. Not solve for λ, which is I thought what you were indicating would be a better idea. That's what I was suggesting. No real need to know λ.

Last edited: Nov 6, 2013
7. Nov 6, 2013

### Ray Vickson

Well, I said that because you wrote "I would solve for x, y and z in terms of λ." I agree, and then I would just plug in x(λ), y(λ) and z(λ) in the constraint to get an equation for λ. Solving that gives two roots (corresponding to two square roots); one gives the maximizing solution and the other the minimizing solution, although that is not 100% apparent without some further checking.

Of course you can do it in another way, but if the OP wants to learn about Lagrange multipliers then showing him one of the ways seems appropriate. I showed him one way, you showed him another. It won't harm him to see both.

8. Nov 6, 2013

### HallsofIvy

Staff Emeritus
We want to minimize the distance to (1, 1, -1), $\sqrt{(x- 1)^2+ (y- 1)^2+ (z+ 1)^2}$, which is the same as minizing the distance squared, $f(x, y, z)= (x- 1)^2+ (y- 1)^2+ (z+ 1)^2$, with the constraint $g(x, y, z)= x^2+ y^2+ z^2= 25$.

We have $\nabla f= 2(x- 1)\vec{i}+ 2(y- 1)\vec{j}+ 2(z+ 1)\vec{k}$ and $\nabla g= 2x\vec{i}+ 2y\vec{j}+ 2z\vec{k}$ and we want $\nabla f= \lambda\nabla g$ for some "multiplier" $\lambda$. Setting corresponding components equal, we have
$2(x- 1)= 2\lambda x$
$2(y- 1)= 2\lambda y$ and
$2(z+ 1)= 2\lambda z$

I find it is often simplest to eliminate $\lambda$ by dividing one equation by another.
That is, $\dfrac{x- 1}{y- 1}= \dfrac{x}{y}$ and $\dfrac{x- 1}{z+ 1}= \dfrac{x}{z}$.

Then (x- 1)y= x(y- 1) so xy- y= xy- x or y= x. (x- 1)z= x(z+ 1) so xz- z= xz+ x or z= -x.

Setting y= x and z= -x in the constraint $x^2+ y^2+ z^2= 25$ we have $3x^2= 25$.
We can solve for two values of (x, y, z) from that. One gives the point of shortest distance, the other the point of longest distance.

Of course, the easy way to do this is to note that since $x^2+ y^2+ z^2= 25$ is a sphere with center at the origin, the shortest and longest distances from (1, 1, -1) to that sphere lie on the line through the center, (0, 0, 0), and (1, 1, -1). Determine where x= t, y= t, z= -t cross the sphere.

Last edited: Nov 6, 2013
9. Nov 6, 2013

### Ray Vickson

If we look at the Lagrange equations $(\lambda-1) x = 1,$ etc., we see that we must have $\lambda \neq 1$. Therefore, we can divide by $\lambda - 1$ to get $x=v, y=v, z=-v$, where $v = 1/(\lambda-1)$. The constraint gives $3v^2 = 25$, so $v = \pm 5/\sqrt{3}$, etc.