Skip to main content
Logo image

Section 2.2 Matrix multiplication and linear combinations

The previous section introduced vectors and linear combinations and demonstrated how they provide a way to think about linear systems geometrically. In particular, we saw that the vector b is a linear combination of the vectors v1,v2,,vn precisely when the linear system corresponding to the augmented matrix
[v1v2vnb]
is consistent.
Our goal in this section is to introduce matrix multiplication, another algebraic operation that deepens the connection between linear systems and linear combinations.

Subsection 2.2.1 Scalar multiplication and addition of matrices

We first thought of a matrix as a rectangular array of numbers. If we say that the shape of a matrix is m×n, we mean that it has m rows and n columns. For instance, the shape of the matrix below is 3×4:
[043131202011].
We may also think of the columns of a matrix as a set of vectors. For instance, the matrix above may be represented as
[v1v2v3v4]
where
v1=[032],v2=[410],v3=[321],v4=[101].
In this way, we see that the 3×4 matrix is equivalent to an ordered set of 4 vectors in R3.
This means that we may define scalar multiplication and matrix addition operations using the corresponding column-wise vector operations. For instance,
c[v1v2vn]=[cv1cv2cvn][v1v2vn]+[w1w2wn]=[v1+w1v2+w2vn+wn].

Preview Activity 2.2.1. Matrix operations.

  1. Compute the scalar multiple
    3[310431].
  2. Find the sum
    [031234]+[412211].
  3. Suppose that A and B are two matrices. What do we need to know about their shapes before we can form the sum A+B?
  4. The matrix In, which we call the identity matrix, is the n×n matrix whose entries are zero except for the diagonal entries, all of which are 1. For instance,
    I3=[100010001].
    If we can form the sum A+In, what must be true about the matrix A?
  5. Find the matrix A2I3 where
    A=[122233234].
As this preview activity shows, the operations of scalar multiplication and addition of matrices are natural extensions of their vector counterparts. Some care, however, is required when adding matrices. Since we need the same number of vectors to add and since those vectors must be of the same dimension, two matrices must have the same shape if we wish to form their sum.

Subsection 2.2.2 Matrix-vector multiplication and linear combinations

A more important operation will be matrix multiplication as it allows us to compactly express linear systems. We now introduce the product of a matrix and a vector with an example.

Example 2.2.1. Matrix-vector multiplication.

Suppose we have the matrix A and vector x:
A=[230231],   x=[23].
Their product will be defined to be the linear combination of the columns of A using the components of x as weights. This means that
Ax=[230231][23]=2[203]+3[321]=[406]+[963]=[569].
Because A has two columns, we need two weights to form a linear combination of those columns, which means that x must have two components. In other words, the number of columns of A must equal the dimension of the vector x.
Similarly, the columns of A are 3-dimensional so any linear combination of them is 3-dimensional as well. Therefore, Ax will be 3-dimensional.
We then see that if A is a 3×2 matrix, x must be a 2-dimensional vector and Ax will be 3-dimensional.
More generally, we have the following definition.

Definition 2.2.2. Matrix-vector multiplication.

The product of a matrix A by a vector x will be the linear combination of the columns of A using the components of x as weights. More specifically, if
A=[v1v2vn],   x=[c1c2cn],
then
Ax=c1v1+c2v2++cnvn.
If A is an m×n matrix, then x must be an n-dimensional vector, and the product Ax will be an m-dimensional vector.
The next activity explores some properties of matrix multiplication.

Activity 2.2.2. Matrix-vector multiplication.

  1. Find the matrix product
    [120124321261][3111].
  2. Suppose that A is the matrix
    [310024215103].
    If Ax is defined, what is the dimension of the vector x and what is the dimension of Ax?
  3. A vector whose entries are all zero is denoted by 0. If A is a matrix, what is the product A0?
  4. Suppose that I=[100010001] is the identity matrix and x=[x1x2x3]. Find the product Ix and explain why I is called the identity matrix.
  5. Suppose we write the matrix A in terms of its columns as
    A=[v1v2vn].
    If the vector e1=[100], what is the product Ae1?
  6. Suppose that
    A=[1211],b=[60].
    Is there a vector x such that Ax=b?
Multiplication of a matrix A and a vector is defined as a linear combination of the columns of A. However, there is a shortcut for computing such a product. Let’s look at our previous example and focus on the first row of the product.
[230231][23]=2[2]+3[3]=[2(2)+3(3)]=[5].
To find the first component of the product, we consider the first row of the matrix. We then multiply the first entry in that row by the first component of the vector, the second entry by the second component of the vector, and so on, and add the results. In this way, we see that the third component of the product would be obtained from the third row of the matrix by computing 2(3)+3(1)=9.
You are encouraged to evaluate the product Item a of the previous activity using this shortcut and compare the result to what you found while completing that activity.

Activity 2.2.3.

Sage can find the product of a matrix and vector using the * operator. For example,
  1. Use Sage to evaluate the product
    [120124321261][3111]
    from Item a of the previous activity.
  2. In Sage, define the matrix and vectors
    A=[203142],0=[00],v=[23],w=[12].
  3. What do you find when you evaluate A0?
  4. What do you find when you evaluate A(3v) and 3(Av) and compare your results?
  5. What do you find when you evaluate A(v+w) and Av+Aw and compare your results?
This activity demonstrates several general properties satisfied by matrix multiplication that we record here.

Subsection 2.2.3 Matrix-vector multiplication and linear systems

So far, we have begun with a matrix A and a vector x and formed their product Ax=b. We would now like to turn this around: beginning with a matrix A and a vector b, we will ask if we can find a vector x such that Ax=b. This will naturally lead back to linear systems.
To see the connection between the matrix equation Ax=b and linear systems, let’s write the matrix A in terms of its columns vi and x in terms of its components.
A=[v1v2vn],x=[c1c2cn].
We know that the matrix product Ax forms a linear combination of the columns of A. Therefore, the equation Ax=b is merely a compact way of writing the equation for the weights ci:
c1v1+c2v2++cnvn=b.
We have seen this equation before: Remember that Proposition 2.1.12 says that the solutions of this equation are the same as the solutions to the linear system whose augmented matrix is
[v1v2vnb].
This gives us three different ways of looking at the same solution space.
When the matrix A=[v1v2vn], we will frequently write
[v1v2vnb]=[Ab]
and say that the matrix A is augmented by the vector b.
The equation Ax=b gives a notationally compact way to write a linear system. Moreover, this notation will allow us to focus on important features of the system that determine its solution space.

Example 2.2.5.

We will describe the solution space of the equation
[202416135]x=[0515].
By Proposition 2.2.4, this equation may be equivalently expressed as
x1[241]+x2[013]+x3[265]=[0515],
which is the linear system corresponding to the augmented matrix
[2020416513515].
The reduced row echelon form of the augmented matrix is
[2020416513515][101001250000],
which corresponds to the linear system
x1+x3=0x22x3=5.
The variable x3 is free so we may write the solution space parametrically as
x1=x3x2=5+2x3.
Since we originally asked to describe the solutions to the equation Ax=b, we will express the solution in terms of the vector x:
x=[x1x2x3]=[x35+2x3x3]=[050]+x3[121]
As before, we call this a parametric description of the solution space.
This shows that the solutions x may be written in the form v+x3w, for appropriate vectors v and w. Geometrically, the solution space is a line in R3 through v moving parallel to w.

Activity 2.2.4. The equation Ax=b.

  1. Consider the linear system
    2x+y3z=4x+2y+z=33xy=4.
    Identify the matrix A and vector b to express this system in the form Ax=b.
  2. If A and b are as below, write the linear system corresponding to the equation Ax=b and describe its solution space, using a parametric description if appropriate:
    A=[310206],   b=[62].
  3. Describe the solution space of the equation
    [120124321261]x=[115].
  4. Suppose A is an m×n matrix. What can you guarantee about the solution space of the equation Ax=0?

Subsection 2.2.4 Matrix-matrix products

In this section, we have developed some algebraic operations on matrices with the aim of simplifying our description of linear systems. We now introduce a final operation, the product of two matrices, that will become important when we study linear transformations in Section 2.5.

Definition 2.2.6. Matrix-matrix multiplication.

Given matrices A and B, we form their product AB by first writing B in terms of its columns
B=[v1v2vp]
and then defining
AB=[Av1Av2Avp].

Example 2.2.7.

Given the matrices
A=[42013420],   B=[230122],
we have
AB=[A[21]A[32]A[02]]=[61641221018460].

Observation 2.2.8.

It is important to note that we can only multiply matrices if the shapes of the matrices are compatible. More specifically, when constructing the product AB, the matrix A multiplies the columns of B. Therefore, the number of columns of A must equal the number of rows of B. When this condition is met, the number of rows of AB is the number of rows of A, and the number of columns of AB is the number of columns of B.

Activity 2.2.5.

Consider the matrices
A=[132341],   B=[301221].
  1. Before computing, first explain why the shapes of A and B enable us to form the product AB. Then describe the shape of AB.
  2. Compute the product AB.
  3. Sage can multiply matrices using the * operator. Define the matrices A and B in the Sage cell below and check your work by computing AB.
  4. Are we able to form the matrix product BA? If so, use the Sage cell above to find BA. Is it generally true that AB=BA?
  5. Suppose we form the three matrices.
    A=[1232],B=[0421],C=[1343].
    Compare what happens when you compute A(B+C) and AB+AC. State your finding as a general principle.
  6. Compare the results of evaluating A(BC) and (AB)C and state your finding as a general principle.
  7. When we are dealing with real numbers, we know if a0 and ab=ac, then b=c. Define matrices
    A=[1224],B=[3013],C=[1222]
    and compute AB and AC.
    If AB=AC, is it necessarily true that B=C?
  8. Again, with real numbers, we know that if ab=0, then either a=0 or b=0. Define
    A=[1224],B=[2412]
    and compute AB.
    If AB=0, is it necessarily true that either A=0 or B=0?
This activity demonstrated some general properties about products of matrices, which mirror some properties about operations with real numbers.

Properties of Matrix-matrix Multiplication.

If A, B, and C are matrices such that the following operations are defined, it follows that
Associativity:
A(BC)=(AB)C.
Distributivity:
A(B+C)=AB+AC.
(A+B)C=AC+BC.
At the same time, there are a few properties that hold for real numbers that do not hold for matrices.

Caution.

The following properties hold for real numbers but not for matrices.
Commutativity:
It is not generally true that AB=BA.
Cancellation:
It is not generally true that AB=AC implies that B=C.
Zero divisors:
It is not generally true that AB=0 implies that either A=0 or B=0.

Subsection 2.2.5 Summary

In this section, we have found an especially simple way to express linear systems using matrix multiplication.
  • If A is an m×n matrix and x an n-dimensional vector, then Ax is the linear combination of the columns of A using the components of x as weights. The vector Ax is m-dimensional.
  • The solution space to the equation Ax=b is the same as the solution space to the linear system corresponding to the augmented matrix [Ab].
  • If A is an m×n matrix and B is an n×p matrix, we can form the product AB, which is an m×p matrix whose columns are the products of A and the columns of B.

Exercises 2.2.6 Exercises

1.

Consider the system of linear equations
x+2yz=13x+2y+2z=7x+4z=3.
  1. Find the matrix A and vector b that expresses this linear system in the form Ax=b.
  2. Give a description of the solution space to the equation Ax=b.

2.

Suppose that A is a 135×2201 matrix, and that x is a vector. If Ax is defined, what is the dimension of x? What is the dimension of Ax?

3.

Suppose that A is a 3×2 matrix whose columns are v1 and v2; that is,
A=[v1v2].
  1. What is the dimension of the vectors v1 and v2?
  2. What is the product A[10] in terms of v1 and v2? What is the product A[01]? What is the product A[23]?
  3. If we know that
    A[10]=[321],   A[01]=[032],
    what is the matrix A?

4.

Suppose that the matrix A=[v1v2] where v1 and v2 are shown in Figure 2.2.9.
Figure 2.2.9. Two vectors v1 and v2 that form the columns of the matrix A.
  1. What is the shape of the matrix A?
  2. On Figure 2.2.9, indicate the vectors
    A[10],   A[23],   A[03].
  3. Find all vectors x such that Ax=b.
  4. Find all vectors x such that Ax=0.

5.

Suppose that
A=[102222131].
  1. Describe the solution space to the equation Ax=0.
  2. Find a 3×2 matrix B with no zero entries such that AB=0.

6.

Consider the matrix
A=[124423011046].
  1. Find the product Ax where
    x=[1202].
  2. Give a description of the vectors x such that
    Ax=[11517].
  3. Find the reduced row echelon form of A and identify the pivot positions.
  4. Can you find a vector b such that Ax=b is inconsistent?
  5. For a general 3-dimensional vector b, what can you say about the solution space of the equation Ax=b?

7.

The operations that we perform in Gaussian elimination can be accomplished using matrix multiplication. This observation is the basis of an important technique that we will investigate in a subsequent chapter.
Let’s consider the matrix
A=[121202323].
  1. Suppose that
    S=[100070001].
    Verify that SA is the matrix that results when the second row of A is scaled by a factor of 7. What matrix S would scale the third row by -3?
  2. Suppose that
    P=[010100001].
    Verify that PA is the matrix that results from interchanging the first and second rows. What matrix P would interchange the first and third rows?
  3. Suppose that
    L1=[100210001].
    Verify that L1A is the matrix that results from multiplying the first row of A by 2 and adding it to the second row. What matrix L2 would multiply the first row by 3 and add it to the third row?
  4. When we performed Gaussian elimination, our first goal was to perform row operations that brought the matrix into a triangular form. For our matrix A, find the row operations needed to find a row equivalent matrix U in triangular form. By expressing these row operations in terms of matrix multiplication, find a matrix L such that LA=U.

8.

In this exercise, you will construct the inverse of a matrix, a subject that we will investigate more fully in the next chapter. Suppose that A is the 2×2 matrix:
A=[3221].
  1. Find the vectors b1 and b2 such that the matrix B=[b1b2] satisfies
    AB=I=[1001].
  2. In general, it is not true that AB=BA. Check that it is true, however, for the specific A and B that appear in this problem.
  3. Suppose that x=[x1x2]. What do you find when you evaluate Ix?
  4. Suppose that we want to solve the equation Ax=b. We know how to do this using Gaussian elimination; let’s use our matrix B to find a different way:
    Ax=bB(Ax)=Bb(BA)x=BbIx=Bbx=Bb.
    In other words, the solution to the equation Ax=b is x=Bb.
    Consider the equation Ax=[52]. Find the solution in two different ways, first using Gaussian elimination and then as x=Bb, and verify that you have found the same result.

9.

Determine whether the following statements are true or false and provide a justification for your response.
  1. If Ax is defined, then the number of components of x equals the number of rows of A.
  2. The solution space to the equation Ax=b is equivalent to the solution space to the linear system whose augmented matrix is [Ab].
  3. If a linear system of equations has 8 equations and 5 unknowns, then the shape of the matrix A in the corresponding equation Ax=b is 5×8.
  4. If A has a pivot position in every row, then every equation Ax=b is consistent.
  5. If A is a 9×5 matrix, then Ax=b is inconsistent for some vector b.

10.

Suppose that A is a 4×4 matrix and that the equation Ax=b has a unique solution for some vector b.
  1. What does this say about the pivot positions of the matrix A? Write the reduced row echelon form of A.
  2. Can you find another vector c such that Ax=c is inconsistent?
  3. What can you say about the solution space to the equation Ax=0?
  4. Suppose A=[v1v2v3v4]. Explain why every four-dimensional vector can be written as a linear combination of the vectors v1, v2, v3, and v4 in exactly one way.

11.

Define the matrix
A=[124213317].
  1. Describe the solution space to the homogeneous equation Ax=0 using a parametric description, if appropriate. What does this solution space represent geometrically?
  2. Describe the solution space to the equation Ax=b where b=[341]. What does this solution space represent geometrically and how does it compare to the previous solution space?
  3. We will now explain the relationship between the previous two solution spaces. Suppose that xh is a solution to the homogeneous equation; that is Axh=0. Suppose also that xp is a solution to the equation Ax=b; that is, Axp=b.
    Use the Linearity Principle expressed in Proposition 2.2.3 to explain why xh+xp is a solution to the equation Ax=b. You may do this by evaluating A(xh+xp).
    That is, if we find one solution xp to an equation Ax=b, we may add any solution to the homogeneous equation to xp and still have a solution to the equation Ax=b. In other words, the solution space to the equation Ax=b is given by translating the solution space to the homogeneous equation by the vector xp.

12.

Suppose that a city is starting a bicycle sharing program with bicycles at locations B and C. Bicycles that are rented at one location may be returned to either location at the end of the day. Over time, the city finds that 80% of bicycles rented at location B are returned to B with the other 20% returned to C. Similarly, 50% of bicycles rented at location C are returned to B and 50% to C.
To keep track of the bicycles, we form a vector
xk=[BkCk]
where Bk is the number of bicycles at location B at the beginning of day k and Ck is the number of bicycles at C. The information above tells us how to determine the distribution of bicycles the following day:
Bk+1=0.8Bk+0.5CkCk+1=0.2Bk+0.5Ck.
Expressed in matrix-vector form, these expressions give
xk+1=Axk
where
A=[0.80.50.20.5].
  1. Let’s check that this makes sense.
    1. Suppose that there are 1000 bicycles at location B and none at C on day 1. This means we have x1=[10000]. Find the number of bicycles at both locations on day 2 by evaluating x2=Ax1.
    2. Suppose that there are 1000 bicycles at location C and none at B on day 1. Form the vector x1 and determine the number of bicycles at the two locations the next day by finding x2=Ax1.
  2. Suppose that one day there are 1050 bicycles at location B and 450 at location C. How many bicycles were there at each location the previous day?
  3. Suppose that there are 500 bicycles at location B and 500 at location C on Monday. How many bicycles are there at the two locations on Tuesday? on Wednesday? on Thursday?

13.

This problem is a continuation of the previous problem.
  1. Let us define vectors
    v1=[52],   v2=[11].
    Show that
    Av1=v1,   Av2=0.3v2.
  2. Suppose that x1=c1v1+c2v2 where c1 and c2 are scalars. Use the Linearity Principle expressed in Proposition 2.2.3 to explain why
    x2=Ax1=c1v1+0.3c2v2.
  3. Continuing in this way, explain why
    x3=Ax2=c1v1+0.32c2v2x4=Ax3=c1v1+0.33c2v2x5=Ax4=c1v1+0.34c2v2.
  4. Suppose that there are initially 500 bicycles at location B and 500 at location C. Write the vector x1 and find the scalars c1 and c2 such that x1=c1v1+c2v2.
  5. Use the previous part of this problem to determine x2, x3 and x4.
  6. After a very long time, how are all the bicycles distributed?
You have attempted 1 of 1 activities on this page.