Using matrices, solve the following system of equations:
$x + y + z = 6$, $\;$ $x - y + z = 2$, $\;$ $2x + y - z = 1$
The given equations are: $\;$ $x + y + z = 6$, $\;$ $x - y + z = 2$, $\;$ $2x + y - z = 1$
Writing the given equations in the matrix form $\;$ $AX = B$ $\;$ as
$\begin{bmatrix}
1 & 1 & 1 \\
1 & -1 & 1 \\
2 & 1 & -1
\end{bmatrix} \begin{bmatrix}
x \\
y \\
z
\end{bmatrix} = \begin{bmatrix}
6 \\
2 \\
1
\end{bmatrix}$
where $\;$ $A = \begin{bmatrix}
1 & 1 & 1 \\
1 & -1 & 1 \\
2 & 1 & -1
\end{bmatrix}$, $\;$ $X = \begin{bmatrix}
x \\
y \\
z
\end{bmatrix}$, $\;$ $B = \begin{bmatrix}
6 \\
2 \\
1
\end{bmatrix}$
$\begin{aligned}
\left|A\right| & = \begin{vmatrix}
1 & 1 & 1 \\
1 & -1 & 1 \\
2 & 1 & -1
\end{vmatrix} \\\\
& = 1 \left(1 - 1\right) - 1 \left(-1 - 2\right) + 1 \left(1 + 2\right) = 6 \neq 0
\end{aligned}$
$\implies$ $A$ is a non-singular matrix.
$\therefore \;$ The given system of equations has the unique solution $\;$ $X = A^{-1} B$
Cofactors of matrix $A$ are:
$A_{11} = \begin{vmatrix}
-1 & 1 \\
1 & -1
\end{vmatrix} = 1 - 1 = 0$
$A_{12} = \left(-1\right) \begin{vmatrix}
1 & 1 \\
2 & -1
\end{vmatrix} = \left(-1\right) \times \left(-1 -2\right) = 3$
$A_{13} = \begin{vmatrix}
1 & -1 \\
2 & 1
\end{vmatrix} = 1 + 2 = 3$
$A_{21} = \left(-1\right) \begin{vmatrix}
1 & 1 \\
1 & -1
\end{vmatrix} = \left(-1\right) \times \left(-1 -1\right) = 2$
$A_{22} = \begin{vmatrix}
1 & 1 \\
2 & -1
\end{vmatrix} = -1 -2 = -3$
$A_{23} = \left(-1\right) \begin{vmatrix}
1 & 1 \\
2 & 1
\end{vmatrix} = \left(-1\right) \times \left(1 - 2\right) = 1$
$A_{31} = \begin{vmatrix}
1 & 1 \\
-1 & 1
\end{vmatrix} = 1 + 1 = 2$
$A_{32} = \left(-1\right) \begin{vmatrix}
1 & 1 \\
1 & 1
\end{vmatrix} = \left(-1\right) \times \left(1 - 1\right) = 0$
$A_{33} = \begin{vmatrix}
1 & 1 \\
1 & -1
\end{vmatrix} = -1 - 1 = -2$
$\therefore \;$ $adj \left(A\right) = \begin{bmatrix}
A_{11} & A_{12} & A_{13} \\
A_{21} & A_{22} & A_{23} \\
A_{31} & A_{32} & A_{33}
\end{bmatrix}^t = \begin{bmatrix}
0 & 3 & 3 \\
2 & -3 & 1 \\
2 & 0 & -2
\end{bmatrix}^t = \begin{bmatrix}
0 & 2 & 2 \\
3 & -3 & 0 \\
3 & 1 & -2
\end{bmatrix}$
$\begin{aligned}
\therefore \; A^{-1} = \dfrac{adj \left(A\right)}{\left|A\right|} & = \dfrac{1}{6} \begin{bmatrix}
0 & 2 & 2 \\
3 & -3 & 0 \\
3 & 1 & -2
\end{bmatrix} \\\\
& = \begin{bmatrix}
0 & 1/3 & 1/3 \\
1/2 & -1/2 & 0 \\
1/2 & 1/6 & -1/3
\end{bmatrix}
\end{aligned}$
$\begin{aligned}
\therefore \; X = A^{-1} B & = \begin{bmatrix}
0 & 1/3 & 1/3 \\
1/2 & -1/2 & 0 \\
1/2 & 1/6 & -1/3
\end{bmatrix} \begin{bmatrix}
6 \\
2 \\
1
\end{bmatrix} \\\\
& = \begin{bmatrix}
0 + 2/3 + 1/3 \\
3 - 1 + 0 \\
3 + 1/3 - 1/3
\end{bmatrix} \\\\
i.e. \; \begin{bmatrix}
x \\
y \\
z
\end{bmatrix} & = \begin{bmatrix}
1 \\
2 \\
3
\end{bmatrix}
\end{aligned}$
$\implies$ $x = 1$, $\;$ $y = 2$, $\;$ $z = 3$