Chapter 2 Matrices
2.3 Matrix Operations
Learning Objectives
By the end of this section, you will be able to:
- Identify the dimensions of a matrix
- Identify the entries of a matrix
- Add and subtract matrices
- Calculate a scalar multiple of a matrix
- Multiply matrices
Two club soccer teams, the Wildcats and the Mud Cats, are hoping to obtain new equipment for an upcoming season. The table below shows the needs of both teams.
[latex]\begin{array}{lcc} &\text{Wildcats}&\text{Mud Cats}\\ \text{Goals}&6&10\\ \text{Balls} &30&24\\ \text{Jerseys}&14&20 \end{array}[/latex]
A goal costs $300; a ball costs $10; and a jersey costs $30. How can we find the total cost for the equipment needed for each team?
In the last section, we learned how matrices can be used to solve systems of linear equations. In this section, we will explore other uses of matrices and discover a method in which the data in the soccer equipment table can be displayed and used for calculating other information. Then, we will be able to calculate the cost of the equipment in a way that can be easily translated to a computer or calculator.
To solve a problem like the one in the section opener, we can use a matrix, which is a rectangular array of numbers. A row in a matrix is a set of numbers that are aligned horizontally. A column in a matrix is a set of numbers that are aligned vertically. Each number is an entry, sometimes called an element, of the matrix. Matrices (plural) are enclosed in [ ] or ( ) and are usually named with capital letters. For example, three matrices named [latex]A[/latex], [latex]B[/latex], and [latex]C[/latex] are shown below.
[latex]A=\begin{bmatrix}1&2\\3&4\end{bmatrix}[/latex] [latex]B=\begin {bmatrix}1&2&7\\0&-5&6\\7&8&2 \end{bmatrix}[/latex] [latex]C=\begin{bmatrix}-1&3\\0&2\\3&1 \end{bmatrix}[/latex]
Describing Matrices
A matrix is often referred to by its size or dimensions: [latex]m\times n[/latex] indicating [latex]m[/latex] rows and [latex]n[/latex] columns. Matrix entries are defined first by row and then by column. For example, to locate the entry in matrix [latex]A[/latex] identified as [latex]a_{ij}[/latex], we look for the entry in row [latex]i[/latex] column [latex]j[/latex]. In matrix [latex]A[/latex], shown below, the entry in row 2, column 3 is [latex]a_{23}[/latex].
[latex]\begin{bmatrix}a_{11}&a_{12}&a_{13}\\a_{21}&a_{22}&a_{23}\\a_{31}&a_{32}&a_{33} \end{bmatrix}[/latex]
A square matrix is a matrix with dimensions [latex]n \times n[/latex], meaning that it has the same number of rows as columns. The matrix [latex]3 \times 3[/latex] above is an example of a square matrix.
A row matrix is a matrix consisting of one row with dimensions [latex]1 \times n[/latex].
[latex]\begin {bmatrix} a_{11}&a_{12}&a_{13} \end{bmatrix}[/latex]
A column matrix is a matrix consisting of one column with dimensions [latex]m \times 1[/latex].
[latex]\begin{bmatrix} a_{11}\\a_{21}\\a_{31} \end{bmatrix}[/latex]
A matrix may be used to represent a system of equations. In these cases, the numbers represent the coefficients of the variables in the system. Matrices often make solving systems of equations easier because they are not encumbered with variables. We will investigate this idea further in the next section, but first we will look at basic matrix operations.
A matrix is a rectangular array of numbers that is usually named by a capital letter: [latex]A[/latex], [latex]B[/latex], [latex]C[/latex], and so on. Each entry in a matrix is referred to as [latex]a_{ij}[/latex] such that [latex]i[/latex] represents the row and [latex]j[/latex] represents the column. Matrices are often referred to by their dimensions: [latex]m \times n[/latex] indicating [latex]m[/latex] rows and [latex]n[/latex] columns.
Example 1
Given matrix [latex]A=\begin{bmatrix}2&1\\2&4\\3&1 \end{bmatrix}[/latex], answer the following questions.
a) What are the dimensions of matrix [latex]A[/latex]?
The dimensions are [latex]3 \times 2[/latex] because there are three rows and two columns.
b) What are the entries at [latex]a_{31}[/latex] and [latex]a_{22}[/latex]?
Entry [latex]a_{31}[/latex] is the number at row 3, column 1, which is 3. The entry [latex]a_{22}[/latex] is the number at row 2, column 2, which is 4. Remember, the row comes first, then the column.
Adding and Subtracting Matrices
We use matrices to list data or to represent systems. Because the entries are numbers, we can perform operations on matrices. We add or subtract matrices by adding or subtracting corresponding entries.
In order to do this, the entries must correspond. Therefore, addition and subtraction of matrices is only possible when the matrices have the same dimensions. We can add or subtract a [latex]3 \times 3[/latex] matrix and another [latex]3 \times 3[/latex] matrix, but we cannot add or subtract a [latex]2 \times 3[/latex] matrix and a [latex]3 \times 3[/latex] matrix because some entries in one matrix will not have a corresponding entry in the other matrix.
Given matrices [latex]A[/latex] and [latex]B[/latex] of like dimensions, addition and subtraction of [latex]A[/latex] and [latex]B[/latex] will produce matrix [latex]C[/latex] or matrix [latex]D[/latex] of the same dimension.
[latex]A+B=C[/latex] such that [latex]a_{ij}+b_{ij}=c_{ij}[/latex]
[latex]A-B=D[/latex] such that [latex]a_{ij}-b_{ij}=d_{ij}[/latex]
Matrix addition is commutative: [latex]A+B=B+A[/latex]
It is also associative: [latex](A+B)+C=A+(B+C)[/latex]
Example 2
Given [latex]A[/latex] and [latex]B[/latex]:
[latex]A=\begin{bmatrix}2&-10&-2\\14&12&10\\4&-2&2\end{bmatrix}[/latex] and [latex]B=\begin{bmatrix}6&10&-2\\0&-12&-4\\-5&2&-2\end{bmatrix}[/latex]
a) Find the sum.
Add the corresponding entries.
[latex]\begin{array}{rcl}A+B&=&\begin{bmatrix}2&-10&-2\\14&12&10\\4&-2&2\end{bmatrix}+\begin{bmatrix}6&10&-2\\0&-12&-4\\-5&2&-2\end{bmatrix}\\ &=&\begin{bmatrix}{2+6}&{-10+10}&-2-2\\14+0&12-12&10-4\\4-5&-2+2&2-2 \end{bmatrix}\\ &=&\begin{bmatrix}8&0&-4\\14&0&6\\-1&0&0\end{bmatrix}\end{array}[/latex]
b) Find the difference.
Subtract the corresponding entries.
[latex]\begin{array}{rcl}A-B&=&\begin{bmatrix}2&-10&-2\\14&12&10\\4&-2&2\end{bmatrix}-\begin{bmatrix}6&10&-2\\0&-12&-4\\-5&2&-2\end{bmatrix}\\ &=&\begin{bmatrix}2-6&-10-10&-2+2\\14-0&12+12&10+4\\4+5&-2-2&2+2\end{bmatrix}\\ &=&\begin{bmatrix}-4&-20&0\\14&24&14\\9&-4&4\end{bmatrix} \end{array}[/latex]
You can work this problem with the matrix calculator.
Add matrix [latex]A[/latex] and matrix [latex]B[/latex].
[latex]A= \begin{bmatrix}2&6\\1&0\\1&-3\end{bmatrix}[/latex] and [latex]B= \begin{bmatrix}3&-2\\1&5\\-4&3\end{bmatrix}[/latex]
Solution
[latex]A+B=\begin{bmatrix} 2&6\\1&0\\1&-3\end{bmatrix}+\begin{bmatrix}3&-2\\1&5\\-4&3\end{bmatrix}=\begin{bmatrix} 2+3&6+(-2)\\1+1&0+5\\1+(-4)&-3+3\end{bmatrix}=\begin{bmatrix}5&4\\2&5\\-3&0 \end{bmatrix}[/latex]
Finding Scalar Multiples of a Matrix
Besides adding and subtracting whole matrices, there are many situations in which we need to multiply a matrix by a constant called a scalar. Recall that a scalar is a real number quantity that has magnitude but not direction. For example, time, temperature, and distance are scalar quantities. The process of scalar multiplication involves multiplying each entry in a matrix by a scalar. A scalar multiple is any entry of a matrix that results from scalar multiplication.
Scalar Multiplication
Scalar multiplication involves finding the product of a constant by each entry in the matrix.
Given [latex]A=\begin{bmatrix}a_{11}&b_{12}\\a_{21}&a_{22}\end{bmatrix}[/latex]
the scalar multiple [latex]cA[/latex] is
[latex]\begin{array}{rcl}cA&=&c\begin{bmatrix}a_{11}&a_{12}\\a_{21}&a_{22}\end{bmatrix}\\ &=&\begin{bmatrix}ca_{11}&ca_{12}\\ca_{21}&ca_{22}\end{bmatrix}\end{array}[/latex]
Scalar multiplication is distributive. For the matrices [latex]A, B,[/latex] and [latex]C[/latex] with scalars [latex]a[/latex] and [latex]b[/latex],
[latex]\begin{array}{rcl}a(A+B)&=&aA+aB\\(a+b)A&=&aA+bA \end{array}[/latex]
Example 3
Multiply matrix [latex]A[/latex] by the scalar 3.
[latex]A=\left[\begin{array}{cc}8&1\\5&4 \end{array}\right][/latex]
Multiply each entry in [latex]A[/latex] by the scalar 3.
[latex]\begin{array}{rcl}3A&=&3\left[\begin{array}{cc}8&1\\5&4\end{array}\right]\\ &=&3\left[\begin{array}{cc}3 \cdot 8&3 \cdot 1\\3 \cdot 5&3 \cdot 4\end{array}\right]\\ &=&\left[\begin{array}{cc}24&3\\15&12\end{array}\right]\end{array}[/latex]
You can work this problem with the matrix calculator.
Given matrix [latex]B[/latex], find [latex]-2B[/latex], where
[latex]B=\begin{bmatrix}4&1\\3&2\end{bmatrix}[/latex]
Solution
[latex]-2B=\begin{bmatrix}-8&-2\\-6&-4 \end{bmatrix}[/latex]
Example 4
Find the sum [latex]3A+2B[/latex].
[latex]A=\begin{bmatrix}1&-2&0\\0&-1&2\\4&3&-6 \end{bmatrix}[/latex] and [latex]B=\begin{bmatrix}-1&2&1\\0&-3&2\\0&1&-4 \end{bmatrix}[/latex]
First, find [latex]3A[/latex] , then [latex]2B[/latex].
[latex]\begin{array}{rcl} 3A&=&\begin{bmatrix} 3 \cdot1&3(-2)&3 \cdot 0\\3 \cdot 0&3(-1)&3 \cdot 2\\ 3 \cdot4& 3 \cdot 3& 3(-6)\end{bmatrix}\\ &=&\begin{bmatrix}3&-6&0\\0&-3&6\\12&9&18 \end{bmatrix}\\2B&=&\begin{bmatrix} 2(-1)&2 \cdot2 &2 \cdot 1\\2 \cdot 0&2(-3)&2 \cdot 2\\2 \cdot 0&2 \cdot1&2(-4) \end{bmatrix}\\ &=&\begin{bmatrix}-2&4&2\\0&-6&4\\0&2&-8 \end{bmatrix} \end{array}[/latex]
Now add [latex]3A+2B[/latex].
[latex]\begin{array}{rcl} 3A+2B&=&\begin{bmatrix}3&-6&0\\0&-3&6\\12&9&-18 \end{bmatrix}+\begin{bmatrix}-2&4&2\\0&-6&4\\0&2&-8\end{bmatrix}\\ &=&\begin{bmatrix}3-2&-6+4&0+2\\0+0&-3-6&6+4\\12+0&9+2&-18-8\end{bmatrix}\\ &=&\begin{bmatrix}1&-2&2\\0&-9&10\\12&11&-26\end{bmatrix}\end{array}[/latex]
You can work this problem with the matrix calculator matrix calculator.
Finding the Product of Two Matrices
In addition to multiplying a matrix by a scalar, we can multiply two matrices. Finding the product of two matrices is only possible when the inner dimensions are the same, meaning that the number of columns of the first matrix is equal to the number of rows of the second matrix. If [latex]A[/latex] is an [latex]m \times r[/latex] matrix and [latex]B[/latex] is an [latex]r \times n[/latex] matrix, then the product matrix [latex]AB[/latex] is an [latex]m \times n[/latex] matrix. For example, the product [latex]AB[/latex] is possible because the number of columns in [latex]A[/latex] is the same as the number of rows in [latex]B[/latex]. If the inner dimensions do not match, the product is not defined.
[latex]\;\;\;A\;\;\;\; \cdot \;\;\;\; B\;\;\;[/latex]
[latex]2 \times \underbrace {3 \;\;\; \;\;\; 3}_{same}\times 3[/latex]
We multiply entries of [latex]A[/latex] with entries of [latex]B[/latex] according to a specific pattern as outlined below. The process of matrix multiplication becomes clearer when working a problem with real numbers.
To obtain the entries in row [latex]i[/latex] of [latex]AB[/latex], we multiply the entries in row [latex]i[/latex] of [latex]A[/latex] by column [latex]j[/latex] in [latex]B[/latex] and add. For example, given matrices [latex]A[/latex] and [latex]B[/latex] where the dimensions of [latex]A[/latex] are [latex]2\times3[/latex] and the dimensions of [latex]B[/latex] are [latex]3\times3[/latex], the product of [latex]AB[/latex] will be a [latex]2\times3[/latex] matrix.
[latex]A=\begin{bmatrix}a_{11}&a_{12}&a_{13}\\a_{21}&a_{22}&a_{23}\\a_{31}&a_{32}&a_{33}\end{bmatrix}[/latex] and [latex]B=\begin{bmatrix}b_{11}&b_{12}&b_{13}\\b_{21}&b_{22}&b_{23}\\b_{31}&b_{32}&b_{33}\end{bmatrix}[/latex]
Multiplying Matrices
To obtain the entry in row 1, column 1 of [latex]AB[/latex], multiply the first row in [latex]A[/latex] by the first column in [latex]B[/latex] and add.
[latex]\begin{bmatrix}a_{11}&a_{12}&a_{13}\end{bmatrix} \cdot \begin{bmatrix}b_{11}\\b_{21}\\b_{31}\end{bmatrix} = a_{11}\cdot b_{11}+a_{12}\cdot b_{21}+a_{13} \cdot b_{31}[/latex]
To obtain the entry in row 1, column 2 of [latex]AB[/latex], multiply the first row of [latex]A[/latex] by the second column in [latex]B[/latex] and add.
[latex]\begin{bmatrix}a_{11}&a_{12}&a_{13}\end{bmatrix} \cdot \begin{bmatrix}b_{12}\\b_{22}\\b_{32}\end{bmatrix} = a_{11}\cdot b_{12}+a_{12}\cdot b_{22}+a_{13} \cdot b_{32}[/latex]
To obtain the entry in row 1, column 3 of [latex]AB[/latex], multiply the first row of [latex]A[/latex] by the third column in [latex]B[/latex] and add.
[latex]\begin{bmatrix}a_{11}&a_{12}&a_{13}\end{bmatrix} \cdot \begin{bmatrix}b_{13}\\b_{23}\\b_{33}\end{bmatrix} = a_{11}\cdot b_{13}+a_{12}\cdot b_{23}+a_{13} \cdot b_{33}[/latex]
We proceed the same way to obtain the second row of [latex]AB[/latex]—in other words, row 2 of [latex]A[/latex] times column 1 of [latex]B[/latex] row 2 of [latex]A[/latex] times column 2 of [latex]B[/latex] row 2 of [latex]A[/latex] times column 3 of [latex]B[/latex]. When complete, the product matrix will be
[latex]AB=\begin{bmatrix} a_{11}\cdot b_{11}+a_{12}\cdot b_{21}+a_{13} \cdot b_{31} & a_{11}\cdot b_{12}+a_{12}\cdot b_{22}+a_{13} \cdot b_{32} & a_{11}\cdot b_{13}+a_{12}\cdot b_{23}+a_{13} \cdot b_{33}\\a_{21}\cdot b_{11}+a_{22}\cdot b_{21}+a_{23} \cdot b_{31} & a_{21}\cdot b_{12}+a_{22}\cdot b_{22}+a_{23} \cdot b_{32} & a_{21}\cdot b_{13}+a_{22}\cdot b_{23}+a_{23} \cdot b_{33}\end{bmatrix}[/latex]
Properties of Matrix Multiplication
For the matrices [latex]A, B,[/latex], and [latex]C[/latex], the following properties hold:
- Matrix multiplication is associative: [latex](AB)C=A(BC)[/latex].
- Matrix multiplication is distributive: [latex]\begin{array}{rcl} C(A+B)&=&CA+CB\\(A+B)C&=&AC+BC \end{array}[/latex]
Note that matrix multiplication is not commutative.
Example 5
Multiply matrix [latex]A[/latex] and matrix [latex]B.[/latex]
[latex]A=\begin{bmatrix} 1&2\\3&4 \end {bmatrix}[/latex] and [latex]\begin{bmatrix} 5&6\\7&8 \end{bmatrix}[/latex]
First, we check the dimensions of the matrices.
Matrix [latex]A[/latex] has dimensions [latex]2 \times 2[/latex], and matrix [latex]B[/latex] has dimensions [latex]2 \times 2[/latex]. The inner dimensions are the same, so we can perform the multiplication. The product will have the dimensions [latex]2 \times 2[/latex].
We perform the operations outlined previously.
[latex]\begin{array}{rcl} AB&=&\begin{bmatrix} 1&2\\3&4\end{bmatrix} \cdot \begin{bmatrix} 5&6\\7&8 \end{bmatrix}\\ &=& \begin{bmatrix} 1 \cdot 5+2 \cdot 7 & 1 \cdot 6+2 \cdot 8\\ 3 \cdot 5+4 \cdot 7 & 3 \cdot 6+4 \cdot 8\end{bmatrix}\\ &=&\begin{bmatrix}19&22\\43&50\end{bmatrix} \end{array}[/latex]
You can work this problem with the matrix calculator.
Given [latex]A[/latex] and [latex]B[/latex]:
[latex]A=\begin{bmatrix} -1&2&3\\4&0&5 \end {bmatrix}[/latex] and [latex]B=\begin{bmatrix} 5&-1\\-4&0\\2&3 \end{bmatrix}[/latex]
a) Find [latex]AB[/latex].
As the dimensions of [latex]A[/latex] are [latex]2 \times 3[/latex] and the dimensions of [latex]B[/latex] are [latex]3 \times 2[/latex], these matrices can be multiplied together because the number of columns in [latex]A[/latex] matches the number of rows in [latex]B[/latex]. The resulting product will be a [latex]2 \times 2[/latex] matrix, the number of rows in [latex]A[/latex] by the number of columns in [latex]B[/latex].
[latex]\begin{array}{rcl} AB&=&\begin{bmatrix}-1&2&3\\4&0&5\end{bmatrix} \begin{bmatrix}5&-1\\-4&0\\2&3\end{bmatrix}\\ &=&\begin{bmatrix} -1(5)+2(-4)+3(2) &-1(-1)+2(0)+3(3)\\4(5)+0(-4)+5(2) & 4(-1)+0(0)+5(3)\end{bmatrix}\\ &=&\begin{bmatrix}-7&10\\30&11 \end{bmatrix} \end{array}[/latex]
b) Find [latex]BA[/latex].
The dimensions of [latex]B[/latex] are [latex]3 \times 2[/latex] and the dimensions of [latex]A[/latex] are [latex]2 \times 3[/latex]. The inner dimensions match, so the product is defined and will be a [latex]3 \times 3[/latex] matrix.
[latex]\begin{array}{rcl} BA&=& \begin{bmatrix} 5&-1\\-4&0\\2&3 \end{bmatrix} \begin{bmatrix} -1&2&3\\4&0&5 \end{bmatrix}\\ &=&\begin{bmatrix} 5(-1)+-1(4)&5(2)+-1(0)&5(3)+-1(5)\\-4(-1)+0(4)&-4(2)+0(0)&-4(3)+0(5)\\2(-1)+3(4)&2(2)+3(0)&2(3)+3(5) \end{bmatrix}\\ &=&\begin{bmatrix} -9&10&10\\4&-8&-12\\10&4&21 \end{bmatrix}\end{array}[/latex]
You can work this problem with the matrix calculator.
Notice in the example above that the products [latex]AB[/latex] and [latex]BA[/latex] are not equal.
[latex]AB=\begin{bmatrix} -7&10\\30&11\end{bmatrix} \neq \begin{bmatrix}-9&10&10\\4&-8&-12\\10&4&21\end{bmatrix}=BA[/latex]
This illustrates the fact that matrix multiplication is not commutative.
Also, this means that it is possible for [latex]AB[/latex] to be defined but not [latex]BA[/latex]. Consider a matrix [latex]A[/latex] with dimension [latex]3 \times 4[/latex] and matrix [latex]B[/latex] with dimension [latex]4 \times 2[/latex]. For the product [latex]AB[/latex], the inner dimensions are 4 and the product is defined, but for the product [latex]BA[/latex], the inner dimensions are 2 and 3, so the product is undefined.
Exercise 3
Multiply.
[latex]\begin{bmatrix}1&-2\\4&0\\-1&3\end{bmatrix} \cdot \begin{bmatrix} 2&3\\1&-1\end{bmatrix}[/latex]
Solution
[latex]\begin{bmatrix}1&-2\\4&0\\-1&3\end{bmatrix} \cdot \begin{bmatrix}2&3\\1&-1\end{bmatrix}=\begin{bmatrix} 1(2)+(-2)(1)&1(3)+(-2)(-1)\\4(2)+(0)(1)&4(3)+0(-1)\\(-1)(2)+(3)(1)&(-1)(3)+(3)(-1) \end{bmatrix}=\begin{bmatrix}0&5\\8&12\\1&-6\end{bmatrix}[/latex]
Example 7
Let’s return to the problem presented at the opening of this section. We have the table below representing the equipment needs of two soccer teams.
[latex]\begin{array}{lcc} &\text{Wildcats}&\text{Mud Cats}\\ \text{Goals}&6&10\\ \text{Balls} &30&24\\ \text{Jerseys}&14&20 \end{array}[/latex]
We are also given the prices of the equipment, as shown below.
[latex]\begin{array}{cc} \text{Goal}& \$300\\ \text{Ball}&$10\\ \text{Jersey}&$30 \end{array}[/latex]
We will convert the data to matrices. Thus, the equipment need matrix is written as
[latex]E=\begin{bmatrix} 6&10\\30&24\\14&20 \end{bmatrix}[/latex]
The cost matrix is written as
[latex]C=\begin{bmatrix} 300&10&30\end{bmatrix}[/latex]
We perform matrix multiplication to obtain costs for the equipment.
[latex]\begin{array}{rcl}CE&=&\begin{bmatrix}300&10&30\end{bmatrix} \cdot \begin{bmatrix} 6&10\\30&24\\14&20\end{bmatrix}\\ &=&\begin{bmatrix} 300(6)+10(30)+30(14)&300(10)+10(24)+30(20)\end{bmatrix}\\ &=&\begin{bmatrix}2,520&3,840\end{bmatrix} \end{array}[/latex]
The total cost for equipment for the Wildcats is $2,520, and the total cost for equipment for the Mud Cats is $3,840.
You can work this problem with the matrix calculator.
The calculation in the last example could easily be performed using a calculator and computer, which would also easily handle a version of the problem with dozens of teams and hundreds of expenses. Representing the problem as matrix operations allows us to utilize technology to help solve this type of problem.
A matrix is a rectangular array of numbers arranged into rows and columns.
A set of numbers that are aligned horizontally.
A set of numbers that are aligned vertically.
A matrix that has the same number of rows as columns.
A matrix consisting of one row.
A matrix consisting of one column.
Each number in a matrix. An entry may also be called an element.
The number of rows in a matrix by the number of columns in the matrix.
Any entry of a matrix that results from scalar multiplication.
Scalar multiplication involves finding the product of a constant by each entry in the matrix.