Exercise 3.3.21. Given three vectors , , and , and the two lines through the origin and and through in the direction of , we want to find scalar values and such that the distance between the points and is at a minimum. Write down equations for and . Solve the equations for when , , and .

Answer: We approach the problem by taking partial derivatives of with respect to and and then setting those partial derivatives to zero. We have

We take advantage of the facts that for two vectors and we have (the inner product is the same no matter in which order we calculate it) and (the transpose of a difference is the same as the difference of the transposes). We then have

Next we take the partial derivatives with respect to :

and with respect to :

Equating the partial derivatives to zero gives us the following system of equations (after simplifying by dividing by 2 and rearranging terms):

When , , and we have , , , , and . The system of equations is then

We can solve this by multiplying both sides of the equation on the left by

to get

The solution is thus .

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fifth Edition and the accompanying free online course, and Dr Strang’s other books.