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

Least Square Solution of Ax = b

Where A= $$\begin{bmatrix}1 & 3 & 5\\ 1 & 1 & 0\\ 1 & 1 & 2\\1 & 3 & 3\end{bmatrix}$$, b = $$\begin{bmatrix}3\\5\\7\\3\end{bmatrix}$$

Here, Ax = b

ATAx = ATb

∴ x = (ATA)-1 ATB   ——— (i)

Now,

ATA = $$\begin{bmatrix}1 & 1 & 1 & 1\\ 3 & 1 & 1 & 3\\ 5 & 0 & 2 & 3\end{bmatrix}$$$$\begin{bmatrix}1 & 3 & 5\\ 1 & 1 & 0\\ 1 & 1 & 2\\1 & 3 & 3\end{bmatrix}$$

= $$\begin{bmatrix}1+1+1+1 & 3+1+1+3 & 5+0+2+3\\ 3+1+1+3 & 9+1+1+9 & 15+0+2+9\\ 5+0+2+3 & 15+0+2+9 & 25+0+4+9\end{bmatrix}$$

= $$\begin{bmatrix}4 & 8 & 10\\ 8 & 20 & 26\\ 10 & 26 & 38\end{bmatrix}$$

ATB = $$\begin{bmatrix}1 & 1 & 1 & 1\\ 3 & 1 & 1 & 3\\ 5 & 0 & 2 & 3\end{bmatrix}$$ $$\begin{bmatrix}3\\5\\7\\3\end{bmatrix}$$

= $$\begin{bmatrix}18\\20\\3\end{bmatrix}$$

Now (ATA)-1

det(ATA) = $$\begin{vmatrix}4 & 8 & 10\\ 8 & 20 & 26\\ 10 & 26 & 38\end{vmatrix}$$

= 4$$\begin{vmatrix}20 & 26\\ 26 & 38\end{vmatrix}$$ – 8$$\begin{vmatrix}8 & 26\\ 10 & 38\end{vmatrix}$$ + 10$$\begin{vmatrix}8 & 20\\ 10 & 26\end{vmatrix}$$

= 4 × 84 – 44 × 8 + 10 × 8

= 64

Now,

a11 = $$\begin{vmatrix}20 & 26\\ 26 & 38\end{vmatrix}$$ = 84

a12 = -$$\begin{vmatrix}8 & 26\\ 10 & 38\end{vmatrix}$$ = -44

a13 = $$\begin{vmatrix}8 & 20\\ 10 & 26\end{vmatrix}$$ = 8

a21 = $$\begin{vmatrix}8 & 10\\ 26 & 38\end{vmatrix}$$ = -44

a22 = $$\begin{vmatrix}4 & 10\\ 10 & 38\end{vmatrix}$$ = 52

a23 = -$$\begin{vmatrix}4 & 8\\ 10 & 26\end{vmatrix}$$ = -24

a31 = $$\begin{vmatrix}8 & 10\\ 26 & 38\end{vmatrix}$$ = 44

a32 = -$$\begin{vmatrix}4 & 10\\ 8 & 26\end{vmatrix}$$ = -24

a33 = $$\begin{vmatrix}4 & 8\\8 & 20\end{vmatrix}$$ = 16

i.e. $$\begin{bmatrix}84 & -44 & 8\\ -44 & 52 & -24\\ 44 & -24 & 16\end{bmatrix}$$

Its transpose is

$$\begin{bmatrix}84 & -44 & 44\\ -44 & 52 & -24\\ 8 & -24 & 16\end{bmatrix}$$

∴ (ATA)-1 = $$\frac{1}{64} \begin{bmatrix}84 & -44 & 44\\ -44 & 52 & -24\\ 8 & -24 & 16\end{bmatrix}$$

= $$\begin{bmatrix}\frac{21}{16} & \frac{-11}{16} & \frac{1}{8}\\ \frac{-11}{16} & \frac{13}{16} & \frac{-3}{8}\\ \frac{1}{8} & \frac{-3}{8} & \frac{1}{4}\end{bmatrix}$$

From (i)

x = (ATA)-1 × ATB

= $$\begin{bmatrix}\frac{21}{16} & \frac{-11}{16} & \frac{1}{8}\\ \frac{-11}{16} & \frac{13}{16} & \frac{-3}{8}\\ \frac{1}{8} & \frac{-3}{8} & \frac{1}{4}\end{bmatrix}$$ $$\begin{bmatrix}18\\20\\3\end{bmatrix}$$

∴ x = $$\begin{bmatrix}\frac{31}{4}\\\frac{-9}{4}\\\frac{1}{2}\end{bmatrix}$$ is the solution