Loading [MathJax]/jax/output/HTML-CSS/jax.js
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

2.2: Multiplication of Matrices

( \newcommand{\kernel}{\mathrm{null}\,}\)

The next important matrix operation we will explore is multiplication of matrices. The operation of matrix multiplication is one of the most important and useful of the matrix operations. Throughout this section, we will also demonstrate how matrix multiplication relates to linear systems of equations.

First, we provide a formal definition of row and column vectors.

Definition 2.2.1: Row and Column Vectors

Matrices of size n×1 or 1×n are called vectors. If X is such a matrix, then we write xi to denote the entry of X in the ith row of a column matrix, or the ith column of a row matrix.

The n×1 matrix X=[x1xn] is called a column vector. The 1×n matrix X=[x1xn] is called a row vector.

We may simply use the term vector throughout this text to refer to either a column or row vector. If we do so, the context will make it clear which we are referring to.

In this chapter, we will again use the notion of linear combination of vectors as in Definition 9.2.2. In this context, a linear combination is a sum consisting of vectors multiplied by scalars. For example, [50122]=7[14]+8[25]+9[36] is a linear combination of three vectors.

It turns out that we can express any system of linear equations as a linear combination of vectors. In fact, the vectors that we will use are just the columns of the corresponding augmented matrix!

Definition 2.2.2: The Vector Form of a System of Linear Equations

Suppose we have a system of equations given by a11x1++a1nxn=b1am1x1++amnxn=bm We can express this system in vector form which is as follows: x1[a11a21am1]+x2[a12a22am2]++xn[a1na2namn]=[b1b2bm]

Notice that each vector used here is one column from the corresponding augmented matrix. There is one vector for each variable in the system, along with the constant vector.

The first important form of matrix multiplication is multiplying a matrix by a vector. Consider the product given by [123456][789] We will soon see that this equals 7[14]+8[25]+9[36]=[50122]

In general terms, [a11a12a13a21a22a23][x1x2x3]= x1[a11a21]+x2[a12a22]+x3[a13a23]=[a11x1+a12x2+a13x3a21x1+a22x2+a23x3] Thus you take x1 times the first column, add to x2 times the second column, and finally x3 times the third column. The above sum is a linear combination of the columns of the matrix. When you multiply a matrix on the left by a vector on the right, the numbers making up the vector are just the scalars to be used in the linear combination of the columns as illustrated above.

Here is the formal definition of how to multiply an m×n matrix by an n×1 column vector.

Definition 2.2.3: Multiplication of Vector by Matrix

Let A=[aij] be an m×n matrix and let X be an n×1 matrix given by A=[A1An],X=[x1xn]

Then the product AX is the m×1 column vector which equals the following linear combination of the columns of A: x1A1+x2A2++xnAn=nj=1xjAj

If we write the columns of A in terms of their entries, they are of the form Aj=[a1ja2jamj] Then, we can write the product AX as AX=x1[a11a21am1]+x2[a12a22am2]++xn[a1na2namn]

Note that multiplication of an m×n matrix and an n×1 vector produces an m×1 vector.

Here is an example.

Example 2.2.1: A Vector Multiplied by a Matrix

Compute the product AX for A=[121302122141],X=[1201]

Solution

We will use Definition 2.2.3 to compute the product. Therefore, we compute the product AX as follows. 1[102]+2[221]+0[114]+1[321]=[102]+[442]+[000]+[321]=[825]

Using the above operation, we can also write a system of linear equations in matrix form. In this form, we express the system as a matrix multiplied by a vector. Consider the following definition.

Definition 2.2.4: The Matrix Form of a System of Linear Equations

Suppose we have a system of equations given by a11x1++a1nxn=b1a21x1++a2nxn=b2am1x1++amnxn=bm Then we can express this system in matrix form as follows. [a11a12a1na21a22a2nam1am2amn][x1x2xn]=[b1b2bm]

The expression AX=B is also known as the Matrix Form of the corresponding system of linear equations. The matrix A is simply the coefficient matrix of the system, the vector X is the column vector constructed from the variables of the system, and finally the vector B is the column vector constructed from the constants of the system. It is important to note that any system of linear equations can be written in this form.

Notice that if we write a homogeneous system of equations in matrix form, it would have the form AX=0, for the zero vector 0.

You can see from this definition that a vector X=[x1x2xn] will satisfy the equation AX=B only when the entries x1,x2,,xn of the vector X are solutions to the original system.

Now that we have examined how to multiply a matrix by a vector, we wish to consider the case where we multiply two matrices of more general sizes, although these sizes still need to be appropriate as we will see. For example, in Example 2.2.1, we multiplied a 3×4 matrix by a 4×1 vector. We want to investigate how to multiply other sizes of matrices.

We have not yet given any conditions on when matrix multiplication is possible! For matrices A and B, in order to form the product AB, the number of columns of A must equal the number of rows of B. Consider a product AB where A has size m×n and B has size n×p. Then, the product in terms of size of matrices is given by (m×these must match!^n)(n×p)=m×p

Note the two outside numbers give the size of the product. One of the most important rules regarding matrix multiplication is the following. If the two middle numbers don’t match, you can’t multiply the matrices!

When the number of columns of A equals the number of rows of B the two matrices are said to be conformable and the product AB is obtained as follows.

Definition 2.2.5: Multiplication of Two Matrices

Let A be an m×n matrix and let B be an n×p matrix of the form B=[B1Bp] where B1,...,Bp are the n×1 columns of B. Then the m×p matrix AB is defined as follows: AB=A[B1Bp]=[(AB)1(AB)p] where (AB)k is an m×1 matrix or column vector which gives the kth column of AB.

Consider the following example.

Example 2.2.2: Multiplying Two Matrices

Find AB if possible. A=[121021],B=[120031211]

Solution

The first thing you need to verify when calculating a product is whether the multiplication is possible. The first matrix has size 2×3 and the second matrix has size 3×3. The inside numbers are equal, so A and B are conformable matrices. According to the above discussion AB will be a 2×3 matrix. Definition 2.2.5 gives us a way to calculate each column of AB, as follows.

[First column[121021][102],Second column[121021][231],Third column[121021][011]] You know how to multiply a matrix times a vector, using Definition 2.2.3 for each of the three columns. Thus [121021][120031211]= [193273]

Since vectors are simply n×1 or 1×m matrices, we can also multiply a vector by another vector.

Example 2.2.3: Vector Times Vector Multiplication

Multiply if possible [121][1210].

Solution

In this case we are multiplying a matrix of size 3×1 by a matrix of size 1×4. The inside numbers match so the product is defined. Note that the product will be a matrix of size 3×4. Using Definition 2.2.5, we can compute this product as follows [121][1210]=[First column[121][1],Second column[121][2],Third column[121][1],Fourth column[121][0]]

You can use Definition 2.2.3 to verify that this product is [121024201210]

Example 2.2.4: A Multiplication Which is Not Defined

Find BA if possible. B=[120031211],A=[121021]

Solution

First check if it is possible. This product is of the form (3×3)(2×3). The inside numbers do not match and so you can’t do this multiplication.

In this case, we say that the multiplication is not defined. Notice that these are the same matrices which we used in Example 2.2.2. In this example, we tried to calculate BA instead of AB. This demonstrates another property of matrix multiplication. While the product AB maybe be defined, we cannot assume that the product BA will be possible. Therefore, it is important to always check that the product is defined before carrying out any calculations.

Earlier, we defined the zero matrix 0 to be the matrix (of appropriate size) containing zeros in all entries. Consider the following example for multiplication by the zero matrix.

Example 2.2.5: Multiplication by the Zero Matrix

Compute the product A0 for the matrix A=[1234] and the 2×2 zero matrix given by 0=[0000]

Solution

In this product, we compute [1234][0000]=[0000]

Hence, A0=0.

Notice that we could also multiply A by the 2×1 zero vector given by [00]. The result would be the 2×1 zero vector. Therefore, it is always the case that A0=0, for an appropriately sized zero matrix or vector.


This page titled 2.2: Multiplication of Matrices is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Ken Kuttler (Lyryx) via source content that was edited to the style and standards of the LibreTexts platform.

  • Was this article helpful?

Support Center

How can we help?