# 4. Multiplication of Matrices

**Important:** We can only multiply matrices if the number of columns in the first matrix is the same as the number of rows in the second matrix.

### Example 1

a) Multiplying a 2 × 3 matrix by a 3 × 4 matrix is possible and it gives a 2 × 4 matrix as the answer.

b) Multiplying a 7 × 1 matrix by a 1 × 2 matrix is okay; it gives a 7 × 2 matrix

c) A 4 × 3 matrix times a 2 × 3 matrix is NOT possible.

## How to Multiply 2 Matrices

We use letters first to see what is going on. We'll see a numbers example after.

As an example, let's take a general 2 × 3 matrix multiplied by a 3 × 2 matrix.

`[(a,b,c),(d,e,f)][(u,v),(w,x),(y,z)]`

The answer will be a 2 × 2 matrix.

We multiply and add the elements as follows. We work **across** the 1st row of the first matrix, multiplying **down** the 1st column of the second matrix, element by element. We **add** the resulting products. Our answer goes in position *a*_{11} (top left) of the answer matrix.

We do a similar process for the 1st row of the first matrix and the **2nd** column of the second matrix. The result is placed in position *a*_{12}.

Now for the **2nd** row of the first matrix and the **1st** column of the second matrix. The result is placed in position *a*_{21}.

Finally, we do the 2nd row of the first matrix and the 2nd column of the second matrix. The result is placed in position *a*_{22}.

So the result of multiplying our 2 matrices is as follows:

`[(a,b,c),(d,e,f)][(u,v),(w,x),(y,z)]=[(au+bw+cy,av+bx+cz),(du+ew+fy,dv+ex+fz)]`

Now let's see a number example.

### Example 2

Multiply:

`((0,-1,2),(4,11,2))((3,-1),(1,2),(6,1))`

## Multiplying 2 × 2 Matrices

The process is the same for any size matrix. We multiply **across** rows of the first matrix and **down** columns of the second matrix, element by element. We then add the products:

`((a,b),(c,d))((e,f),(g,h))=((ae+bg,af+bh),(ce+dg,cf+dh))`

In this case, we multiply a 2 × 2 matrix by a 2 × 2 matrix and we get a 2 × 2 matrix as the result.

### Example 3

Multiply:

`((8,9),(5,-1))((-2,3),(4,0))`

## Matrices and Systems of Simultaneous Linear Equations

We now see how to write a system of linear equations using matrix multiplication.

### Example 4

The system of equations

−3

x+y= 16

x− 3y= −4

can be written as:

`((-3,1),(6,-3))((x),(y))=((1),(-4))`

Matrices are ideal for computer-driven solutions of problems because computers easily form *arrays*. We can leave out the algebraic symbols. A computer only requires the first and last matrices to solve the system, as we will see in Matrices and Linear Equations.

## Note 1 - Notation

Care with **writing** matrix multiplication.

The following expressions have **different meanings:**

ABismatrix multiplication

A×Biscrossproduct, which returns avector

A*Bused in computer notation, but not on paper

A•Bdotproduct, which returns ascalar.

[See the Vector chapter for more information on vector and scalar quantities.]

## Note 2 - Commutativity of Matrix Multiplication

Does `AB = BA`?

Let's see if it is true using an example.

### Example 5

If

`A=((0,-1,2),(4,11,2))`

and

`B=((3,-1),(1,2),(6,1))`

find *AB* and *BA.*

In general, when multiplying matrices, the commutative law doesn't hold, i.e. *AB* ≠ *BA*. There are two common exceptions to this:

- The identity matrix:
*IA*=*AI*=*A*. - The
**inverse**of a matrix:*A*^{-1}*A*=*AA*^{-1}=*I.*

In the next section we learn how to find the inverse of a matrix.

### Example 6 - Multiplying by the Identity Matrix

Given that

`A=((-3,1,6),(3,-1,0),(4,2,5))`

find *AI*.

## Exercises

1. If possible, find *BA* and *AB*.

`A=((-2,1,7),(3,-1,0),(0,2,-1))`

`B=(4\ \ -1\ \ \ 5)`

2. Determine if *B* = *A*^{-1}, given:

`A=((3,-4),(5,-7))`

`B=((7,4),(5,3))`

3. In studying the motion of electrons, one of the Pauli spin matrices is

`s=((0,-j),(j,0))`

where

`j=sqrt(-1)`

Show that *s*^{2} = *I.*

[If you have never seen *j* before, go to the section on complex numbers].

4. Evaluate the following matrix multiplication which is used in directing the motion of a robotic mechanism.

`( (cos\ 60° ,-sin\ 60° ,0),(sin\ 60°, cos\ 60°,0),(0,0,1))((2),(4),(0))`

## Matrix Multiplication interactives

### Search IntMath, blog and Forum

### Online Algebra Solver

This algebra solver can solve a wide range of math problems.

Go to: Online algebra solver

### Algebra Lessons on DVD

Easy to understand algebra lessons on DVD. See samples before you commit.

More info: Algebra videos

### The IntMath Newsletter

Sign up for the free **IntMath Newsletter**. Get math study tips, information, news and updates each fortnight. Join thousands of satisfied students, teachers and parents!