[Math] Find the point on the line closest to the point given by using projections.

linear algebravectors

I have the formula and am employing it correctly (or so I thought), but I'm consistently getting the wrong point (sometimes has the same length as the correct answer, but not the same entries).

Here is an example question:

For the given point and line, find by projection the point on the line that is closest to the given point and use perp to find the distance from the point to the line.

$$Q(2,5), \text{line} \; \vec{x} =
\begin{bmatrix}
3 \\
7 \\
\end{bmatrix}
+ t
\begin{bmatrix}
1 \\
-4 \\
\end{bmatrix}
$$

Here is my work:

$$\vec{QP} =
\begin{bmatrix}
3-2 \\
7-5 \\
\end{bmatrix}
=
\begin{bmatrix}
1 \\
2 \\
\end{bmatrix}
$$

$$\vec{OR} =
\begin{bmatrix}
1 \\
2 \\
\end{bmatrix}
– \frac{-7} {17}
\begin{bmatrix}
1 \\
-4 \\
\end{bmatrix}
=
\begin{bmatrix}
24/17 \\
6/17 \\
\end{bmatrix}
$$

$$\text{Distance} = \frac{6} {\sqrt{17}} $$

So the strange thing here is that I got the correct distance but not the correct point.

Here is the formula for distance from Q to a point on the line:

$$||\vec{QP}-\text{proj}_\vec{d}\vec{QP}|| = ||\vec{QP}-\frac{\vec{QP}\cdot\vec{d}} {||\vec{d}||^2} \vec{d}||$$

The correct answer is $$R(58/17,91/17)$$ and my answer for distance is correct.

Best Answer

Apparently $ P = \begin{bmatrix} 3 \\ 7 \end{bmatrix}.$ Your formula for projection is correct; letting $\vec d = \begin{bmatrix} 1 \\ -4 \end{bmatrix},$ we have $\vec{QP} \cdot \vec d = -7$ and $\|\vec d\|^2 = 17.$ The equation that gives you $\vec{QR} = \begin{bmatrix} 24/17 \\ 6/17 \end{bmatrix}$ is correct, where $R$ is the point on the line closest to $Q.$

So you have $$\begin{bmatrix} 24/17 \\ 6/17 \end{bmatrix} = \vec{QR} = R - Q = R - \begin{bmatrix} 2 \\ 5 \end{bmatrix}.$$ So $$R = \begin{bmatrix} 2 \\ 5 \end{bmatrix} + \begin{bmatrix} 24/17 \\ 6/17 \end{bmatrix} = \begin{bmatrix} 58/17 \\ 91/17 \end{bmatrix} = \begin{bmatrix} 3 \\ 7 \end{bmatrix} - \left(-\dfrac{7}{17}\right) \begin{bmatrix} 1 \\ -4 \end{bmatrix},$$ as it should be. This matches all your calculations. So it's not clear how you have the "wrong point," unless you're doing something like using the coordinates of $\vec{QR}$ when you need to give the coordinates of $R.$