# How do I minimize the distance between the origin and a sphere using Lagrange multipliers?

The question is: Using Lagrange multipliers, which point on the sphere, $$x^2+y^2+(z-4)^2=1$$, is closest to the origin, $$(0,0,0)$$?

I decided to minimize the distance function squared: $$f(x,y,z)=x^2+y^2+z^2$$

I determined the constraint to be $$g(x,y,z)=x^2+y^2+(z-4)^2-1=0$$ I found that $$\nabla f = 2x\hat{i} + 2y\hat{j}+ 2z\hat{k}$$ $$\nabla g = 2x\hat{i} + 2y\hat{j}+ 2(z-4)\hat{k}$$ Plugging these into $$\nabla f=\lambda\nabla g$$, I found these relationships: $$2x=2\lambda x$$ $$2y=2\lambda y$$ $$2z=2\lambda (z-4)$$

Simplifying these relationships, I get $$1=\lambda$$ $$1=\lambda$$ $$z=\lambda (z-4)$$ These relationships don't work out, since plugging $$\lambda =1$$ into $$z=\lambda z-4$$ yields $$0=-4$$ which simply isn't true.

I know conceptually that I have a sphere of radius $$1$$ that is $$4$$ units above the $$z$$-axis which means that the closest distance should be at a point where $$z=3$$. I have also entered “minimize $$f(x,y,z)=x^{2}+y^{2}+z^{2}$$ with constraint $$x^{2}+y^{2}+(z-4)^{2}-1=0$$” into WolframAlpha, and this proved my conceptualization. However, I can’t seem to figure out how to mathematically prove this. Any help is appreciated. Thank you!

 Simplifying these relationships, I get

$$1=\lambda \text{ or } x = 0$$ $$1=\lambda \text{ or } y = 0$$ $$z=\lambda (z-4)$$

• Without LM it's much more easier. – Michael Rozenberg Oct 12 '18 at 6:07
• I understand that...This was a question given by a math professor who specifically requires the use of LM – Nold Oct 12 '18 at 6:07
• Hint: Find another solution of $2x=2\lambda x$. – amd Oct 12 '18 at 6:11
• @amd Hi, how do I find another solution? – Nold Oct 12 '18 at 6:16
• Suppose $\lambda=2$. Is there some value of $x$ that satisfies the equation? – amd Oct 12 '18 at 6:17

Your simplifications are wrong. From the equality $$2x=2\lambda x$$, what you get is that $$\lambda=1$$ or that $$x=0$$. For the same reason, $$\lambda=1$$ or $$y=0$$.

• Ah ok that makes sense, but if I deduce that $x=0$ and $y=0$, how would that be useful for determining $z$? – Nold Oct 12 '18 at 6:24
• You already know that $\lambda=1$ is not a possibility. Therefore, $x=y=0$. And so $(x,y,z)=(0,0,5)$ or $(x,y,z)=(0,0,3)$. Which of these points is closest to the origin? – José Carlos Santos Oct 12 '18 at 6:35
• Thanks! In my head I was thinking that I have to use the last relationship, but that's totally not the case. – Nold Oct 12 '18 at 6:38

Alternative solution:

In spherical coordinates around the origin $$(0,0,4)$$, you minimize

$$\sqrt{\cos^2\phi\sin^2\theta+\sin^2\phi\sin^2\theta+(\cos\theta+4)^2}=\sqrt{8\cos\theta+17}.$$

The minimum is $$3$$ (and the maximum $$5$$).

You could also have avoided this confusion - indeed, Lagrange multipliers altogether - by noting that minimising $$x^2+y^2+z^2$$ subject to minimising $$x^2+y^2+z^2-8z+15=0$$ is equivalent to minimising $$8z-15$$ (or, indeed, $$z$$) subject to that constraint. Since $$x^2+y^2+(z-4)^2=1\implies (z-4)^2\le1\implies z\ge 3,$$the solution must use $$z=3$$ so $$x=y=0$$.

If $$\lambda=1$$, the last relationship would yield $$0=-4$$, so we will deduce $$x=0$$ and $$y=0$$ instead. Since we don't know what lambda is, we will have to use the constraint to solve for z.
Rearraging the constraint to find z, we get $$z=\sqrt{1-x^2-y^2}+4$$ Plugging in $$x=0$$ and $$y=0$$, we get $$z=\pm\sqrt{1}+4$$ $$z=3,5$$ So, the possible solutions are $$(0,0,3) \text{ or } (0,0,5)$$ $$(0,0,3)$$ is correct since it is closest to the origin.

• Thank you everyone for helping me out here! – Nold Oct 12 '18 at 6:46