Finding Closest Points on a Submanifold to another Given Point I was given the equations \begin{align*}
x^2+y^2+z^2&=2 \\
y^2+z^2+w^2&=3
\end{align*} and asked to show that that they define a compact submanifold on $\mathbb{R}^4$. I've completed that, but now I'm asked to find the points of $M$ that are closest to the point $(x,y,z,w)=(0,\sqrt{2},\sqrt{2},0)$, and I have no clue how to do it.
A guess would be to do this using Lagrange multipliers subject to the constraint $g(x,y,z,y)=\sqrt{x^2+y^2+z^2+w^2}$, but again I'm not sure.
Help is appreciated.
 A: This can actually be done using the distance function
$$
d^2(x,y,z,w) \;\; =\;\; x^2 + \left (y-\sqrt{2}\right )^2 + \left (z - \sqrt{2}\right )^2 + w^2.
$$
Now, for whatever reason the method of Lagrange multipliers doesn't seem to work if we use the constraints given in the prompt, though we can reformulate them to come up with another constraint.  If we can solve $y^2 + z^2 = 2-x^2$ and plug this into the other equation we get the constraint
$$
w^2 - x^2 \;\; =\;\; 1.
$$
While I can't speak as to why using the original two constraints won't work here, they will work for the constraint given above and one of the original two.  Let's take $f(x,y,z,w) = w^2-x^2-1$ and $g(x,y,z,w) = x^2  +y^2 + z^2 - 2$ and use the minimization problem on the following Lagrangian:
$$
L(x,y,z,w) \;\; =\;\; d^2(x,y,z,w) + \lambda\left (w^2-x^2-1 \right ) + \mu\left (x^2+y^2+z^2-2 \right ).
$$
Solving for our gradients:
\begin{eqnarray*}
2x & = & -2\lambda x + 2\mu x \\
2\left (y-\sqrt{2}\right ) & = & 2\mu y \\
2\left (z-\sqrt{2}\right ) & = & 2\mu z \\
2w & = & 2\lambda w.
\end{eqnarray*}
Taking the ratio of the second and third equations we can uncover that $y=z$.  The last equation gives us that $\lambda=1$.  We can plug this into our first equation and find out that $2x = \mu x$.  Rather than solving for $\mu$ we can take the ratio of this equation and the second equation to find
$$
\frac{2x}{y-\sqrt{2}} \;\; =\;\; \frac{x}{y} \hspace{2pc} \Longrightarrow \hspace{2pc}x\left (y+\sqrt{2}\right ) \;\; =\;\; 0.
$$
This last equation tells us that either $y = z = -\sqrt{2}$ or that $x=0$.  Now if $y=z=-\sqrt{2}$, then this will not satisfy our original constraints defining our manifold, so we have to discard these as a possibility.  Taking $x=0$, we find that $w^2 =  1$ and $w = \pm 1$.  This tells us that 
$$
x^2 + y^2 + z^2 = 2\hspace{2pc} \Longrightarrow \hspace{2pc} 2y^2 = 2
$$
thus $y = \pm1$ and $z=\pm1$.  This gives us all of our possibilities for points on the manifold that will work, namely the eight possibilities $(0,\pm1,\pm1,\pm1)$.  To minimize the distance given above we want to take $y=z=1$, but this leaves our value for $w$ ambiguous.  We therefore conclude there are two minimizing points:
$$
(0,1,1,1) \hspace{2pc}\text{and} \hspace{2pc} (0,1,1,-1).
$$
