## Least squares method

Use the projection to find the best approximate solution of the system $$\mathbf A\mathbf x=\mathbf b$$, where
$$\mathbf A= \begin{pmatrix} 2 & 1 & 0 \\ 4 & 2 & 0 \\ 2 & -4 & -1 \\ 1 & -2 & 2 \\ \end{pmatrix}, \qquad \mathbf b=(10, 5, 13, 9)^T$$
Observe that the columns of $$\mathbf A$$ are mutually perpendicular.
Since the columns $$\mathbf a_1,…,\mathbf a_3$$ are orthogonal, the projection is given by
$$\mathbf b_{{\mathcal R}(A)}=\sum\limits_{i=1}^3 \frac{\langle \mathbf b|\mathbf a_i \rangle}{||\mathbf a_i||^2}\mathbf a_i$$, hence $$\mathbf b_{{\mathcal R}(A)}=(4, 8, 13, 9)^T$$ with coefficients $$\mathbf x'=(3, -2, 1)^T$$.