How to find a point on a line closest to another given point?

One point on the line is $(-2, -4, 5)$ and another is $(0,0,1)$ (found by setting the equation to 0, then to 2). So the general point is $(-2t, -4t, 1+4t)$. You want the dot product of the vector from a point on the line to $(1, 1, 1)$ and a vector along the line to be zero. So $$(-2, -4, 4)\cdot(-2t-1, -4t-1, 4t)=0$$ $$4t+2+16t+4+16t=0$$ $$t=\frac{-1}{6}$$ And the point is $$\left(\frac{1}{3},\frac{2}{3},\frac{1}{3}\right)$$


One method is to parametrize the line. So $$\vec{r}(t) = (t-2)\hat{\imath} + (2t-4)\hat{\jmath} + (-2t+5)\hat{k}$$ We can then define the real-valued function $d(t)$ representing the distance from the line to $(1,1,1)$ for any value of $t$. Hence $$d(t) = \sqrt{(t-3)^2 + (2t-5)^2 + (-2t+4)^2} = \sqrt{9t^2 - 42t + 40}$$ To find the minimum, it's now only a single variable optimization problem. So by standard procedure, look at $d'(t)$ $$d'(t) = \frac{9t - 21}{\sqrt{9t^2 - 42t + 40}}$$ The critical point occurs at $t = \frac{7}{3}$, so the closest point is $\vec{r}(\frac{7}{3}) = (\frac{1}{3},\frac{2}{3},\frac{1}{3})$.


Using multi-variable calculus you would write a formula for distance from the point (1,1,1) to the arbitrary point (x,y,z) (this second points needs to satisfy your equation since it lies on the line). You would then apply the multi-variable optimization procedure: Find the critical points of this functions (those points where both partial derivatives equal zero or those points where either partial derivative is undefined) and examine these to find the minimum value for distance.

If you do want to use linear algebra, a vector from the point (x,y,z) (on the line) to the point (1,1,1) is $<1-x,1-y,1-z>$ Now take a directional vector from your line and compute the dot product of this with $<1-x,1-y,1-z>$. As you said, this dot product should be zero so solve for x,y, and z.