Given the matrix equation:
$$ x^TA^TA = b^TA $$
I'm trying to find the least squares solution (i.e.; trying to minimize $r=||Ax-b||$). The matrix $A$ is not necessarily symmetric.
When I solve it in following way I find $x$ as:
$$ \begin{array}{rcl} x^TA^TA &=& b^TA \\ x^T &=& b^TA(A^TA)^{-1} \\ x &=& (AA^T)^{-1}A^Tb \end{array} $$
But I find a different solution for $x$ when I solve it this way:
$$ \begin{array}{rcl} x^TA^TA &=& b^TA \\ A^TAx &=& A^Tb \\ x &=& (A^TA)^{-1}A^Tb \end{array} $$
Apparently the latter one is the correct solution. But what is wrong with the first one? What am I doing wrong?