Question: 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 :)

Answer: 
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.
Try to merge algebra with geometry within you own mind. The answer should be obvious with few calculations.

[![enter image description here](https://i.stack.imgur.com/i9bDP.png)](https://i.stack.imgur.com/i9bDP.png)