# Matrix Multiplication Review

## Overview

Matrices are a way of grouping numbers, and are organized into rows and columns. Matrices are often used as a way of representing several equations in an easier to organize format, however to solve these systems of equations we must be able to perform matrix operations such as multiplication.

## Rows and Columns

The below matrix is an example of a [3x2] matrix. Matrices are described in the form [RxC] where R represents the number of matrix rows and C represents the number of matrix columns.

The above matrix is a [3x2] because it has 3 rows and 2 columns.

## Multiplication by a Scalar

Any matrix can be multiplied by a what is known as a scalar quantity. In this case a scalar represents a real number that is multiplied by the entire matrix. For example:

## Matrix Multiplication

It is also possible to multiply two matrices together, however matrices can only be multiplied if the number of columns of the first matrix is equal to the number of rows of the second matrix. If the two matrices fit this criteria, they can be multiplied. The result will be a third matrix with as many rows as in the first matrix and as many columns as in the second matrix.

### Example

Can the following matrices be multiplied? What will be the dimensions of the answer?

[2x3] * [2x2]

[3x2] * [2x2]

[2*3] * [3*1]

### Answer

1. We cannot multiply these matrices because matrix 1 has three columns and matrix 2 has only two rows.

2. We can multiply these matrices because matrix 1 has two columns and matrix 2 has 2 rows. The resulting matrix will have as many rows as matrix 1 and columns as matrix 2 - so it will be a [3x2].

3. We can multiply these two matrices because matrix 1 has three columns and matrix 2 has three rows. The result will be a [2x1].

**Note**: This exercise should have made clear that order matters when multiplying two matrices. Try flipping the order of any of the above examples and see if the result changes.

## Matrix Multiplication Rules

Once we know if two matrices can be multiplied, it's time to carry out that multiplication. Multiplication of two matrices is also known as a "dot product". Each number in the answer matrix is the result of multiplying one of the rows of matrix 1 by one of the columns of matrix 2.

To find row one, column one of the answer matrix, multiply row one of matrix 1 by column one of matrix 2. To find row 1, column 2 of the answer matrix, multiply row one of matrix 1 by column two of matrix 2. When multiplying a row by a column, matching terms are multiplied and added together.

**Example**: Find the dot product of the two matrices

Matrix 1 has two columns and Matrix 2 has two rows so the two can be multiplied. The answer will have two rows because Matrix 1 has two rows and three columns because Matrix 2 has three columns. Thus the answer will be [2x3].

Let's say we first want to find the upper left corner of the answer matrix (marked with X). Because the spot we want to find is in row 1 column 1, we must multiply row 1 of the first matrix by column 1 of the second matrix. The row and column that must be multiplied are marked by arrows.

When multiplying the row and column, we multiply multiply the first number in the row by the first number in the column, multiply the second number in the row by the second number in the column, and add the result.

To find the bottom left corner of the answer matrix we repeat the same process. Because the spot we are solving for is located in the second row and first column of the answer matrix, we must multiply row two of the first matrix by column one of the second matrix.

The process is repeated again for row 2, column 2:

After multiplying all rows and columns as shown in the previous steps, the answer matrix is complete.