Hello. Here is a guide on matrix multiplication in the field of linear algebra.

Matrix multiplication is an operation similar to addition, subtraction, multiplication and division but it is for matrices.

Before we get into matrix multiplication, let’s review the dimensions of a matrix.

 


Dimensions of Matrices

 

Suppose we have a matrix such as:

\[A = \begin{bmatrix} 8 & 2 & 1\\ -1 & -2 & 0 \\ \end{bmatrix}\]

 

This matrix \(A\) has 2 rows and 3 columns. Rows go from left to right and follow a horizontal fashion while columns are from top to bottom in a vertical manner. Since \(A\) has 2 rows and 3 columns, we say that \(A\) is a 2 by 3 matrix.

The first row of A contain the entries 8, 2 and 1 and the second row contains the entries of -1, -2 and 0.

With the columns, the first column of A has 8 and -1, the second column has 2 and -2 and the last column has 1 and 0.

Suppose we have a matrix B which is:

\[B = \begin{bmatrix} 1 & 4 & 10\\ -1 & 7 & -5 \\ 2 & 9 & 3 \\ \end{bmatrix}\]

The matrix \(B\) has 3 rows and 3 columns. Whenever a matrix has the same number of rows as it does the number of columns,we say that the matrix is a square matrix. In this case, B is a square matrix. In Linear Algebra, square matrices have a lot neat and special properties.

 


 

In regular multiplication, two numbers are needed to create an answer called the product. Two times three gives six for example.

Matrix multiplication does not operate exactly like regular multiplication but it does require two matrices under a certain condition to create an output.

Instead of showing the general formula, a simple example will be shown first.

Suppose we have

 

\[C = \begin{bmatrix} 1 & -1 \end{bmatrix}\]

 

which is a 1 by 2 matrix and a 2 by 2 matrix \(D = \begin{bmatrix} 5 & 3\\ -1 & 0 \\ \end{bmatrix}\).

We can matrix multiply the matrix \(C\) with \(D\) to create \(CD\) since the number of columns of \(C\) matches the number of rows from the matrix \(D\) which is 2.

Matrix multiplying to get \(DC\) is not possible as the number of columns in \(D\) is 2 which does not match the one row in matrix \(C\).

The resulting matrix \(CD\) from matrix multiplication is a 1 by 2 matrix. The matrix \(CD\) has one row from the one row from \(C\) and \(CD\) has 2 columns from the 2 columns of \(D\). The matrix \(CD\) is:

 

\[CD = \begin{bmatrix} (5 \times 1) + (-1 \times -1) & (1 \times 3) + (-1 \times 0)\\ \end{bmatrix} = \begin{bmatrix} 6 & 3 \end{bmatrix}\]

 

The first entry of the first row in \(C\) is multiplied by the first entry in the first column of \(D\) added by the second entry in the first row of \(C\) multiplied by the second entry in the first column of \(D\). This gives the 6 as the first row, first column entry in \(CD\).

To get the 3, we use the row from \(C\) but use the second column from \(D\).


A Guideline

If the matrix \(A\) has \(r_1\) many rows and \(c_1\) many columns and if the matrix \(B\) has \(r_2\) many rows and \(c_2\) many columns then the matrix \(AB\) exists if \(c_1 = r_2\). That is, the number of columns in \(A\) is equal to the number of rows in \(B\).

The resulting matrix \(AB\) would have \(r_1\) many rows and \(c_2\) many columns.

% Image: http://www.coolmath.com/sites/cmat/files/images/04-matrices-03.gif


 

Examples

 

Example One

 

Given the matrices \(A = \begin{bmatrix} 1 & -2 \\ 3 & -1 \\ \end{bmatrix}\) and \(B = \begin{bmatrix} 1 \\ 2 \end{bmatrix}\), does \(AB\) exist? If so, what is \(AB\)? Does \(BA\) exist? If so, what is \(BA\)?

 

Solution:

 

The matrix \(A\) is a 2 by 2 matrix and \(B\) is a 2 by 1 matrix. The matrix \(AB\) does exist since the number of columns in \(A\) matches the number of rows in \(B\) which is 2.

Through matrix multiplication, \(AB\) is:

 

\[AB = \begin{bmatrix} (1 \times 1) + (-2 \times 2)\\ (3 \times 1) + (-1 \times 2) \\ \end{bmatrix} = \begin{bmatrix} (1 - 4)\\ (3 - 2)\\ \end{bmatrix} = \begin{bmatrix} -3\\ 1\\ \end{bmatrix}\]

 

Example Two

 

In this example we are given:

 

\[A = \begin{bmatrix} 1 & 7 \\ 3 & 2 \\ 4 & 6 \\ \end{bmatrix} \]

 

and

 

\[B = \begin{bmatrix} 1 & 0 & 5\\ 0 & 4 & 2 \\ 1 & 1 & 0 \\ \end{bmatrix}\]

 

What is BA?

The matrix \(B\) is a 3 by 3 matrix and \(A\) is a 3 by 2 matrix. Matrix multiplication can be applied and \(BA\) would be a 3 by 2 matrix.

 

\[BA = \begin{bmatrix} 1 & 0 & 5\\ 0 & 4 & 2 \\ 1 & 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & 7 \\ 3 & 2 \\ 4 & 6 \\ \end{bmatrix} \]  

\[ BA = \begin{bmatrix} (1 \times 1 + 0 \times 3+ 5 \times 4) & (1 \times 7 + 0 \times 2 + 5 \times 6)\\ (0 \times 1 + 4 \times 3+ 2 \times 4) & (0 \times 7 + 4 \times 2 + 2 \times 6)\\ (1 \times 1 + 1 \times 3+ 0 \times 4) & (1 \times 7 + 1 \times 2 + 0 \times 6) \\ \end{bmatrix} \]

 

\[ BA = \begin{bmatrix} (1 + 0 + 20) & (7 + 0 + 30)\\ (0 + 12 + 8) & (0 + 8 + 12)\\ (1 + 3 + 0) & (7 + 2 + 0)\\ \end{bmatrix} \]

 

\[ BA = \begin{bmatrix} 21 & 37\\ 20 & 20\\ 4 & 9\\ \end{bmatrix}\]

 


Notes

 

Matrix multiplication is used often when dealing with matrices. You first learn this topic by hand as an introduction.

When matrices get larger the use of computer software such as R, MATLAB, Python, C, C++ would be preferred.