<s>[INST] 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
 [/INST] 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.
</s>