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!
[Edit]
Simplifying these relationships, I get
$$1=\lambda \text{ or } x = 0$$
$$1=\lambda \text{ or } y = 0$$
$$z=\lambda (z-4)$$
 A: 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$.
A: 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$).
A: 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.
A: 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$.
