Linear Algebra – A Guide To Matrix Multiplication

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.

Update: The LaTeX parts are fixed in the later part of this page. The QuickLatex plugin did not work. It was fixed by using the QuickLaTeX website itself. From the website I copied and pasted the images.


Topics


Dimensions of Matrices

Suppose we have a matrix such as:

Source: http://quicklatex.com/cache3/ff/ql_8e266a1616f4752d1bdfd50c42f928ff_l3.png

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:

Source: http://quicklatex.com/cache3/32/ql_26ae83ac1f1d4cf96d31622d0963d732_l3.png

 

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.


Matrix Multiplication

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

Source: http://quicklatex.com/cache3/0a/ql_2bea377eca38241cae8d1c6ed0d18f0a_l3.png.

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.

The image from http://www.coolmath.com/sites/cmat/files/images/04-matrices-03.gif is provides a nice summary and guideline for matrix multiplication.

 

 


Examples

Example One

Given the matrices

http://quicklatex.com/cache3/c0/ql_c4ca4be2a32a2546ff724d6433ed5cc0_l3.png

and

Source: http://quicklatex.com/cache3/9a/ql_df0d88b7355f9e90222ee75a0dcbc59a_l3.png

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:

Source: http://quicklatex.com/cache3/b0/ql_e4c83e14cc0c106a9546df898a47ceb0_l3.png

Example Two

In this example we are given:

Source: http://quicklatex.com/cache3/ec/ql_4cb253d6dacc35d2f3cbf42329336dec_l3.png

 

and

Source: http://quicklatex.com/cache3/9e/ql_b6afb7413d37ed50a93224b15fda799e_l3.png

 

What is BA?

Solution:

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.

 

Source: http://quicklatex.com/cache3/07/ql_264cd4bda3398f193d876278d88cbc07_l3.png

 

Source: http://quicklatex.com/cache3/b7/ql_47c71d955ef278e9d5b264f71724d6b7_l3.png

 

Source: http://quicklatex.com/cache3/b2/ql_68e3569074fc9be0988ed434d7addab2_l3.png

 

Source: http://quicklatex.com/cache3/6f/ql_afb11cfcf24d855e8aabe0b14e83b06f_l3.png

 


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.

Given matrices A and B the command for matrix multiplication in the statistical program R is

The featured image is from http://d1gjlxt8vb0knt.cloudfront.net//wp-content/uploads/strassen_new.png.