Find point on a line that is nearest to the origin Can you help me with this exercise?

Find the nearest point to the origin $(0,0,0)$ in the line given by the intersection of planes $x+y+z=2$ and $12x+3y+3z=12$.

The intersection of the planes is the line : $x=2/3$, $3y+3z=4$. 
So I restrict the function $f(x,y,z)=x^2+y^2+z^2$ to the set $A=\{x=2/3, 3y+3z=4\}$. Let $g(y,z)=f(2/3,y,z)=4/9+y^2+z^2$. 
So the problem is equivalent to find the maximum of $g(y,z)=4/9+y^2+z^2$ restricted to $h(y,z)=3y+3z-4=0$. Using Lagrange multipliers, I get
$(2y,2z)=\lambda(3,3)$, 
$3y+3z=4$
By the first equation I get $y=z$, then in the second I get $6y=4$, so $y=2/3$, therefore $z=2/3$. This is why I get $x=y=z=2/3$. 
Is it better now? 
Thanks
 A: $\newcommand{\angles}[1]{\left\langle\,{#1}\,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\Li}[1]{\,\mathrm{Li}_{#1}}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

Lets
  $$
\vec{r} \equiv \pars{x,y,z}\,,\quad
\vec{a} \equiv \pars{1,1,1}\,,\quad
\vec{b} \equiv \pars{4,1,1}\,,\quad 
\mbox{Note that}\ \vec{r}\cdot\vec{a} = 2\ \mbox{and}\ \vec{r}\cdot\vec{b} = 4
$$

'Lagrange': $\ds{\half\,\vec{r}\cdot\vec{r} - \mu\vec{r}\cdot\vec{a} - \nu\vec{r}\cdot\vec{b}}$:
\begin{align}
&\vec{r} - \mu\vec{a} - \nu\vec{b} = 0\quad\imp\quad
\mu\vec{a} + \nu\vec{b} = \vec{r}\quad\imp\quad
\left\lbrace\begin{array}{rcrcl}
\ds{a^{2}\,\mu} & \ds{+} & \ds{\vec{a}\cdot\vec{b}\,\nu} & \ds{=} & \ds{2}
\\
\ds{\vec{a}\cdot\vec{b}\,\mu} & \ds{+} & \ds{b^{2}\,\nu} & \ds{=} & \ds{4} 
\end{array}\right.
\\[4mm] &\
\imp\quad\left.\begin{array}{rcrcl}
\ds{3\mu} & \ds{+} & \ds{6\nu} & \ds{=} & \ds{2}
\\
\ds{3\mu} & \ds{+} & \ds{9\nu} & \ds{=} & \ds{2} 
\end{array}\right\rbrace\quad\imp\quad \mu = {2 \over 3}\,,\quad\nu = 0
\end{align}

$$
\vec{r} = \mu\vec{a} = {2 \over 3}\pars{1,1,1} = \pars{{2 \over 3},{2 \over 3},{2 \over 3}}\quad\imp
\color{#f00}{x} = \color{#f00}{y} = \color{#f00}{z} = \color{#f00}{2 \over 3}
$$
A: This is an instance of the least-norm problem
$$\begin{array}{ll} \text{minimize} & \| {\bf x} \|_2^2\\ \text{subject to} & {\bf A} {\bf x} = {\bf b} \end{array}$$
As $2 \times 3$ matrix $\bf A$ has full row rank, the least-norm solution is
$$ {\bf x}_{\text{LN}} := {\bf A}^\top \left( {\bf A} {\bf A}^\top \right)^{-1} {\bf b} $$
In SymPy:
>>> A = Matrix([[1, 1, 1], [12, 3, 3]])
>>> A
⎡1   1  1⎤
⎢        ⎥
⎣12  3  3⎦
>>> b = Matrix([2, 12])
>>> b
⎡2 ⎤
⎢  ⎥
⎣12⎦
>>> x_LN = A.T * (A * A.T)**-1 * b
>>> x_LN
⎡2/3⎤
⎢   ⎥
⎢2/3⎥
⎢   ⎥
⎣2/3⎦


Appendix
We can use Lagrange multipliers to find the least-norm solution. We define the Lagrangian
$$\mathcal{L} ({\bf x}, {\bf \lambda}) := \frac 12 {\bf x}^\top {\bf x} - {\bf \lambda}^\top ({\bf A} {\bf x} - {\bf b})$$
Taking the partial derivatives and finding where they vanish, we obtain
$$ {\bf x} = {\bf A}^\top {\bf \lambda}, \qquad \qquad {\bf A} {\bf x} = {\bf b} $$
from which it is easy to compute the least-norm solution, assuming that $\bf A$ has full row rank (so that $\bf A \bf A^\top$ is invertible).
A: You could even solve the problem using basic calculus since minimizing the distance is the same as minimizing the square of the distance. 
The constraints being $$x+y+z=2\qquad , \qquad 12x+3y+3z=12$$ take advantage of their linearity and solve these two equations for $x$ and $z$ as functions of $y$. Tou will get $x=\frac 23$ and $z=\frac 43-y$.
So $$d^2=x^2+y^2+z^2=\frac{4}{9}+y^2+\left(\frac{4}{3}-y\right)^2=2 y^2-\frac{8 y}{3}+\frac{20}{9}$$ The derivative $(d^2)'=4y-\frac 83$ cancel for $y=\frac 23$ and, using $z=\frac 43-y$, $z=\frac 23$.
Then the solution $x=y=z=\frac 23$ and $d^2=\frac 43$.
Notice that the second derivative test $(d^2)''=4y$ confirms that this is a minimum.
