# How can I write an algorithm to solve this formula for closest point to a set of lines in 3d

I am trying to understand how I can write an algorithm to solve the formula written at the end of this answer, that is:

$$0=\sum_{i=0}^m \vec c - \vec a_i - \vec d_i \frac {(\vec c-\vec a_i)\cdot\vec d_i}{\|\vec d_i\|^2}$$

I know simple equations systems may be solved through matrices when you have $$Ax=b$$ you can solve with $$x = A^{-1}b$$ but this is a little more complicated for me

I think I should come to a form such as: $$A\vec c = b$$ but I don't have idea how to deal with $\sum$ and dot products

• I agree, but the missing of latex over there suggests this is the best place.. – elect Jun 24 '15 at 9:25
• I was also not sure so I removed my comment. – sashas Jun 24 '15 at 9:26
• Anyway, I gave it a try and wrote also over there, let's see – elect Jun 24 '15 at 9:31
• Also asked at StackExchange. – Joseph O'Rourke Jun 24 '15 at 12:04