Algebra of matrices

Algebra of Matrices

Algebra of matrices is a basic things to work with matrices. Algebra of matrices contains addition, subtraction, scalar multiplication and multiplication of matrices. Let us understand algebra of matrices in details with examples.

Equal Matrices.

Two matrices $A=[a_{ij}]$ and $B=[b_{ij}]$ are called equal matrices if

• Number of rows of $A=$ Number of rows of $B$.

• Number of columns of $A=$ Number of columns of $B$.

• Corresponding entries are equal. i.e. $a_{ij}=b_{ij}$ for all $i,j$.

Examples of Equal Matrices and not Equal Matrices.

Let $A=\begin{bmatrix} 2&3&0\\ 5&1&2\end{bmatrix}$, $B=\begin{bmatrix}1&0 \\-1&\dfrac{1}{\sqrt{2}}\end{bmatrix}$
and $C=\begin{bmatrix}\sin \pi/2 &\log 1 \\\cos\pi&\sin\pi/4\end{bmatrix}$. Then

• Matrices $A$ and $B$ are not equal matrices because number of columns of $A\ne$ number of columns of $B$.

• Matrices $A$ and $C$ are not equal matrices because number of columns of $A\ne$ number of columns of $C$.

• Matrices $B$ and $C$ are equal matrices because number of rows and columns of $B$ are equal to number of rows and columns of $C$ respectively, and

 \begin{aligned} c_{11}& =\sin\pi/2=1=b_{11},\\ c_{12}&=\log 1=0=b_{12},\\ c_{21}&=\cos\pi=-1=b_{21},\\ c_{22}&=\sin\pi/4=\dfrac{1}{\sqrt{2}}=b_{22} \end{aligned}

Two matrices can be added if and only if they have the same number of rows and same number of columns. That is the order of both the matrices are same.

In order to find addition of two matrices, you just add the corresponding entries of the matrices.
The resultant matrix of addition of two matrices is also of the same order.

Let $A=[a_{ij}]_{m\times n}$ and $B=[b_{ij}]_{m\times n}$ be two matrices then the addition of $A$ and $B$ is defined as

 \begin{alignat*}{2} A+B &=\left[\begin{matrix} a_{11}&a_{12}&\ldots&a_{1j}&\ldots&a_{1n}\\ a_{21}&a_{22}&\ldots&a_{1j}&\ldots&a_{2n}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{i1}&a_{i2}&\ldots&a_{ij}&\ldots&a_{in}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{m1}&a_{m2}&\ldots&a_{mj}&\ldots&a_{mn}\\ \end{matrix}\right]_{m\times n}+\;\;\;\;\; \left[ \begin{matrix} b_{11}&b_{12}&\ldots&b_{1j}&\ldots&b_{1n}\\ b_{21}&b_{22}&\ldots&b_{1j}&\ldots&b_{2n}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ b_{i1}&b_{i2}&\ldots&b_{ij}&\ldots&b_{in}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ b_{m1}&b_{m2}&\ldots&b_{mj}&\ldots&b_{mn}\\ \end{matrix}\right]_{m\times n}\\ &\\ &=\left[\begin{matrix} a_{11}+b_{11}&a_{12}+b_{12}&\ldots&a_{1j}+b_{1j}&\ldots&a_{1n}+b_{1n}\\ a_{21}+b_{21}&a_{22}+b_{22}&\ldots&a_{2j}+b_{2j}&\ldots&a_{2n}+b_{2n}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{i1}+b_{i1}&a_{i2}+b_{i2}&\ldots&a_{ij}+b_{ij}&\ldots&a_{in}+b_{in}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{m1}+b_{m1}&a_{m2}+b_{m2}&\ldots&a_{mj}+b_{mj}&\ldots&a_{mn}+b_{mn}\\ \end{matrix}\right]_{m\times n} \end{alignat*}
That is

 \begin{aligned} A+B&=[a_{ij}]_{m\times n}+[b_{ij}]_{m\times n}\\ &=[a_{ij}+b_{ij}]_{m\times n}. \end{aligned}

Examples of Addition of two Matrices.

Let us understand addition of two matrices with following examples.

1. Let $A=\begin{bmatrix}2&3&6\\0&-1&2\end{bmatrix}$ and $B=\begin{bmatrix}5&1&-6\\2&3&-2\end{bmatrix}$. Then

 \begin{alignat*}{2} A+B&=\begin{bmatrix}2&3&6\\0&-1&2\end{bmatrix}+\begin{bmatrix}5&1&-6\\2&3&-2\end{bmatrix}\\ &\\ &=\begin{bmatrix}2+5&3+1&6+(-6)\\0+2&(-1)+3&2+(-2)\end{bmatrix}\\ &\\ &=\begin{bmatrix}7 & 4& 0\\2& 2&0\end{bmatrix} \end{alignat*}

1. Let $A=\begin{bmatrix}2&1\\-5&3\\1&7\end{bmatrix}$ and $B=\begin{bmatrix}3&5\\-2&6\\4&1\end{bmatrix}$. Then

 \begin{aligned} A+B&=\begin{bmatrix}2&1\\-5&3\\1&7\end{bmatrix}+\begin{bmatrix}3&5\\-2&6\\4&1\end{bmatrix}\\ &\\ &=\begin{bmatrix}2+3&1+5\\-5+(-2)&3+6\\1+4&7+1\end{bmatrix}\\ &\\ &=\begin{bmatrix}5 & 6\\-7&9\\5&8\end{bmatrix} \end{aligned}

Subtraction of two Matrices.

Two matrices can be subtract if and only if they have the same number of rows and same number of columns. That is the order of both the matrices are same.

In order to find subtraction of two matrices, you just subtract the corresponding entries of the matrices.
The resultant matrix of subtraction of two matrices is also of the same order.

Let $A=[a_{ij}]_{m\times n}$ and $B=[b_{ij}]_{m\times n}$ be two matrices then the subtraction of $A$ and $B$ is defined as

 \begin{aligned} A-B&=\left[\begin{matrix} a_{11}&a_{12}&\ldots&a_{1j}&\ldots&a_{1n}\\ a_{21}&a_{22}&\ldots&a_{1j}&\ldots&a_{2n}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{i1}&a_{i2}&\ldots&a_{ij}&\ldots&a_{in}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{m1}&a_{m2}&\ldots&a_{mj}&\ldots&a_{mn}\\ \end{matrix}\right]_{m\times n}-\;\;\;\;\; \left[\begin{matrix} b_{11}&b_{12}&\ldots&b_{1j}&\ldots&b_{1n}\\ b_{21}&b_{22}&\ldots&b_{1j}&\ldots&b_{2n}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ b_{i1}&b_{i2}&\ldots&b_{ij}&\ldots&b_{in}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ b_{m1}&b_{m2}&\ldots&b_{mj}&\ldots&b_{mn}\\ \end{matrix}\right]_{m\times n}\\ &\\ &=\left[\begin{matrix} a_{11}-b_{11}&a_{12}-b_{12}&\ldots&a_{1j}-b_{1j}&\ldots&a_{1n}-b_{1n}\\ a_{21}-b_{21}&a_{22}-b_{22}&\ldots&a_{2j}-b_{2j}&\ldots&a_{2n}-b_{2n}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{i1}-b_{i1}&a_{i2}-b_{i2}&\ldots&a_{ij}-b_{ij}&\ldots&a_{in}-b_{in}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{m1}-b_{m1}&a_{m2}-b_{m2}&\ldots&a_{mj}-b_{mj}&\ldots&a_{mn}-b_{mn}\\ \end{matrix}\right]_{m\times n} \end{aligned}

That is

 \begin{aligned} A-B&=[a_{ij}]_{m\times n}-[b_{ij}]_{m\times n}\\ &=[a_{ij}-b_{ij}]_{m\times n} \end{aligned}

Examples of Subtraction of two Matrices.

Let us understand subtraction of two matrices with following examples.

1. Let $A=\begin{bmatrix}2&3&6\\0&-1&2\end{bmatrix}$ and $B=\begin{bmatrix}5&1&-6\\2&3&-2\end{bmatrix}$. Then

 \begin{aligned} A-B&=\begin{bmatrix}2&3&6\\0&-1&2\end{bmatrix}-\begin{bmatrix}5&1&-6\\2&3&-2\end{bmatrix}\\ &\\ &=\begin{bmatrix}2-5&3-1&6-(-6)\\0-2&(-1)-3&2-(-2)\end{bmatrix}\\ &\\ &=\begin{bmatrix}-3 & 2& 12\\-2& -4&4\end{bmatrix} \end{aligned}

1. Let $A=\begin{bmatrix}2&1\\-5&3\\1&7\end{bmatrix}$ and $B=\begin{bmatrix}3&5\\-2&6\\4&1\end{bmatrix}$. Then

 \begin{aligned} A-B&=\begin{bmatrix}2&1\\-5&3\\1&7\end{bmatrix}-\begin{bmatrix}3&5\\-2&6\\4&1\end{bmatrix}\\ &\\ &=\begin{bmatrix}2-3&1-5\\-5-(-2)&3-6\\1-4&7-1\end{bmatrix}\\ &\\ &=\begin{bmatrix}-1 & -4\\-3&-3\\-3&6\end{bmatrix} \end{aligned}

Multiplication of a Matrix by a Scalar

Let $A=[a_{ij}]_{m\times n}$ be a matrix and $k\in\mathbb{R} (or\; \mathbb{C})$ be a scalar. Then to find the multiplication of $A$ by a scalar $k$, multiply every entry of the matrix by $k$.

 \begin{aligned} kA&=k\;\left[\begin{matrix} a_{11}&a_{12}&\ldots&a_{1j}&\ldots&a_{1n}\\ a_{21}&a_{22}&\ldots&a_{1j}&\ldots&a_{2n}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{i1}&a_{i2}&\ldots&a_{ij}&\ldots&a_{in}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ a_{m1}&a_{m2}&\ldots&a_{mj}&\ldots&a_{mn}\\ \end{matrix}\right]_{m\times n}\\ &=\left[\begin{matrix} k\cdot a_{11}&k\cdot a_{12}&\ldots&k\cdot a_{1j}&\ldots&k\cdot a_{1n}\\ k\cdot a_{21}&k\cdot a_{22}&\ldots&k\cdot a_{1j}&\ldots&k\cdot a_{2n}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ k\cdot a_{i1}&k\cdot a_{i2}&\ldots&k\cdot a_{ij}&\ldots&k\cdot a_{in}\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ k\cdot a_{m1}&k\cdot a_{m2}&\ldots&k\cdot a_{mj}&\ldots&k\cdot a_{mn}\\ \end{matrix}\right]_{m\times n} \end{aligned}

That is

 \begin{aligned} kA&=k[a_{ij}]\\ &=[k\cdot a_{ij}] \end{aligned}

Examples of Multiplication of a Matrix by a Scalar

Let us understand multiplication of a matrix by a scalar with following examples.

1. Let $A=\begin{bmatrix}2&3&6\\0&-1&2\end{bmatrix}$. Then

 \begin{aligned} 3A&=3\begin{bmatrix}2&3&6\\0&-1&2\end{bmatrix}\\ &\\ &=\begin{bmatrix}3\cdot 2&3\cdot3&3\cdot 6\\3\cdot 0&3\cdot (-1)&3\cdot 2\end{bmatrix}\\ &\\ &=\begin{bmatrix}6 & 9& 18\\0& -3&6\end{bmatrix} \end{aligned}

1. Let $B=\begin{bmatrix}3&5\\-2&6\\4&1\end{bmatrix}$. Then

 \begin{aligned} (-5)B&=(-5)\begin{bmatrix}3&5\\-2&6\\4&1\end{bmatrix}\\ &\\ &=\begin{bmatrix}(-5)\cdot3&(-5)\cdot5\\(-5)\cdot(-2)&(-5)\cdot 6\\(-5)\cdot 4&(-5)\cdot 1\end{bmatrix}\\ &\\ &=\begin{bmatrix}-15 & -25\\10& -30\\-20&-5\end{bmatrix} \end{aligned}

By multiplication of a matrix by a scalar does not change the order of the matrix.

Multiplication of two Matrices

Multiplication of two matrices can be possible if and only if the number of columns of first matrix is equal to the number of rows of the second matrix. In other words, if $A=[a_{ij}]_{m\times n}$ and $B=[b_{ij}]_{p\times q}$ be two matrices, then the multiplication $AB$ of matrices $A$ and $B$ is defined iff $n=p$.

Let $A=[a_{ij}]_{m\times n}$ and $B=[b_{ij}]_{n\times q}$ be two matrices then the multiplication $AB$ of $A$ and $B$ is defined as

$$AB=[c_{ij}]_{m\times q}$$

where $c_{ij}=a_{i1}b_{1j}+a_{i2}b_{2j}+\cdots+a_{in}b_{nj}=\sum\limits_{k=1}^n a_{ik}b_{kj}$ for all $i=1,2,\ldots,m$ and $j=1,2,\ldots,n$.

Examples of Multiplication of Matrices

Let us understand multiplication of matrices with following examples.

1. If $A=\begin{bmatrix}2&3&6\\0&-1&2\end{bmatrix}$ and $B=\begin{bmatrix}3&5\\-2&6\\4&1\end{bmatrix}$, then

 \begin{aligned} AB&=\begin{bmatrix}2&3&6\\0&-1&2\end{bmatrix}_{2\times 3} \cdot \begin{bmatrix}3&5\\-2&6\\4&1\end{bmatrix}_{3\times 2}\\ &\\ &=\begin{bmatrix} 2\cdot 3+3\cdot(-2)+6\cdot 4 & 2\cdot 5+3\cdot 6+6 \cdot 1\\ 0\cdot 3+(-1)\cdot(-2)+2\cdot 4 & 0\cdot 5+(-1)\cdot 6+2 \cdot 1 \end{bmatrix}\\ &\\ &=\begin{bmatrix} 24 & 24\\ 9& -4 \end{bmatrix}_{2\times 2} \end{aligned}

 \begin{aligned} BA&=\begin{bmatrix}3&5\\-2&6\\4&1\end{bmatrix}_{3\times 2}\cdot \begin{bmatrix}2&3&6\\0&-1&2\end{bmatrix}_{2\times 3}\\ &\\ &=\begin{bmatrix} 3\cdot 2+5\cdot 0 &3\cdot 3+5\cdot (-1)&3\cdot 6+5\cdot 2\\ -2\cdot 2+6\cdot 0&-2\cdot 3+6\cdot (-1)&-2\cdot 6+6\cdot 2\\ 4\cdot 2+1\cdot 0 &4\cdot 3+1\cdot (-1)&4\cdot 6+1\cdot 2\\ \end{bmatrix}\\ &\\ &=\begin{bmatrix} 6 & 4 & 28\\ -4 & -12&0\\ 8&11&26 \end{bmatrix}_{3\times 3} \end{aligned}

Order of matrix $A$ is $2\times 3$ and order of $B$ is $3\times 2$.

The number of columns of the matrix $A$=The number of rows of the matrix $B=3$

The order of the resultant matrix $AB$ is $2\times 2$.

The order of the resultant matrix $AB$ is (The number of rows of the first matrix) $\times$ (The number of columns of the second matrix).

$BA$ is also defined and it is of order $3\times 3$.

Here $AB\ne BA$. That is matrix multiplication is not commutative.

1. If $X=\begin{bmatrix}1&3&7\\0&1&2\\2&4&1\end{bmatrix}$ and $Y=\begin{bmatrix}2&5\\1&6\\4&-3\end{bmatrix}$, then

 \begin{aligned} XY&=\begin{bmatrix}1&3&7\\0&1&2\\2&4&1\end{bmatrix}_{3\times 3} \cdot \begin{bmatrix}2&5\\1&6\\4&-3\end{bmatrix}_{3\times 2}\\ &\\ &=\begin{bmatrix} 1\cdot 2+3\cdot 1+7\cdot 4 & 1\cdot 5+3\cdot 6+7 \cdot (-3)\\ 0\cdot 2+1\cdot 1+2\cdot 4 & 0\cdot 5+1\cdot 6+2 \cdot (-3)\\ 2\cdot 2+4\cdot 1+1\cdot 4 & 2\cdot 5+4\cdot 6+1 \cdot (-3)\\ \end{bmatrix}\\ &\\ &=\begin{bmatrix} 33 & 2\\ 9& 0\\ 12&31 \end{bmatrix}_{3\times 2} \end{aligned}

Order of matrix $X$ is $3\times 3$ and order of $Y$ is $3\times 2$.

The number of columns of the matrix $X$=The number of rows of the matrix $Y=3$

The order of the resultant matrix $XY$ is $3\times 2$.

The order of the resultant matrix $XY$ is (The number of rows of the first matrix) $\times$ (The number of columns of the second matrix).

$YX$ is not defined because number of columns of matrix $Y$ is not equal to number of rows of matrix $X$.