How to do matrix multiplication?

Matrix multiplication is the process of multiplying two matrices together, resulting in a new matrix. To multiply two matrices, the number of columns in the first matrix must match the number of rows in the second matrix. The result of the multiplication is a matrix with the same number of rows as the first matrix and the same number of columns as the second matrix. The individual values of the resulting matrix are determined by multiplying each row of the first matrix by each column of the second matrix and then adding the products.


Introduction

Suppose we have a 2×2 matrix A, which has 2 rows and 2 columns:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.super_short2 {
max-width: 180px;
margin: 5px auto;
color: blue;
}

A =
  A11 A12  
A21 A22

Suppose we also have a 2×3 matrix B, which has 2 rows and 3 columns:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.short2 {
max-width: 250px;
margin: 5px auto;
color: red;
}

B =
  B11 B12 B13  
B21 B22 B23

To multiply matrix A by matrix B, we use the following formula:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.long{
margin: 5px auto;
color: #000000;
}
.red {
color: red;
}
.blue {
color: blue;
}

A x B =
  A11*B11+A12*B21 A11*B12+A12*B22 A11*B13+A12*B23  
A21*B11+A22*B21 A21*B12+A22*B22 A21*B13+A22*B23

This results in a 2×3 matrix.

The following examples illustrate how to multiply a 2×2 matrix with a 2×3 matrix using real numbers.

Example 1

Suppose we have a 2×2 matrix C, which has 2 rows and 2 columns:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.super_short {
max-width: 150px;
margin: 5px auto;
color: #000000;
}

C =
  7 5  
6 3

Suppose we also have a 2×3 matrix D, which has 2 rows and 3 columns:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.short {
max-width: 250px;
margin: 5px auto;
color: #000000;
}

D =
  2 1 4  
5 1 2

Here is how to multiply matrix C by matrix D:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.medium {
max-width: 500px;
margin: 5px auto;
color: #000000;
}
.red {
color: red;
}
.blue {
color: blue;
}

C x D =
  7*2 + 5*5 7*1 + 5*1 7*4 + 5*2  
6*2 + 3*5 6*1 + 3*1 6*4 + 3*2

This results in the following matrix:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.short {
max-width: 250px;
margin: 5px auto;
color: #000000;
}

C x D =
  39 12 38  
27 9 30

Example 2

Suppose we have a 2×2 matrix E, which has 2 rows and 2 columns:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.super_short {
max-width: 150px;
margin: 5px auto;
color: #000000;
}

E =
  -2 4  
9 2

Suppose we also have a 2×3 matrix F, which has 2 rows and 3 columns:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.short {
max-width: 250px;
margin: 5px auto;
color: #000000;
}

F =
  3 6 9  
2 4 6

Here is how to multiply matrix E by matrix F:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.medium {
max-width: 500px;
margin: 5px auto;
color: #000000;
}
.red {
color: red;
}
.blue {
color: blue;
}

E x F =
  -2*3 + 4*2 -2*6 + 4*4 -2*9 + 4*6  
9*3 + 2*2 9*6 + 2*4 9*9 + 2*6

This results in the following matrix:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.short {
max-width: 250px;
margin: 5px auto;
color: #000000;
}

E x F =
  2 4 6  
31 62 93

Example 3

Suppose we have a 2×2 matrix G, which has 2 rows and 2 columns:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.super_short {
max-width: 150px;
margin: 5px auto;
color: #000000;
}

G =
  2 3  
4 5

Suppose we also have a 2×3 matrix H, which has 2 rows and 3 columns:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.short {
max-width: 250px;
margin: 5px auto;
color: #000000;
}

H =
  1 2 3  
4 5 6

Here is how to multiply matrix G by matrix H:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.medium {
max-width: 500px;
margin: 5px auto;
color: #000000;
}
.red {
color: red;
}
.blue {
color: blue;
}

G x H =
  2*1 + 3*4 2*2 + 3*5 2*3 + 3*6  
4*1 + 5*4 4*2 + 5*5 4*3 + 5*6

This results in the following matrix:

table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
}
td.tdleft {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-left: solid 1px #000;
width: 5px;
padding: 0;
}
td.tdreg {
padding: 2px 1px;
text-align: center;
border-bottom: solid 1px #fff;
}
td.tdright {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
border-right: solid 1px #000;
width: 5px;
padding: 0;
}
.short {
max-width: 250px;
margin: 5px auto;
color: #000000;
}

G x H =
  14 19 24  
24 33 42

Matrix Calculator

The examples above illustrated how to multiply 2×2 matrices by hand. A good way to double check your work if you’re multiplying matrices by hand is to confirm your answers with a matrix calculator. While there are many matrix calculators online, the simplest one to use that I have come across is this one by Math is Fun.

Multiplying Matrices Video Tutorial: (2×2) by (2×3)

https://www.youtube.com/watch?v=yeKJbi8-heE
x