# Chapter 3 Binary Matrix Operations

## 3.1 Learning Objectives

After reading this chapter, you should be able to:

(1). add, subtract, and multiply matrices, and

(2). apply rules of binary operations on matrices.

## 3.2How do you add two matrices?

Two matrices $$\left\lbrack A \right\rbrack$$ and $$\left\lbrack B \right\rbrack$$ can be added only if they are the same size. The addition is then shown as

$\left\lbrack C \right\rbrack = \left\lbrack A \right\rbrack + \left\lbrack B \right\rbrack$

where

$c_{{ij}} = a_{{ij}} + b_{{ij}}$

### 3.2.1 Example 1

$$\left\lbrack A \right\rbrack = \begin{bmatrix} 5 & 2 & 3 \\ 1 & 2 & 7 \\ \end{bmatrix}$$ $$\left\lbrack B \right\rbrack = \begin{bmatrix} 6 & 7 & - 2 \\ 3 & 5 & 19 \\ \end{bmatrix}$$

Solution

$\begin{split} \left\lbrack C \right\rbrack &= \left\lbrack A \right\rbrack + \left\lbrack B \right\rbrack\\ &= \begin{bmatrix} 5 & 2 & 3 \\ 1 & 2 & 7 \\ \end{bmatrix} + \begin{bmatrix} 6 & 7 & - 2 \\ 3 & 5 & 19 \\ \end{bmatrix}\\ &= \begin{bmatrix} 5 + 6 & 2 + 7 & 3 - 2 \\ 1 + 3 & 2 + 5 & 7 + 19 \\ \end{bmatrix}\\ &= \begin{bmatrix} 11 & 9 & 1 \\ 4 & 7 & 26 \\ \end{bmatrix} \end{split}$

### 3.2.2 Example 2

Blowout r’us store has two store locations $$A$$ and $$B$$, and their sales of tires are given by make (in rows) and quarters (in columns) as shown below.

$\left\lbrack A \right\rbrack = \begin{bmatrix} \begin{matrix} 25 & 20 \\ \end{matrix} & \begin{matrix} 3 & 2 \\ \end{matrix} \\ \begin{matrix} 5 & 10 \\ \end{matrix} & \begin{matrix} 15 & 25 \\ \end{matrix} \\ \begin{matrix} 6 & 16 \\ \end{matrix} & \begin{matrix} 7 & 27 \\ \end{matrix} \\ \end{bmatrix}$

$\left\lbrack B \right\rbrack = \begin{bmatrix} \begin{matrix} 20 & 5 \\ \end{matrix} & \begin{matrix} 4 & 0 \\ \end{matrix} \\ \begin{matrix} 3 & 6 \\ \end{matrix} & \begin{matrix} 15 & 21 \\ \end{matrix} \\ \begin{matrix} 4 & 1 \\ \end{matrix} & \begin{matrix} 7 & 20 \\ \end{matrix} \\ \end{bmatrix}$

where the rows represent the sale of Tirestone, Michigan and Copper tires respectively and the columns represent the quarter number: 1, 2, 3 and 4. What are the total tire sales for the two locations by make and quarter?

Solution

$\begin{split} \left\lbrack C \right\rbrack &= \left\lbrack A \right\rbrack + \left\lbrack B \right\rbrack\\ &= \begin{bmatrix} \begin{matrix} 25 & 20 \\ \end{matrix} & \begin{matrix} 3 & 2 \\ \end{matrix} \\ \begin{matrix} 5 & 10 \\ \end{matrix} & \begin{matrix} 15 & 25 \\ \end{matrix} \\ \begin{matrix} 6 & 16 \\ \end{matrix} & \begin{matrix} 7 & 27 \\ \end{matrix} \\ \end{bmatrix} + \begin{bmatrix} \begin{matrix} 20 & 5 \\ \end{matrix} & \begin{matrix} 4 & 0 \\ \end{matrix} \\ \begin{matrix} 3 & 6 \\ \end{matrix} & \begin{matrix} 15 & 21 \\ \end{matrix} \\ \begin{matrix} 4 & 1 \\ \end{matrix} & \begin{matrix} 7 & 20 \\ \end{matrix} \\ \end{bmatrix}\\ &= \left\lbrack \begin{matrix} \left( 25 + 20 \right) \\ \left( 5 + 3 \right) \\ \left( 6 + 4 \right) \\ \end{matrix}\begin{matrix} \left( 20 + 5 \right) \\ \left( 10 + 6 \right) \\ \left( 16 + 1 \right) \\ \end{matrix}\begin{matrix} \left( 3 + 4 \right) \\ \left( 15 + 15 \right) \\ \left( 7 + 7 \right) \\ \end{matrix}\begin{matrix} \left( 2 + 0 \right) \\ \left( 25 + 21 \right) \\ \left( 27 + 20 \right) \\ \end{matrix} \right\rbrack\\ &= \left\lbrack \begin{matrix} 45 \\ 8 \\ 10 \\ \end{matrix}\begin{matrix} 25 \\ 16 \\ 17 \\ \end{matrix}\begin{matrix} 7 \\ 30 \\ 14 \\ \end{matrix}\begin{matrix} 2 \\ 46 \\ 47 \\ \end{matrix} \right\rbrack \end{split}$

So, if one wants to know the total number of Copper tires sold in quarter $$4$$ at the two locations, we would look at Row $$3$$ – Column $$4$$ to give $$c_{34} = 47$$.

## 3.3 How do you subtract two matrices?

Two matrices $$\left\lbrack A \right\rbrack$$ and $$\left\lbrack B \right\rbrack$$ can be subtracted only if they are the same size. The subtraction is then shown as

$\left\lbrack D \right\rbrack = \left\lbrack A \right\rbrack - \left\lbrack B \right\rbrack$

where

$d_{{ij}} = a_{{ij}} - b_{{ij}}$

### 3.3.1 Example 3

Subtract matrix $$\left\lbrack B \right\rbrack$$ from matrix $$\left\lbrack A \right\rbrack$$.

$\left\lbrack A \right\rbrack = \begin{bmatrix} 5 & 2 & 3 \\ 1 & 2 & 7 \\ \end{bmatrix}$

$\left\lbrack B \right\rbrack = \begin{bmatrix} 6 & 7 & - 2 \\ 3 & 5 & 19 \\ \end{bmatrix}$

Solution

$\begin{split} \left\lbrack D \right\rbrack &= \left\lbrack A \right\rbrack - \left\lbrack B \right\rbrack\\ &= \begin{bmatrix} 5 & 2 & 3 \\ 1 & 2 & 7 \\ \end{bmatrix} - \begin{bmatrix} 6 & 7 & - 2 \\ 3 & 5 & 19 \\ \end{bmatrix}\\ &= \begin{bmatrix} \left( 5 - 6 \right) & \left( 2 - 7 \right) & \left( 3 - \left( - 2 \right) \right) \\ \left( 1 - 3 \right) & \left( 2 - 5 \right) & \left( 7 - 19 \right) \\ \end{bmatrix}\\ &= \begin{bmatrix} - 1 & - 5 & 5 \\ - 2 & - 3 & - 12 \\ \end{bmatrix} \end{split}$

### 3.3.2 Example 4

Blowout r’us has two store locations $$A$$ and $$B$$ and their sales of tires are given by make (in rows) and quarters (in columns) as shown below.

$\left\lbrack A \right\rbrack = \left\lbrack \begin{matrix} 25 \\ 5 \\ 6 \\ \end{matrix}\begin{matrix} 20 \\ 10 \\ 16 \\ \end{matrix}\begin{matrix} 3 \\ 15 \\ 7 \\ \end{matrix}\begin{matrix} 2 \\ 25 \\ 27 \\ \end{matrix} \right\rbrack$

$\left\lbrack B \right\rbrack = \left\lbrack \begin{matrix} 20 \\ 3 \\ 4 \\ \end{matrix}\begin{matrix} 5 \\ 6 \\ 1 \\ \end{matrix}\begin{matrix} 4 \\ 15 \\ 7 \\ \end{matrix}\begin{matrix} 0 \\ 21 \\ 20 \\ \end{matrix} \right\rbrack$

where the rows represent the sale of Tirestone, Michigan and Copper tires respectively and the columns represent the quarter number: 1, 2, 3, and 4. How many more tires did store $$A$$ sell than store $$B$$ of each brand in each quarter?

Solution

$\begin{split} \left\lbrack D \right\rbrack &= \left\lbrack A \right\rbrack - \left\lbrack B \right\rbrack\\ &= \left\lbrack \begin{matrix} 25 \\ 5 \\ 6 \\ \end{matrix}\begin{matrix} 20 \\ 10 \\ 16 \\ \end{matrix}\begin{matrix} 3 \\ 15 \\ 7 \\ \end{matrix}\begin{matrix} 2 \\ 25 \\ 27 \\ \end{matrix} \right\rbrack - \left\lbrack \begin{matrix} 20 \\ 3 \\ 4 \\ \end{matrix}\begin{matrix} 5 \\ 6 \\ 1 \\ \end{matrix}\begin{matrix} 4 \\ 15 \\ 7 \\ \end{matrix}\begin{matrix} 0 \\ 21 \\ 20 \\ \end{matrix} \right\rbrack\\ &= \left\lbrack \begin{matrix} \left( 25 - 20 \right) \\ \left( 5 - 3 \right) \\ \left( 6 - 4 \right) \\ \end{matrix}\begin{matrix} \left( 20 - 5 \right) \\ \left( 10 - 6 \right) \\ \left( 16 - 1 \right) \\ \end{matrix}\begin{matrix} \left( 3 - 4 \right) \\ \left( 15 - 15 \right) \\ \left( 7 - 7 \right) \\ \end{matrix}\begin{matrix} \left( 2 - 0 \right) \\ \left( 25 - 21 \right) \\ \left( 27 - 20 \right) \\ \end{matrix} \right\rbrack\\ &= \left\lbrack \begin{matrix} 5 \\ 2 \\ 2 \\ \end{matrix}\begin{matrix} 15 \\ 4 \\ 15 \\ \end{matrix}\begin{matrix} - 1 \\ 0 \\ 0 \\ \end{matrix}\begin{matrix} 2 \\ 4 \\ 7 \\ \end{matrix} \right\rbrack \end{split}$

So, if you want to know how many more Copper tires were sold in quarter $$4$$ in store $$A$$ than store $$B$$, $$d_{34} = 7$$. Note that $$d_{13} = - 1$$ implies that store $$A$$ sold 1 less Michigan tire than store $$B$$ in quarter $$3$$.

## 3.4 How do I multiply two matrices?

Two matrices $$\left\lbrack A \right\rbrack$$ and $$\left\lbrack B \right\rbrack$$ can be multiplied only if the number of columns of $$\left\lbrack A \right\rbrack$$ is equal to the number of rows of $$\left\lbrack B \right\rbrack$$ to give

$\left\lbrack C \right\rbrack_{m \times n} = \left\lbrack A \right\rbrack_{m \times p}\left\lbrack B \right\rbrack_{p \times n}$

If $$\left\lbrack A \right\rbrack$$ is a $$m \times p$$ matrix and $$\left\lbrack B \right\rbrack$$ is a $$p \times n$$ matrix, the resulting matrix $$\left\lbrack C \right\rbrack$$ is a $$m \times n$$ matrix.

So how does one calculate the elements of $$\left\lbrack C \right\rbrack$$ matrix?

$\begin{split} c_{{ij}} &= \sum_{k = 1}^{p}{a_{{ik}}b_{{kj}}}\\ &= a_{i1}b_{1j} + a_{i2}b_{2j} + \ldots + a_{{ip}}b_{{pj}} \end{split}$

for each $$i = 1,\ 2,\ \ldots\ \ ,\ m$$ and $$j = 1,\ 2,\ \ldots\ \ ,\ n$$.

To put it in simpler terms, the $$i^{{th}}$$ row and $$j^{{th}}$$ column of the $$\left\lbrack C \right\rbrack$$ matrix in $$\left\lbrack C \right\rbrack = \left\lbrack A \right\rbrack\left\lbrack B \right\rbrack$$ is calculated by multiplying the $$i^{{th}}$$ row of $$\left\lbrack A \right\rbrack$$ by the $$j^{{th}}$$ column of $$\left\lbrack B \right\rbrack$$. That is

$\begin{split} c_{{ij}} &= \left\lceil a_{i1}a_{i2}\ \ \ldots\ \ \ a_{\text{ip}} \right\rceil\begin{bmatrix} \begin{matrix} b_{1j} \\ b_{2j} \\ \end{matrix} \\ \begin{matrix} \vdots \\ b_{\text{pj}} \\ \end{matrix} \\ \end{bmatrix}\\ &= a_{i1}b_{1j} + a_{i2}b_{2j} + \ldots + a_{\text{ip}}b_{\text{pj}}\\ &= \sum_{k = 1}^{p}{a_{\text{ik}}b_{\text{kj}}} \end{split}$

### 3.4.1 Example 5

Given

$\left\lbrack A \right\rbrack = \begin{bmatrix} 5 & 2 & 3 \\ 1 & 2 & 7 \\ \end{bmatrix}$

$\left\lbrack B \right\rbrack = \begin{bmatrix} 3 & - 2 \\ 5 & - 8 \\ 9 & - 10 \\ \end{bmatrix}$

Find

$\left\lbrack C \right\rbrack = \left\lbrack A \right\rbrack\left\lbrack B \right\rbrack$

Solution

$$c_{12}$$ can be found by multiplying the first row of $$\left\lbrack A \right\rbrack$$ by the second column of $$\left\lbrack B \right\rbrack$$,

$\begin{split} c_{12} &= \begin{bmatrix} 5 & 2 & 3 \\ \end{bmatrix}\begin{bmatrix} -2 \\ -8 \\ -10 \\ \end{bmatrix}\\ &= \left( 5 \right)\left( - 2 \right) + \left( 2 \right)\left( - 8 \right) + \left( 3 \right)\left( - 10 \right)\\ &= -56 \end{split}$

Similarly, one can find the other elements of $$\left\lbrack C \right\rbrack$$ to give

$\left\lbrack C \right\rbrack = \begin{bmatrix} 52 & - 56 \\ 76 & - 88 \\ \end{bmatrix}$

### 3.4.2 Example 6

Blowout r’us store location $$A$$ and the sales of tires are given by make (in rows) and quarters (in columns) as shown below

$\left\lbrack A \right\rbrack = \left\lbrack \begin{matrix} 25 \\ 5 \\ 6 \\ \end{matrix}\begin{matrix} 20 \\ 10 \\ 16 \\ \end{matrix}\begin{matrix} 3 \\ 15 \\ 7 \\ \end{matrix}\begin{matrix} 2 \\ 25 \\ 27 \\ \end{matrix} \right\rbrack$

where the rows represent the sale of Tirestone, Michigan and Copper tires respectively and the columns represent the quarter number: 1, 2, 3, and 4. Find the per quarter sales of store $$A$$ if the following are the prices of each tire:

Tirestone = $$\33.25$$

Michigan = $$\40.19$$

Copper = $$\25.03$$

Solution

The answer is given by multiplying the price matrix by the quantity of sales of store $$A$$. The price matrix is $$\begin{bmatrix} 33.25 & 40.19 & 25.03 \\ \end{bmatrix}$$, so the per-quarter sales of store $$A$$ would be given by:

$\left\lbrack C \right\rbrack = \begin{bmatrix} 33.25 & 40.19 & 25.03 \\ \end{bmatrix}\left\lbrack \begin{matrix} 25 \\ 5 \\ 6 \\ \end{matrix}\begin{matrix} 20 \\ 10 \\ 16 \\ \end{matrix}\begin{matrix} 3 \\ 15 \\ 7 \\ \end{matrix}\begin{matrix} 2 \\ 25 \\ 27 \\ \end{matrix} \right\rbrack$

$c_{{ij}} = \sum_{k = 1}^{3}{a_{{ik}}b_{{kj}}}$

$\begin{split} c_{11} &= \sum_{k = 1}^{3}{a_{1k}b_{k1}}\\ &= a_{11}b_{11} + a_{12}b_{21} + a_{13}b_{31}\\ &= \left( 33.25 \right)\left( 25 \right) + \left( 40.19 \right)\left( 5 \right) + \left( 25.03 \right)\left( 6 \right)\\ &= \text{\} 1182.38 \end{split}$

Similarly

$c_{12} = \ 1467.38$

$c_{13} = \ 877.81$

$c_{14} = \ 1747.06$

Therefore, each quarter sales of store $$A$$ in dollars is given by the four columns of the row vector

$\left\lbrack C \right\rbrack = \left\lbrack 1182.38\ \ \ 1467.38\ \ \ 877.81\ \ \ 1747.06 \right\rbrack$

Remember, since we are multiplying a $$1 \times 3$$ matrix by a $$3 \times 4$$ matrix, the resulting matrix is a $$1 \times 4$$ matrix.

## 3.5 What is the scalar multiplication of a matrix?

If $$\left\lbrack A \right\rbrack$$ is a $$m \times n$$ matrix and $$k$$ is a real number, then the multiplication $$\left\lbrack A \right\rbrack$$ by a scalar $$k$$ is another $$m \times n$$ matrix $$\left\lbrack B \right\rbrack$$, where

$$b_{{ij}} = k\ a_{{ij}}$$ for all $$i,\ j$$.

### 3.5.1 Example 7

Let

$\left\lbrack A \right\rbrack = \begin{bmatrix} 2.1 & 3 & 2 \\ 5 & 1 & 6 \\ \end{bmatrix}$

Find $$2\left\lbrack A \right\rbrack$$

Solution

$\begin{split} 2\left\lbrack A \right\rbrack &= 2\begin{bmatrix} 2.1 & 3 & 2 \\ 5 & 1 & 6 \\ \end{bmatrix}\\ &= \begin{bmatrix} 2 \times 2.1 & 2 \times 3 & 2 \times 2 \\ 2 \times 5 & 2 \times 1 & 2 \times 6 \\ \end{bmatrix}\\ & = \begin{bmatrix} 4.2 & 6 & 4 \\ 10 & 2 & 12 \\ \end{bmatrix} \end{split}$

## 3.6 What is a linear combination of matrices?

If $$\left\lbrack A_{1} \right\rbrack,\left\lbrack A_{2} \right\rbrack,\ \ldots\ ,\ \left\lbrack A_{p} \right\rbrack$$ are matrices of the same size and $$k_{1},\ k_{2},\ \ldots\ ,\ k_{p}$$ are scalars, then

$k_{1}\left\lbrack A_{1} \right\rbrack + k_{2}\left\lbrack A_{2} \right\rbrack + \ \ldots\ + k_{p}\left\lbrack A_{p} \right\rbrack$

is called a linear combination of $$\left\lbrack A_{1} \right\rbrack,\left\lbrack A_{2} \right\rbrack,\ \ldots\ ,\ \left\lbrack A_{p} \right\rbrack$$.

### 3.6.1 Example 8

If

$\left\lbrack A_{1} \right\rbrack = \begin{bmatrix} 5 & 6 & 2 \\ 3 & 2 & 1 \\ \end{bmatrix},\ \left\lbrack A_{2} \right\rbrack = \begin{bmatrix} 2.1 & 3 & 2 \\ 5 & 1 & 6 \\ \end{bmatrix},\ \left\lbrack A_{3} \right\rbrack = \begin{bmatrix} 0 & 2.2 & 2 \\ 3 & 3.5 & 6 \\ \end{bmatrix}$

then find

$\left\lbrack A_{1} \right\rbrack + 2\left\lbrack A_{2} \right\rbrack - 0.5\left\lbrack A_{3} \right\rbrack$

Solution

$\left\lbrack A_{1} \right\rbrack + 2\left\lbrack A_{2} \right\rbrack - 0.5\left\lbrack A_{3} \right\rbrack$

$\begin{split} &= \begin{bmatrix} 5 & 6 & 2 \\ 3 & 2 & 1 \\ \end{bmatrix} + 2\begin{bmatrix} 2.1 & 3 & 2 \\ 5 & 1 & 6 \\ \end{bmatrix} - 0.5\begin{bmatrix} 0 & 2.2 & 2 \\ 3 & 3.5 & 6 \\ \end{bmatrix}\\ &= \begin{bmatrix} 5 & 6 & 2 \\ 3 & 2 & 1 \\ \end{bmatrix} + \begin{bmatrix} 4.2 & 6 & 4 \\ 10 & 2 & 12 \\ \end{bmatrix} - 0.5\begin{bmatrix} 0 & 1.1 & 1 \\ 1.5 & 1.75 & 3 \\ \end{bmatrix}\\ &= \begin{bmatrix} 9.2 & 10.9 & 5 \\ 11.5 & 2.25 & 10 \\ \end{bmatrix} \end{split}$

## 3.7 What are some of the rules of binary matrix operations?

### 3.7.1 Commutative law of addition

If $$\left\lbrack A \right\rbrack$$ and $$\left\lbrack B \right\rbrack$$ are $$m \times n$$ matrices, then

$\left\lbrack A \right\rbrack + \left\lbrack B \right\rbrack = \left\lbrack B \right\rbrack + \left\lbrack A \right\rbrack$

### 3.7.2 Associative law of addition

If $$\left\lbrack A \right\rbrack$$, $$\left\lbrack B \right\rbrack$$, and $$\left\lbrack C \right\rbrack$$ are all $$m \times n$$ matrices, then

$\left\lbrack A \right\rbrack + \left( \left\lbrack B \right\rbrack + \left\lbrack C \right\rbrack \right) = \left( \left\lbrack A \right\rbrack + \left\lbrack B \right\rbrack \right) + \left\lbrack C \right\rbrack$

### 3.7.3 Associative law of multiplication

If $$\left\lbrack A \right\rbrack$$, $$\left\lbrack B \right\rbrack$$, and $$\left\lbrack C \right\rbrack$$ are $$m \times n$$, $$n \times p$$, and $$p \times r$$ size matrices, respectively, then

$\left\lbrack A \right\rbrack\left( \left\lbrack B \right\rbrack\left\lbrack C \right\rbrack \right) = \left( \left\lbrack A \right\rbrack\left\lbrack B \right\rbrack \right)\left\lbrack C \right\rbrack$

and the resulting matrix size on both sides of the equation is $$m \times p$$.

### 3.7.4 Distributive law

If $$\left\lbrack A \right\rbrack$$ and $$\left\lbrack B \right\rbrack$$ are $$m \times n$$ size matrices, and $$\left\lbrack C \right\rbrack$$ and $$\left\lbrack D \right\rbrack$$ are $$n \times p$$ size matrices

$\left\lbrack A \right\rbrack\left( \left\lbrack C \right\rbrack + \left\lbrack D \right\rbrack \right) = \left\lbrack A \right\rbrack\left\lbrack C \right\rbrack + \left\lbrack A \right\rbrack\left\lbrack D \right\rbrack$

$\left( \left\lbrack A \right\rbrack + \left\lbrack B \right\rbrack \right)\left\lbrack C \right\rbrack = \left\lbrack A \right\rbrack\left\lbrack C \right\rbrack + \left\lbrack B \right\rbrack\left\lbrack C \right\rbrack$

And the resulting matrix size on both sides of the equation is $$m \times p$$.

### 3.7.5 Example 9

Illustrate the associative law of multiplication of matrices using

$\left\lbrack A \right\rbrack = \begin{bmatrix} 1 & 2 \\ 3 & 5 \\ 0 & 2 \\ \end{bmatrix},\ \ \ \ \left\lbrack B \right\rbrack = \begin{bmatrix} 2 & 5 \\ 9 & 6 \\ \end{bmatrix},\ \ \ \ \left\lbrack C \right\rbrack = \begin{bmatrix} 2 & 1 \\ 3 & 5 \\ \end{bmatrix}$

Solution

$\begin{split} \left\lbrack B \right\rbrack\left\lbrack C \right\rbrack &= \begin{bmatrix} 2 & 5 \\ 9 & 6 \\ \end{bmatrix}\begin{bmatrix} 2 & 1 \\ 3 & 5 \\ \end{bmatrix}\\ &= \begin{bmatrix} 19 & 27 \\ 36 & 39 \\ \end{bmatrix} \end{split}$

$\begin{split} \left\lbrack A \right\rbrack\left( \left\lbrack B \right\rbrack\left\lbrack C \right\rbrack \right) &= \begin{bmatrix} 1 & 2 \\ 3 & 5 \\ 0 & 2 \\ \end{bmatrix}\begin{bmatrix} 19 & 27 \\ 36 & 39 \\ \end{bmatrix}\\ &= \begin{bmatrix} 91 & 105 \\ 237 & 276 \\ 72 & 78 \\ \end{bmatrix} \end{split}$

$\begin{split} \left\lbrack A \right\rbrack\left\lbrack B \right\rbrack &= \begin{bmatrix} 1 & 2 \\ 3 & 5 \\ 0 & 2 \\ \end{bmatrix}\begin{bmatrix} 2 & 5 \\ 9 & 6 \\ \end{bmatrix}\\ &= \begin{bmatrix} 20 & 17 \\ 51 & 45 \\ 18 & 12 \\ \end{bmatrix} \end{split}$

$\begin{split} \left( \left\lbrack A \right\rbrack\left\lbrack B \right\rbrack \right)\left\lbrack C \right\rbrack &= \begin{bmatrix} 20 & 17 \\ 51 & 45 \\ 18 & 12 \\ \end{bmatrix}\begin{bmatrix} 2 & 1 \\ 3 & 5 \\ \end{bmatrix}\\ &= \begin{bmatrix} 91 & 105 \\ 237 & 276 \\ 72 & 78 \\ \end{bmatrix} \end{split}$

The above illustrates the associative law of multiplication of matrices.

## 3.8 Is [A][B] = [B][A]?

If $$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack$$ exists, number of columns of $$\left\lbrack A \right\rbrack$$ has to be same as the number of rows of $$\left\lbrack B \right\rbrack$$ and if $$\left\lbrack B \right\rbrack\left\lbrack A \right\rbrack$$ exists, number of columns of $$\left\lbrack B \right\rbrack$$ has to be same as the number of rows of $$\left\lbrack A \right\rbrack$$. Now for $$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack = \left\lbrack B \right\rbrack\left\lbrack A \right\rbrack$$, the resulting matrix from $$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack$$ and $$\left\lbrack B \right\rbrack\left\lbrack A \right\rbrack$$ has to be of the same size. This is only possible if $$\left\lbrack A \right\rbrack$$ and $$\left\lbrack B \right\rbrack$$ are square and are of the same size. Even then in general $$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack \neq \left\lbrack B \right\rbrack\left\lbrack A \right\rbrack$$

### 3.8.1 Example 10

Determine if

$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack = \left\lbrack B \right\rbrack\left\lbrack A \right\rbrack$

For the following matrices

$\left\lbrack A \right\rbrack = \begin{bmatrix} 6 & 3 \\ 2 & 5 \\ \end{bmatrix},\ \ \ \ \left\lbrack B \right\rbrack = \begin{bmatrix} - 3 & 2 \\ 1 & 5 \\ \end{bmatrix}$

Solution

$\begin{split} \left\lbrack A \right\rbrack\left\lbrack B \right\rbrack &= \begin{bmatrix} 6 & 3 \\ 2 & 5 \\ \end{bmatrix}\begin{bmatrix} - 3 & 2 \\ 1 & 5 \\ \end{bmatrix}\\ &= \begin{bmatrix} - 15 & 27 \\ - 1 & 29 \\ \end{bmatrix} \end{split}$

$\begin{split} \left\lbrack B \right\rbrack\left\lbrack A \right\rbrack &= \begin{bmatrix} - 3 & 2 \\ 1 & 5 \\ \end{bmatrix}\begin{bmatrix} 6 & 3 \\ 2 & 5 \\ \end{bmatrix}\\ &= \begin{bmatrix} - 14 & 1 \\ 16 & 28 \\ \end{bmatrix} \end{split}$

$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack \neq \left\lbrack B \right\rbrack\left\lbrack A \right\rbrack$

## 3.9 Binary Matrix Operations Quiz

(1). If $$\left\lbrack A \right\rbrack = \begin{bmatrix} 5 & 6 \\ 7 & - 3 \\ \end{bmatrix}$$and $$\left\lbrack B \right\rbrack = \begin{bmatrix} 2 \\ - 3 \\ \end{bmatrix}$$ then $$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack =$$

(A) $$\begin{bmatrix} - 8 \\ 23 \\ \end{bmatrix}$$

(B) $$\begin{bmatrix} 10 & 12 \\ 14 & 9 \\ \end{bmatrix}$$

(C) $$\begin{bmatrix} - 2 & 5 \\ \end{bmatrix}$$

(D) not possible

(2). For the product $$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack$$to be possible

(A) the number of rows of $$\left\lbrack A \right\rbrack$$ needs to be the ame as the number of columns of $$\left\lbrack B \right\rbrack$$

(B) the number of columns of $$\left\lbrack A \right\rbrack$$ needs to be the same as the number of rows of $$\left\lbrack B \right\rbrack$$

(C) the number of rows of $$\left\lbrack A \right\rbrack$$ and$$\left\lbrack B \right\rbrack$$ needs to be the same

(D) the number of columns of $$\left\lbrack A \right\rbrack$$ and$$\left\lbrack B \right\rbrack$$ needs to be the same

(3). If $$\left\lbrack A \right\rbrack = \begin{bmatrix} 50 & 60 \\ 20 & - 30 \\ \end{bmatrix}$$ then 6$$\left\lbrack A \right\rbrack$$is equal to

(A) $$\begin{bmatrix} 50 & 360 \\ 120 & - 180 \\ \end{bmatrix}$$

(B) $$\begin{bmatrix} 300 & 60 \\ 20 & - 30 \\ \end{bmatrix}$$

(C) $$\begin{bmatrix} 300 & 360 \\ 120 & - 180 \\ \end{bmatrix}$$

(D) $$\begin{bmatrix} 56 & 66 \\ 26 & - 24 \\ \end{bmatrix}$$

(4). $$\left\lbrack A \right\rbrack$$ and $$\left\lbrack B \right\rbrack$$ are square matrices of $$n \times n$$ order. Then $$(\left\lbrack A \right\rbrack - \left\lbrack B \right\rbrack)(\left\lbrack A \right\rbrack - \left\lbrack B \right\rbrack)$$ is equal to

(A) $$\left\lbrack A \right\rbrack^{2} + \left\lbrack B \right\rbrack^{2} - 2\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack$$

(B) $$\left\lbrack A \right\rbrack^{2} + \left\lbrack B \right\rbrack^{2}$$

(C) $$\left\lbrack A \right\rbrack^{2} - \left\lbrack B \right\rbrack^{2}$$

(D) $$\left\lbrack A \right\rbrack^{2} + \left\lbrack B \right\rbrack^{2} - \left\lbrack A \right\rbrack\left\lbrack B \right\rbrack - \left\lbrack B \right\rbrack\left\lbrack A \right\rbrack$$

(5). Given $$\left\lbrack A \right\rbrack$$ is a rectangular matrix and $$c\left\lbrack A \right\rbrack = \left\lbrack 0 \right\rbrack$$, then choose the most appropriate answer.

(A) $$C = 0$$

(B) $$C = 0$$ and $$\left\lbrack A \right\rbrack = \left\lbrack 0 \right\rbrack$$

(C) $$C = 0$$ or $$\left\lbrack A \right\rbrack = \left\lbrack 0 \right\rbrack$$

(D) $$C = 0$$ and $$\left\lbrack A \right\rbrack$$ is a non-zero matrix

(6). You sell Jupiter and Fickers Candy bars. The sales in January are 25 and 30 of Jupiter and Fickers, respectively. In February, the sales are 75 and 35 of Jupiter and Fickers, respectively. If a Jupiter bar costs $2 and a Fickers bar costs$7, then if

$\left\lbrack A \right\rbrack = \begin{bmatrix} 25 & 30 \\ 75 & 35 \\ \end{bmatrix}, \;\; and$

$\left\lbrack B \right\rbrack = \begin{bmatrix} 2 \\ 7 \\ \end{bmatrix},$

the total sales amount in each month is given by

(A) $$\left\lbrack B \right\rbrack\left\lbrack A \right\rbrack$$

(B) $$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack$$

(C) $$2\left\lbrack A \right\rbrack$$

(D) $$7\left\lbrack A \right\rbrack$$

## 3.10 Binary Matrix Operations Exercise

(1). For the following matrices

$$\lbrack A\rbrack = \begin{bmatrix} \begin{matrix} 3 \\ - 1 \\ \end{matrix} & \begin{matrix} 0 \\ 2 \\ \end{matrix} \\ 1 & 1 \\ \end{bmatrix}$$, $$\lbrack B\rbrack = \begin{bmatrix} 4 & - 1 \\ 0 & 2 \\ \end{bmatrix}$$, $$\lbrack C\rbrack = \begin{bmatrix} \begin{matrix} 5 \\ 3 \\ \end{matrix} & \begin{matrix} 2 \\ 5 \\ \end{matrix} \\ 6 & 7 \\ \end{bmatrix}$$

Find where possible

1. $$4\lbrack A\rbrack + 5\lbrack C\rbrack$$

2. $$\lbrack A\rbrack\lbrack B\rbrack$$

3. $$\lbrack A\rbrack = 2\lbrack C\rbrack$$

1. $$= \begin{bmatrix} \begin{matrix} 37 \\ 11 \\ \end{matrix} & \begin{matrix} 10 \\ 33 \\ \end{matrix} \\ 34 & 39 \\ \end{bmatrix}$$

2. $$= \begin{bmatrix} 12 & - 3 \\ - 4 & 5 \\ 4 & 1 \\ \end{bmatrix}$$

3. $$= \begin{bmatrix} - 7 & - 4 \\ - 7 & - 8 \\ - 11 & - 13 \\ \end{bmatrix}$$

(2). Food orders are taken from two engineering departments for a takeout. The order is tabulated below.

Food order:

$\begin{matrix} \text{Mechanical} \\ \text{Civil} \\ \end{matrix}\overset{\begin{matrix} \begin{matrix} \text{Chicken} \\ \text{Sandwich} \\ \end{matrix} & \text{Fries} & \text{Drink} \\ \end{matrix}}{\begin{bmatrix} 25\ \ & 35 & \ \ 25 \\ 21\ \ & 20 & \ \ 21 \\ \end{bmatrix}}$

However they have a choice of buying this food from three different restaurants. Their prices for the three food items are tabulated below

Price Matrix:

$\begin{matrix} \text{Chicken} \ \ \text{Sandwich} \\ \text{Fries} \\ \text{Drink} \\ \end{matrix}\overset{\begin{matrix} \text{McFat} & \text{Burcholestrol} & \begin{matrix} \text{Kentucky} \\ \text{Sodium} \\ \end{matrix} \\ \end{matrix}}{\begin{bmatrix} 2.42\ \ \ \ & 2.38 & \ \ 2.46 \\ 0.93\ \ \ \ & 0.90 & \ \ 0.89 \\ 0.95\ \ \ \ & 1.03 & \ \ 1.13 \\ \end{bmatrix}}$

Show how much each department will pay for their order at each restaurant. Which restaurant would be more economical to order from for each department?

Answer: The cost in dollars is 116.80, 116.75, 120.90 for the Mechanical Department at three fast food joints. So BurCholestrol is the cheapest for the Mechanical Department. The cost in dollars is 89.37, 89.61, 93.19 for the Civil Department at three fast food joints. McFat is the cheapest for the Civil Department.

(3). Given

$$\left\lbrack A \right\rbrack = \begin{bmatrix} 2 & 3 & 5 \\ 6 & 7 & 9 \\ 2 & 1 & 3 \\ \end{bmatrix}$$

$$\left\lbrack B \right\rbrack = \begin{bmatrix} 3 & 5 \\ 2 & 9 \\ 1 & 6 \\ \end{bmatrix}$$

$$\left\lbrack C \right\rbrack = \begin{bmatrix} 5 & 2 \\ 3 & 9 \\ 7 & 6 \\ \end{bmatrix}$$

Illustrate the distributive law of binary matrix operations

$$\left\lbrack A \right\rbrack\left( \left\lbrack B \right\rbrack + \left\lbrack C \right\rbrack \right) = \left\lbrack A \right\rbrack\left\lbrack B \right\rbrack + \left\lbrack A \right\rbrack\left\lbrack C \right\rbrack$$

Answer: $\left\lbrack B \right\rbrack + \left\lbrack C \right\rbrack = \begin{bmatrix} 3 & 5 \\ 2 & 9 \\ 1 & 6 \\ \end{bmatrix} + \begin{bmatrix} 5 & 2 \\ 3 & 9 \\ 7 & 6 \\ \end{bmatrix}$

$= \begin{bmatrix} 8 & 7 \\ 5 & 18 \\ 8 & 12 \\ \end{bmatrix}$

$\left\lbrack A \right\rbrack\left( \left\lbrack B \right\rbrack + \left\lbrack C \right\rbrack \right) = \begin{bmatrix} 71 & 128 \\ 155 & 276 \\ 45 & 68 \\ \end{bmatrix}$

$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack = \begin{bmatrix} 17 & 67 \\ 41 & 147 \\ 11 & 37 \\ \end{bmatrix}$

$\left\lbrack A \right\rbrack\left\lbrack C \right\rbrack = \begin{bmatrix} 54 & 61 \\ 114 & 129 \\ 34 & 31 \\ \end{bmatrix}$

$\left\lbrack A \right\rbrack\left\lbrack B \right\rbrack + \left\lbrack A \right\rbrack\left\lbrack C \right\rbrack = \begin{bmatrix} 71 & 128 \\ 155 & 276 \\ 45 & 68 \\ \end{bmatrix}$

(4). Let $$\lbrack I\rbrack$$ be a $$n \times n$$ identity matrix. Show that $$\lbrack A\rbrack\lbrack\lbrack I\rbrack = \lbrack I\rbrack\lbrack A\rbrack = \lbrack A\rbrack$$ for every $$n \times n$$ matrix $$\lbrack A\rbrack$$.

Let $$\left\lbrack C \right\rbrack_{n \times n} = \left\lbrack A \right\rbrack_{n \times n}\left\lbrack I \right\rbrack_{n \times n}$$

Answer: Hint: $$c_{{ij}} = \sum_{p = 1}^{n}a_{{ip}}i_{{pj}}$$

$$= a_{i1}i_{1j} + \ldots\ldots + a_{i,j - 1}i_{j - 1,j} + a_{{ij}}i_{{jj}} + a_{i\left( j + 1 \right)}i_{\left( j + 1 \right)j} + \ldots\ldots + a_{{in}}i_{{nj}}$$

Since

$$i_{{ij}} = 0$$ for $$i \neq j$$

$$= 1$$ for $$i = j$$

$$c_{{ij}} = a_{{ij}}$$

So $$\left\lbrack A \right\rbrack = \left\lbrack A \right\rbrack\left\lbrack I \right\rbrack$$

Similarly do the other case

$$\left\lbrack I \right\rbrack\left\lbrack A \right\rbrack = \left\lbrack A \right\rbrack$$. Just do it!

(5). Consider there are only two computer companies in a country. The companies are named Dude and Imac. Each year, company Dude keeps 1/5th of its customers, while the rest switch to Imac. Each year, Imac keeps 1/3rd of its customers, while the rest switch to Dude. If in 2002, Dude has $$1/6^th$$ of the market and Imac has $$5/6^th$$ of the market.

1. What is the distribution of the customers between the two companies in 2003? Write the answer first as multiplication of two matrices.

2. What would be distribution when the market becomes stable?

1. At the end of 2002, Dude has
$$\frac{1}{5} \times \frac{1}{6} + \frac{2}{3} \times \frac{5}{6} = 0.589$$.
Imac has
$$\frac{4}{5} \times \frac{1}{6} + \frac{1}{3} \times \frac{5}{6} = 0.411$$
In matrix form $$\begin{bmatrix} \frac{1}{5} & \frac{2}{3} \\ \frac{4}{5} & \frac{1}{3} \\ \end{bmatrix}\begin{bmatrix} \frac{1}{6} \\ \frac{5}{6} \\ \end{bmatrix} = \begin{bmatrix} 0.589 \\ 0.411 \\ \end{bmatrix}$$

2. Stable distribution is [10/22 12/22] (Try to do this part of the problem first by finding the distribution five years from now).

(6). Given

$$\lbrack A\rbrack = \begin{bmatrix} 12.3 & - 12.3 & 10.3 \\ 11.3 & - 10.3 & - 11.3 \\ 10.3 & - 11.3 & - 12.3 \\ \end{bmatrix}$$,

$$\lbrack B\rbrack = \begin{bmatrix} 2 & 4 \\ - 5 & 6 \\ 11 & - 20 \\ \end{bmatrix}$$

$$[A][B]$$ matrix size is _______________

Answer: $$3 \times 2$$

(7). Given

$$\lbrack A\rbrack = \begin{bmatrix} 12.3 & - 12.3 & 10.3 \\ 11.3 & - 10.3 & - 11.3 \\ 10.3 & - 11.3 & - 12.3 \\ \end{bmatrix}$$,

$$\lbrack B\rbrack = \begin{bmatrix} 2 & 4 \\ - 5 & 6 \\ 11 & - 20 \\ \end{bmatrix}$$

if $$\left\lbrack C \right\rbrack = \left\lbrack A \right\rbrack\left\lbrack B \right\rbrack$$, then $$c_{31}$$= _____________________

Answer: $$(10.3 \times 2) + (( - 5) \times ( - 11.3)) + (11 \times ( - 12.3)) = - 58.2$$