topic badge
Middle Years

14.03 Matrix multiplication

Lesson

When can we multiply?

Two matrices can be multiplied if the number of columns in the first matrix is equal to the number of rows in the second.

If matrix $A$A has dimension $m\times n$m×n and matrix $B$B as dimension $a\times b$a×b then the multiplication is defined if $n=a$n=a and  the dimension of the result $C=AB$C=AB will be $m\times b$m×b.

As shown in the following diagram:

If the dimensions do not meet this criteria then we say that the matrix multiplication is undefined

For example consider the following matrices A, B and C where,

,   ,   

A is a $2\times2$2×2 matrix, B is a $2\times1$2×1 matrix and C is a $1\times2$1×2 matrix.

  •  $A\times B$A×B is a $(2\times2)\times(2\times1)$(2×2)×(2×1) this is defined and the result would be a $2\times1$2×1 matrix.
  • $B\times C$B×C is a $(2\times1)\times(1\times2)$(2×1)×(1×2) this is defined and the result would be a$2\times2$2×2 matrix.
  • $A\times C$A×C is a $(2\times2)\times(1\times2)$(2×2)×(1×2) this is undefined.

How do we multiply?

Unlike matrix addition and subtraction, matrix multiplication is not computed element by element.

Let's look at an example of multiplication before we generalise the result.

If we take the elements in the first row, and multiply them by the elements in the first column, then sum them up then we end up with the a number that belongs in the spot occupying the first row and first column.

 So $5\times6+12\times1+56\times7=434$5×6+12×1+56×7=434 goes into the $\left(1,1\right)$(1,1) entry.

The next combination will be the first row and the second column.  Take the sum of the elements in the first row multiplied by the elements in second column.

So, $5\times3+12\times2+56\times2=151$5×3+12×2+56×2=151 goes into the $\left(1,2\right)$(1,2) entry.

The next combination will be the second row and the first column.  Take the sum of the elements in the second row multiplied by the elements in first column.

So $10\times6+30\times1+75\times7=615$10×6+30×1+75×7=615 goes into the $\left(2,1\right)$(2,1) entry.

The final combination is the second row and the second column.  Take the sum of the elements in the second row multiplied by the elements in second column.

So $10\times3+30\times2+75\times2=240$10×3+30×2+75×2=240 goes into the $\left(2,2\right)$(2,2) entry.

Remember!

In general, to compute the $\left(i,j\right)$(i,j)-element in the matrix $AB$AB, we multiply the elements of the $i$ith row in $A$A with the elements in the $j$jth column of $B$B, and sum all the products. For a pair of $2\times2$2×2 matrices, this looks like:

Practice questions

QUESTION 1

Consider $A$A$=$=   $-7$7 $-3$3 $-1$1   .
$5$5 $7$7 $-6$6

If $A$A is to be multiplied by $B$B, a column matrix, what are the dimensions of $B$B?

  1. $\editable{}$$\times$×$\editable{}$

QUESTION 2

Consider $A$A$=$=
    $-1$1 $-3$3    
    $-9$9 $-4$4    
    $4$4 $-5$5    
and $B$B$=$=
    $3$3    
    $-8$8    
.
  1. Is the product $AB$AB defined?

    Yes

    A

    No

    B
  2. What are the dimensions of $AB$AB?

    $\editable{}$$\times$×$\editable{}$

  3. Determine the matrix $AB$AB.

    $AB$AB$=$=
        $-1$1 $-3$3    
        $-9$9 $-4$4    
        $4$4 $-5$5    
        $3$3    
        $-8$8    
    $=$=
        $\editable{}$    
        $\editable{}$    
        $\editable{}$    

 

Real life applications

Worked example

An organic gardener produces lettuces and tomatoes.  The following table indicates the time taken for each of the growing stages.

 

Stage 1

Germination from seed (days)

Stage 2

from sprout to seedling (days)

Stage 3

from seedling to maturity (days)

Lettuce $5$5 $12$12 $56$56
Tomato $10$10 $30$30 $75$75

The amount of water per day needed for Stage 1 is $60$60 mL, for Stage 2 is $40$40 mL and Stage 3 is $30$30 mL. 

Work out the amount of water needed for both the lettuce and tomato.

Think: First, let's construct two matrices. 

Let $D$D be the matrix of days needed in each stage:

And let $W$W be the matrix of water needed:

 

Do: To work out the total amount of water needed we will multiply $D$D by $W$W. It is important to note that we multiply$D$D by $W$W  not only because the dimensions match, but also because the headings of the columns of $D$D (stages) match the headings of the rows of $W$W (also stages).

 

This tells us that $2460$2460 mL is used in raising a lettuce plant ($2.46$2.46 L) and $4050$4050 mL is used for each tomato plant ($4.05$4.05 L).

Practice questions

QUESTION 3

Frank owns two pizza stores, Panania Pizza and Penrith Pizza, at which he sells small pizzas for $\$7$$7, medium-sized pizzas for $\$15$$15 and large pizzas for $\$28$$28.

The table shows the number of pizzas sold at each store on a particular day.

  Small Medium Large
Panania Pizza $21$21 $25$25 $12$12
Penrith Pizza $26$26 $11$11 $22$22
  1. Organise the prices into the column matrix in ascending size order.

    $A$A$=$=
        $\editable{}$    
        $\editable{}$    
        $\editable{}$    
  2. Organise the number of pizzas sold into the matrix as given in the table.

    $B$B$=$=
        $\editable{}$ $\editable{}$ $\editable{}$    
        $\editable{}$ $\editable{}$ $\editable{}$    
  3. Calculate Frank's total revenue for each store by finding $BA$BA.

    $BA$BA$=$=
        $21$21 $25$25 $12$12    
        $26$26 $11$11 $22$22    
        $7$7    
        $15$15    
        $28$28    
    $=$=
        $\editable{}$    
        $\editable{}$    

QUESTION 4

A local bakery was selling three different products yesterday. The tables show the price that each product was sold for and the amount sold.

Price
Meat pie Croissant Bread roll
$\$5$$5 $\$3$$3 $\$4$$4
Quantity sold
Meat pie $22$22
Croissant $13$13
Bread roll $35$35
  1. Organise the prices of each product into the row matrix in the order given in the table.

    $A$A$=$=
        $\editable{}$ $\editable{}$ $\editable{}$    
  2. Organise the quantity sold of each product into the column matrix in the order given in the table.

    $B$B$=$=
        $\editable{}$    
        $\editable{}$    
        $\editable{}$    
  3. Calculate the bakery's total revenue for the day by finding $AB$AB.

    $AB$AB$=$=
        $5$5 $3$3 $4$4    
        $22$22    
        $13$13    
        $35$35    
    $=$=
        $\editable{}$    

 

Matrix multiplication and using the calculator

Let's look at how we can use our calculator to perform multiplication with matrices.

TI Nspire

How to use the TI Nspire to complete the following tasks regarding matrices

If $A$A$=$=    $1$1  $5$5  $6$6     $B$B$=$=    $3$3  $0$0     and $C$C$=$=    $-2$2  $2$2    
   $3$3  $4$4  $5$5       $-1$1  $2$2       $1$1  $5$5  

Find where possible:

  1. $2BA$2BA

  2. $(B+C)A$(B+C)A

  3. $AB$AB

 

What is Mathspace

About Mathspace