Closest point on a line to another point

The problem asks to find the nearest to $P(2,2)$, on the line:

$$-x -2y +3 =0$$

This is what I've tried,

  • the normal vector,

    $$n = (-1,-2)$$

  • found an arbitrary point on the given line by setting $y = 0$, which results in

    $$P_1 = (3,0)$$

  • calculated distance from $P$ to $P_1$ (call it the vector u):

$$u = (-1,2)$$

then finally I simply applied the projection formula and got that the point on the line should be (3/5,6/5) which unfortunately is the wrong answer.

any ideas where I've gone wrong?


Here is another way to look at this, using the normal vector you've found. Call the closest point to $ \ (2,2) \ $ on the given line $ \ (x,y) \ . $ The vector from $ \ (2,2) \ $ to this point is $ \ \langle x-2 , y-2 \rangle \ . $ Since the shortest distance from an external point to a line is along a perpendicular to the line, this vector must have the same direction as the normal vector, so we may write

$$ \langle x-2 \ , \ y-2 \rangle \ = \ k \cdot \langle -1 \ , \ -2 \rangle \ . $$

From this, we can establish the relation $ \ 2 \ (x-2) = y - 2 \ . $ This is satisfied by the external point $ \ (2,2) \ $ and must also be satisfied by the point on the given line, $ \ x + 2y = 3 \ . $ Inserting our relation into this linear equation allows us to solve for one of the coordinates; the equation of the line will then also give us the other coordinate of the sought-after closest point.

In view of your comment, you can also use the direction vector of the line, $ \ \langle 2 , -1 \rangle \ $ and look for where its dot product with $ \ \langle x-2 \ , \ y-2 \rangle \ $ is zero, again under the constraint that $ \ (x,y) \ $ is on the given line.

[Incidentally, the perpendicularity requirement ("dot product equals zero") is equivalent to the condition for minimum distance given by setting the derivative of the function for the distance between the points equal to zero.]


Hint: The closest distance from point to line is on the line perpendicular to the first line through that point.

The equation you presented is

$-x - 2y + 3 = 0$

$2y = -x + 3$

$y = \frac{-1}{2}x + 1.5$

Therefore, the perpendicular line has a reciprocal, opposite slope. The opposite of -1/2 is 1/2, and the reciprocal of 1/2 is 2. Therefore, the perpendicular line you are constructing has a slope of 2.

$y = 2x + b$ where $b$ is the y intercept, $2$ is the slope.

Inputting our values of x and y, we have

$2 = 2(2) + b$

$2 = 4 + b$

$b = -2$

Therefore, the equation of our perpendicular line is $y = 2x - 2$.

By finding the solution to the system of equations $y = 2x - 2$ and $y = \frac{-x}{2} + 1.5$, you get the point of intersection of the two equations. Find this point of intersection by solving the system of equations, and use the distance formula to determine the distance between them.

see this link for a graph of the line you presented and the perpendicular line. That should give you some intuition as to why the perpendicular line is the closest distance from point to line. https://www.desmos.com/calculator/iz07az84f5