Finding the point on a line closest to another point not on the line I am trying to solve the following question:
Let $L$ be the line passing through the point $A(5,-6, 7)$ parallel to the x–axis. Write down the coordinates of the point B on L which is closest to $C(1, 3, 4)$.
This is what I have tried doing so far:
Since the line is parallel to the x-axis, the equation of the line is:
$L = (5, -6, 7) + t(1, 0, 0)$
So the coordinates of the point B will be:
$x = 5+t$
$y=-6$
$z=7$  
I have got the $y$ and $z$ coordinates, but I am unable to find the $x$-coordinate because of the scalar, $t$.  
Could someone please check whether I am on the right track, and help me find the $x$-coordinate? Thanks :)
 A: You are correct so far. There's actually an easy way to intuit the answer. We travel parallel to the $x$ axis, so the best we can do is to get the $x$-coordinate of the point on $L$ as close to the $x$ coordinate of $C$ as possible. This is obviously achieved when $x=1$, giving $B=(1,-6,7)$.
However, I will give a more formal answer as well which you can use in a general setting.
All you have to do is write a formula for the distance between $C$ and an arbitrary point on $L$, and then minimize that distance. We use the Euclidean distance formula:
$$d=\sqrt{(x_1-x_2)^2+(y_1-y_2)^2+(z_1-z_2)^2}$$
In our case, we have $B=(x_1,y_1,z_1)=(5+t,-6,7)$ and $C=(x_2,y_2,z_2)=(1,3,4)$. Hence our distance formula is
$$d=\sqrt{(5+t-1)^2+(-6-3)^2+(7-4)^2}=\sqrt{(4+t)^2+90}$$
Now we note that this function is minimized in the same place as
$$(4+t)^2+90$$
Taking a derivative and setting equal to $0$, we get
$$2(4+t)=0\hspace{10mm}\implies\hspace{10mm}t=-4$$
Hence the distance is minimized when $t=-4$, which is when $B=(1,-6,7)$ as we originally concluded.
A: There is a very straightforwatd method using dot product. For the line equation $$\underline{r}=\underline{a}+\lambda\underline{b},$$where $\underline {a}$ is a known fixed point on the line and $\underline{b}$ is the direction of the line, then the closest point to $P$ with position vector $\underline{p}$ is found by solving the equation $$(\underline{r}-\underline{p})\cdot\underline{b}=0$$ to obtain the parameter value for the foot of the perpendicular from $P$ to the line.
In this case, you have $$\underline{r}-\underline{p}=\left(\begin{matrix}5\\-6\\7\end{matrix}\right)+\lambda\left(\begin{matrix}1\\0\\0\end{matrix}\right)-\left(\begin{matrix}1\\3\\4\end{matrix}\right)=\left(\begin{matrix}4+\lambda\\-9\\3\end{matrix}\right)$$
Therefore $$\left(\begin{matrix}4+\lambda\\-9\\3\end{matrix}\right)\cdot\left(\begin{matrix}1\\0\\0\end{matrix}\right)=0\Rightarrow \lambda=-4$$
Hence $$\underline{r}=\left(\begin{matrix}1\\-6\\7\end{matrix}\right)$$
A: Try to merge algebra with geometry within you own mind. The answer should be obvious with few calculations.

