# Undefined case in Lagrangian method

I am trying to finding the minimum distance between the point $(1,1,0)$ and points on the sphere $$x^2+y^2+z^2-2x-4y=4.$$

An easy way to do this is to graphical intuition and get the distance, since the point is inside the sphere.

However, can the answer be obtained using Lagrangian multipliers? I keep getting undefined answers and I do not know how to resolve it.

So, I do

\begin{align} &\min\limits_{x,y,z} & f(x,y,z)&=(x-1)^2+(y-1)^2+z^2\\ &\text{subject to}&g(x,y,z)&=x^2+y^2+z^2-2x-4y=4. \end{align}

$\vec\nabla f=<2x,2y,2z>$

$\vec\nabla g=<2x-2,2y-4,2z>$

$\therefore \vec\nabla f=\lambda \vec\nabla g$

$2x=\lambda (2x-2) \\ 2y=\lambda (2y-4) \\ 2z=\lambda (2z)$

From this I get $\lambda=1$, and I have no idea where to go from that point. Please help!

hint: $\lambda \neq 1$ since if it were you would get $2x=2x-2$ would be absurd. Thus the last equation implies $z = 0$, and the first two equations give: $\dfrac{2x}{2x-2} = \dfrac{2y}{2y-4}$. Can you solve for $x,y,z$ using the two new equations, and the constraint?
• so I solve for $x$ and $y$, and let $z=0$, then plug those into $g(x,y,x)$, is this right? But I keep getting ugly answers for $\lambda$.. – user223022 Mar 23 '15 at 18:23
• $x=\frac {\lambda}{\lambda-1} y=\frac {2 \lambda}{\lambda-1}$ Thus, $$(\frac {\lambda}{\lambda-1})^2+(\frac {2 \lambda}{\lambda-1})^2 + 0 -2 \frac {\lambda}{\lambda-1}-4 \frac {\lambda}{\lambda-1} = 4$$ From this I get $\lambda = 1 \pm \frac {\sqrt5}{3}$, which is not really the answer. – user223022 Mar 23 '15 at 18:33