Find the least-square solution of Ax=b for $$A = \begin{bmatrix} 1 & -6\\ 1 & -2\\ 1 & 1\\ 1 & 7 \end{bmatrix}$$ and $$b = \begin{bmatrix}-1 \\ 2\\ 1\\ 6 \end{bmatrix}$$

Here,

A = $$\begin{bmatrix}1 & -6\\ 1 & -2\\ 1 & 1\\ 1 & 7\end{bmatrix}$$ and b = $$\begin{bmatrix}-1\\ 2\\ 1\\ 6\end{bmatrix}$$

Now,

$$\hat{x} = (A^{T}A)^{-1} (A^{T}b)$$  ———– (1)

AT = $$\begin{bmatrix}1 & 1 & 1 & 1\\ -6 & -2 & 1 & 7\end{bmatrix}$$

ATA = $$\begin{bmatrix}1 & 1 & 1 & 1\\ -6 & -2 & 1 & 7\end{bmatrix}$$$$\begin{bmatrix}1 & -6\\ 1 & -2\\ 1 & 1\\ 1 & 7\end{bmatrix}$$

= $$\begin{bmatrix}1+1+1+1 & -6-2+1+7\\ -6-2+1+7 & 36+4+1+49\end{bmatrix}$$

= $$\begin{bmatrix}4 & 0\\ 0 & 90\end{bmatrix}$$

and

ATb = $$\begin{bmatrix}1 & 1 & 1 & 1\\ -6 & -2 & 1 & 7\end{bmatrix}$$$$\begin{bmatrix}-1\\ 2\\ 1\\ 6\end{bmatrix}$$

= $$\begin{bmatrix}-1+2+1+6\\ 6-4+1+42\end{bmatrix}$$

= $$\begin{bmatrix}8\\ 45\end{bmatrix}$$

Since we have definition of least square; the set of least square solutions of Ax = b coincides with the non-empty set of solutions of ATAx = ATb

therefore

$$\hat{x} = (A^{T}A)^{-1} (A^{T}b)$$

Here,

|ATA| = $$\begin{bmatrix}4 & 0\\ 0 & 90\end{bmatrix}$$ = 360 ≠ 0

then

(ATA)-1 = $$\frac{1}{360} \begin{bmatrix}90 & 0\\ 0 & 4\end{bmatrix}$$

then equation(1) becomes

$$\hat{x}$$ = $$\frac{1}{360} \begin{bmatrix}90 & 0\\ 0 & 4\end{bmatrix}\begin{bmatrix}8\\ 45\end{bmatrix}$$

= $$\frac{1}{360}\begin{bmatrix}720+0\\ 0+180\end{bmatrix}$$

= $$\begin{bmatrix}2\\ \frac{1}{2}\end{bmatrix}$$