Solution (source code)

= Solution

Minimize the squared distance $D^2=(x-x_0)^2+(y-y_0)^2$ subject to $g=y-mx-c=0$. The <Lagrange multiplier> condition $\nabla D^2=\lambda\nabla g$ gives $x=x_0-m\lambda/2$ and $y=y_0+\lambda/2$. Enforcing the line constraint gives $\lambda=2(mx_0+c-y_0)/(1+m^2)$, hence
$$
\boxed{x_*=\frac{x_0+m(y_0-c)}{1+m^2},\qquad y_*=\frac{mx_0+m^2y_0+c}{1+m^2}.}
$$
The displacement to this point is parallel to the line's <normal vector> $(-m,1)$, so it is the <orthogonal projection>. The squared distance restricted to the line has positive quadratic coefficient $1+m^2$, proving this stationary point is the unique global minimum.