Compute $\mathrm{AB}$ and $\mathrm{BA}$, which ever exists when
$A=\left[\begin{array}{cc}2 & 1 \\ 3 & 2 \\ -1 & 1\end{array}\right]$ and $B=\left[\begin{array}{ccc}1 & 0 & 1 \\ -1 & 2 & 1\end{array}\right]$
Given : $A=\left[\begin{array}{cc}2 & 1 \\ 3 & 2 \\ -1 & 1\end{array}\right]$ and $B=\left[\begin{array}{ccc}1 & 0 & 1 \\ -1 & 2 & 1\end{array}\right]$
Matrix $A$ is of order $3 \times 2$ and Matrix $B$ is of order $2 \times 3$
To find : matrices $A B$ and $B A$
Formula used :
Where $c_{i j}=a_{i 1} b_{1 j}+a_{i 2} b_{2 j}+a_{i 3} b_{3 j}+\ldots \ldots \ldots \ldots \ldots . .+a_{i n} b_{n j}$
If $A$ is a matrix of order $a \times b$ and $B$ is a matrix of order $c \times d$, then matrix $A B$ exists and is of order $a \times d$, if and only if $b=$ $c$
If $\mathrm{A}$ is a matrix of order $\mathrm{a} \times \mathrm{b}$ and $\mathrm{B}$ is a matrix of order $c \times \mathrm{d}$, then matrix $\mathrm{BA}$ exists and is of order $c \times \mathrm{b}$, if and only if $\mathrm{d}=$ a
For matrix $A B, a=3, b=2, c=2, d=3$, matrix $A B$ exists and is of order $3 \times 3$, as
$b=c=2$
Matrix $A B=\left[\begin{array}{cc}2 & 1 \\ 3 & 2 \\ -1 & 1\end{array}\right] \times\left[\begin{array}{ccc}1 & 0 & 1 \\ -1 & 2 & 1\end{array}\right]=\left[\begin{array}{ccc}2(1)+1(-1) & 2(0)+1(2) & 2(1)+1(1) \\ 3(1)+2(-1) & 3(0)+2(2) & 3(1)+2(1) \\ -1(1)+1(-1) & -1(0)+1(2) & -1(1)+1(1)\end{array}\right]$
Matrix $A B=\left[\begin{array}{ccc}2-1 & 0+2 & 2+1 \\ 3-2 & 0+4 & 3+2 \\ -1-1 & 0+2 & -1+1\end{array}\right]=\left[\begin{array}{ccc}1 & 2 & 3 \\ 1 & 4 & 5 \\ -2 & 2 & 0\end{array}\right]$
Matrix $A B=\left[\begin{array}{ccc}1 & 2 & 3 \\ 1 & 4 & 5 \\ -2 & 2 & 0\end{array}\right]$
Matrix $A B=\left[\begin{array}{ccc}1 & 2 & 3 \\ 1 & 4 & 5 \\ -2 & 2 & 0\end{array}\right]$
For matrix $B A, a=3, b=2, c=2, d=3$, matrix $B A$ exists and is of order $2 \times 2$, as
$d=a=3$
Matrix $B A=\left[\begin{array}{ccc}1 & 0 & 1 \\ -1 & 2 & 1\end{array}\right] \times\left[\begin{array}{cc}2 & 1 \\ 3 & 2 \\ -1 & 1\end{array}\right]=\left[\begin{array}{cc}1(2)+0(3)+1(-1) & 1(1)+0(2)+1(1) \\ -1(2)+2(3)+1(-1) & -1(1)+2(2)+1(1)\end{array}\right]$
Matrix $\mathrm{BA}=\left[\begin{array}{cc}2+0-1 & 1+0+1 \\ -2+6-1 & -1+4+1\end{array}\right]=\left[\begin{array}{ll}1 & 2 \\ 3 & 4\end{array}\right]$
Matrix BA $=\left[\begin{array}{ll}1 & 2 \\ 3 & 4\end{array}\right]$
Matrix $B A=\left[\begin{array}{ll}1 & 2 \\ 3 & 4\end{array}\right]$