Consider a system of linear equations
$$\b{Ax} = \b{b} $$
where $\b{A} \in \R^{m \times n}, \b{b} \in \R^m, m \geq n $, and $\rank{ \b{A}} = n $.
Note that the number of unknowns, $n $, is no larger than the number of equations, $m $.
If $b $ does not belong to the range of $\b{A} $, i.e. $\b{b} \not\in \mathcal{ R }(\b{A})$, then this system of equations is said to be inconsistant or overdetermined.
In this case, there is no solution to the above set of equations.
A vector $\b{ x }^* $ that minimizes $\norm{ \b{Ax} - \b{b}}^2$ is called a least-squares solution; that is, $\forall \b{x} \in \R^n $,
$$\norm{ \b{Ax} -\b{b}}^2 \geq \norm{ \b{A x^*} - \b{b}}^2 $$
Let $\b{A} \in \R^{m \times n}, m \geq n. $ Then,
$$\rank{ \b{A}} = n \iff \rank{ \transpose{ \b{A}} \b{A}}= n\ \text{(the square matrix }\transpose{ \b{A}}\b{A}\text{ is non singular)}$$
</span>
</span>
<span class="proof__expand"><a>[expand]</a></span>
</span>
</span>
<span class="proof__expand"><a>[expand]</a></span>
The unique vector $\b{x}^* $ that minimizes $\norm{ \b{Ax} - \b{b}}^2$ is given by the solution to the equation $\transpose{ \b{A}} \b{A} \b{x} = \transpose{ \b{A}} \b{b}$ i.e.
$$\b{x}^* = \inv{(\transpose{ \b{A}} \b{A})} \transpose{ \b{A}} \b{b} $$
Let $\b{h} \in \mathcal{ R } (\b{A}) $ be such that $\b{h} - \b{b} $ is orthogonal to $\mathcal{ R }(\b{A}) $. Then $\b{h} = \b{A} \b{x}^* = \b{A} \inv{(\transpose{ \b{A}} \b{A})} \transpose{ \b{A}} \b{b}$.