I was going over the linear algebra regarding how to solve the least squares problem and had a few questions regarding the solution.
When solving the $||Ax-b||^2$ I understand the derivation of expanding it, taking the derivative with respect to x and setting it to $0$ to reach this:
$(A^TA)x = A^Tb$
Now let us assume $A$ is an $nxm$ matrix with $n>m$
I understand that if A has rank $m$ then the least squares solution will be unique as $A^TA$ will be invertible. However what if A has rank $q$ where $q<m$ , then does the least squares solution can't be unique so how does it go about solving the problem?
Will there be an infinite number of solutions and can there potentially be no solution? I was having a tough time trying to figure out these last two questions and was hoping to get some intuition on them.
Lastly, how would software go about solving the least squares problem when A has rank $q$ where $q<m$