Find a point on the line: $y=2x-5$ that is the closest to $P(1,2)$ This is our line: $f(x)=2x-5$
I have to find a point on this line that is the closest to the point $P(1,2)$. How do I go on about solving this? Should I use derivative and distance from the point to the line? I've done this so far:
$d\to$ distance between $P(1,2)$ and $f(x)$
$d= \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$
But how do I get the $x_2,y_2 $ from $f(x)$?

Analytic solution. Points on the line have coordinates $(x,2x-5)$; minimizing the distance is the same as minimizing the square of the distance, so we can consider
$$
g(x)=(x-1)^2+((2x-5)-2)^2=5x^2-30x+50=5(x^2-6x+10)=5((x-3)^2+1)
$$
The minimum is for $x=3$, which gives the point $(3,1)$.
If you don't see the square in the expression, you can use the derivative:
$$
g'(x)=5(2x-6)
$$
which vanishes for $x=3$.
