Suppose $A$ is a matrix with linearly dependent columns. I want to find the solution to $Ax=b$ where $b$ does not belong to column space of $A$. So, I find the solution to a new equation $Ax'=p$ where $p$ is the projection of $b$ onto column space of $A$.
Thus, $x' = (A^T A)^{-1}A^Tb$
But since $A$ has linearly dependent columns, $A^TA$ cannot be invertible.
So, how can I find the $x'$? Or am I wrong in my understanding somewhere?
Suppose $A$ is an $l\times n$ matrix
You can pick a basis $a_{n_1},\ldots, a_{n_m}$ for the column space of $A$ where the $a_i$ are columns of $A$ and clearly $m<n$.
Then consider the matrix $B=[a_{n_1},\ldots,a_{n_m}]$ and look at the matrix equation $By=b$. Use the pseudo-inverse to find $y'=(B^TB)^{-1}B^Tb$.
Then you need to lift the solution $y' \in \mathbb{R}^m$ to an $x' \in \mathbb{R}^n$ you can do this by setting the corresponding components in $y'$ to their counterparts in $x'$ and set the other components equal to zero.
I'm editing to provide more info on the correspondence:
$y_1 \leftrightarrow x_{n_1}\\ y_2 \leftrightarrow x_{n_2}\\ \vdots\\ y_m \leftrightarrow x_{n_m}$
Obviously, there's more than one solution here so it's not really the same sort o thing.