How to minimize the distance between the origin and a sphere using Lagrange multipliers

lagrange multiplieroptimization

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!

[Edit]
Simplifying these relationships, I get

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

Best Answer

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$.

Related Question