I have an underdetermined system of 2 equations in n variables and a "starting point" $s$. I need to find the point satisfying the equations which is closest to the starting point. However, I have the additional constraint that all the coordinates of the result point must be positive. So far the steps I've figured out are:
- Find the null space $N$ of the corresponding homogeneous system.
- Find the projection matrix on to this space using $P = N(N^T N)^{-1} N^T$
- Project the starting point using $P(s-r)+r$ where $r$ is some solution to the original non-homogeneous system.
I think this gives me the closet point in my subspace to the starting point. This sort of works but for many starting points, some of the result coordinates are negative.
One idea is to then iterate by:
- Set one of the negative coordinates to 0 to get a new starting point.
- Project it with $P$ again to get a new solution that's slightly closer.
- Repeat
However, I'm not 100% sure if this will always converge or if it will converge fast enough. I'm also wondering if there is a simpler/better way. In the end, I need to write a program to do this so maybe there's an algorithm I'm overlooking?
Thanks!