# 9.6: Matrices and Matrix Operations

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

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

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

##### Learning Objectives

In this section, you will:

• Find the sum and difference of two matrices.
• Find scalar multiples of a matrix.
• Find the product of two matrices.

Figure 1 (credit: “SD Dirk,” Flickr)

Two club soccer teams, the Wildcats and the Mud Cats, are hoping to obtain new equipment for an upcoming season. Table 1 shows the needs of both teams.

Wildcats Mud Cats
Goals 6 10
Balls 30 24
Jerseys 14 20

Table 1

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 this section, we 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. ### Finding the Sum and Difference of Two Matrices To solve a problem like the one described for the soccer teams, 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 A,B,A,B, and CC are shown below. A=[1324],B=⎡⎣⎢1072−58762⎤⎦⎥,C=⎡⎣⎢−103321⎤⎦⎥A=[ 1234 ],B=[ 1270−56782 ],C=[ −103321 ] #### Describing Matrices A matrix is often referred to by its size or dimensions: m×nm×n indicating mm rows and nn columns. Matrix entries are defined first by row and then by column. For example, to locate the entry in matrix AA identified as aij,aij, we look for the entry in row i,i, column j.j. In matrix A, A, shown below, the entry in row 2, column 3 is a23.a23. A=⎡⎣⎢a11a21a31a12a22a32a13a23a33⎤⎦⎥A=[ a11a12a13a21a22a23a31a32a33 ] A square matrix is a matrix with dimensions n×n,n×n, meaning that it has the same number of rows as columns. The 3×33×3 matrix above is an example of a square matrix. A row matrix is a matrix consisting of one row with dimensions 1×n.1×n. [a11a12a13][ a11a12a13 ] A column matrix is a matrix consisting of one column with dimensions m×1.m×1. ⎡⎣⎢a11a21a31⎤⎦⎥[ a11a21a31 ] 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. ##### MATRICES A matrix is a rectangular array of numbers that is usually named by a capital letter: A,B,C,A,B,C, and so on. Each entry in a matrix is referred to as aij,aij, such that ii represents the row and jj represents the column. Matrices are often referred to by their dimensions: m×nm×n indicating mm rows and nn columns. ### EXAMPLE 1 #### Finding the Dimensions of the Given Matrix and Locating Entries Given matrix A:A: 1. ⓐWhat are the dimensions of matrix A?A? 2. ⓑWhat are the entries at a31a31 and a22?a22? A=⎡⎣⎢22314107−2⎤⎦⎥A=[ 21024731−2 ] Answer #### 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 3×33×3 matrix and another 3×33×3 matrix, but we cannot add or subtract a 2×32×3 matrix and a 3×33×3 matrix because some entries in one matrix will not have a corresponding entry in the other matrix. ##### ADDING AND SUBTRACTING MATRICES Given matrices AA and BB of like dimensions, addition and subtraction of AA and BB will produce matrix CC or matrix DD of the same dimension. A+B=Csuch that aij+bij=cijA+B=Csuch that aij+bij=cij A−B=Dsuch that aij−bij=dijA−B=Dsuch that aij−bij=dij Matrix addition is commutative. A+B=B+AA+B=B+A It is also associative. (A+B)+C=A+(B+C)(A+B)+C=A+(B+C) ### EXAMPLE 2 #### Finding the Sum of Matrices Find the sum of AA and B,B, given A=[acbd] and B=[egfh]A=[ abcd ] and B=[ efgh ] Answer ### EXAMPLE 3 #### Adding Matrix A and Matrix B Find the sum of AA and B.B. A=[4312] and B=[5097]A=[ 4132 ] and B=[ 5907 ] Answer ### EXAMPLE 4 #### Finding the Difference of Two Matrices Find the difference of AA and B.B. A=[−2031] and B=[8514]A=[ −2301 ] and B=[ 8154 ] Answer ### EXAMPLE 5 #### Finding the Sum and Difference of Two 3 x 3 Matrices Given AA and B:B: 1. ⓐFind the sum. 2. ⓑFind the difference. A=⎡⎣⎢2144−1012−2−2102⎤⎦⎥and B=⎡⎣⎢60−510−122−2−4−2⎤⎦⎥A=[ 2−10−21412104−22 ]and B=[ 610−20−12−4−52−2 ] Answer ##### TRY IT #1 Add matrix AA and matrix B.B. A=⎡⎣⎢21160−3⎤⎦⎥ and B=⎡⎣⎢31−4−253⎤⎦⎥A=[ 26101−3 ] and B=[ 3−215−43 ] ### 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. Consider a real-world scenario in which a university needs to add to its inventory of computers, computer tables, and chairs in two of the campus labs due to increased enrollment. They estimate that 15% more equipment is needed in both labs. The school’s current inventory is displayed in Table 2. Lab A Lab B Computers 15 27 Computer Tables 16 34 Chairs 16 34 Table 2 Converting the data to a matrix, we have C2013=⎡⎣⎢151616273434⎤⎦⎥C2013=[ 151616273434 ] To calculate how much computer equipment will be needed, we multiply all entries in matrix CC by 0.15. (0.15)C2013=⎡⎣⎢(0.15)15(0.15)16(0.15)16(0.15)27(0.15)34(0.15)34⎤⎦⎥=⎡⎣⎢2.252.42.44.055.15.1⎤⎦⎥(0.15)C2013=[ (0.15)15(0.15)16(0.15)16(0.15)27(0.15)34(0.15)34 ]=[ 2.252.42.44.055.15.1 ] We must round up to the next integer, so the amount of new equipment needed is ⎡⎣⎢333566⎤⎦⎥[ 333566 ] Adding the two matrices as shown below, we see the new inventory amounts. ⎡⎣⎢151616273434⎤⎦⎥+⎡⎣⎢333566⎤⎦⎥=⎡⎣⎢181919324040⎤⎦⎥[ 151616273434 ]+[ 333566 ]=[ 181919324040 ] This means C2014=⎡⎣⎢181919324040⎤⎦⎥C2014=[ 181919324040 ] Thus, Lab A will have 18 computers, 19 computer tables, and 19 chairs; Lab B will have 32 computers, 40 computer tables, and 40 chairs. ##### SCALAR MULTIPLICATION Scalar multiplication involves finding the product of a constant by each entry in the matrix. Given A=[a11a21a12a22]A=[ a11a12a21a22 ] the scalar multiple cAcA is cA=c[a11a21a12a22] =[ca11ca21ca12ca22]cA=c[ a11a12a21a22 ] =[ ca11ca12ca21ca22 ] Scalar multiplication is distributive. For the matrices A,B,A,B, and CC with scalars a a and b,b, a(A+B)=aA+aB(a+b)A=aA+bAa(A+B)=aA+aB(a+b)A=aA+bA ### EXAMPLE 6 #### Multiplying the Matrix by a Scalar Multiply matrix AA by the scalar 3. A=[8514]A=[ 8154 ] Answer ##### TRY IT #2 Given matrix B,B, find −2B−2B where B=[4312]B=[ 4132 ] ### EXAMPLE 7 #### Finding the Sum of Scalar Multiples Find the sum 3A+2B.3A+2B. A=⎡⎣⎢104−2−1302−6⎤⎦⎥and B=⎡⎣⎢−1002−3112−4⎤⎦⎥A=[ 1−200−1243−6 ]and B=[ −1210−3201−4 ] Answer ### 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 AA is an m×rm×r matrix and BB is an r×nr×n matrix, then the product matrix AB AB is an m×nm×n matrix. For example, the product AB AB is possible because the number of columns in AA is the same as the number of rows in B.B. If the inner dimensions do not match, the product is not defined. We multiply entries of AA with entries of BB 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 ii of AB,AB, we multiply the entries in row ii of AA by column jj in BB and add. For example, given matrices AA and B,B, where the dimensions of AA are 2×32×3 and the dimensions of BB are 3×3,3×3, the product of ABAB will be a 2×32×3 matrix. A=[a11a21a12a22a13a23]and B=⎡⎣⎢b11b21b31b12b22b32b13b23b33⎤⎦⎥A=[ a11a12a13a21a22a23 ]and B=[ b11b12b13b21b22b23b31b32b33 ] Multiply and add as follows to obtain the first entry of the product matrix AB.AB. 1. To obtain the entry in row 1, column 1 of AB,AB, multiply the first row in AA by the first column in B,B, and add. [a11a12a13]⎡⎣⎢b11b21b31⎤⎦⎥=a11⋅b11+a12⋅b21+a13⋅b31[ a11a12a13 ][ b11b21b31 ]=a11⋅b11+a12⋅b21+a13⋅b31 2. To obtain the entry in row 1, column 2 of AB,AB, multiply the first row of AA by the second column in B,B, and add. [a11a12a13]⎡⎣⎢b12b22b32⎤⎦⎥=a11⋅b12+a12⋅b22+a13⋅b32[ a11a12a13 ][ b12b22b32 ]=a11⋅b12+a12⋅b22+a13⋅b32 3. To obtain the entry in row 1, column 3 of AB,AB, multiply the first row of AA by the third column in B,B, and add. [a11a12a13]⎡⎣⎢b13b23b33⎤⎦⎥=a11⋅b13+a12⋅b23+a13⋅b33[ a11a12a13 ][ b13b23b33 ]=a11⋅b13+a12⋅b23+a13⋅b33 We proceed the same way to obtain the second row of AB.AB. In other words, row 2 of AA times column 1 of B;B; row 2 of AA times column 2 of B;B; row 2 of AA times column 3 of B.B. When complete, the product matrix will be AB=⎡⎣⎢a11⋅b11+a12⋅b21+a13⋅b31a21⋅b11+a22⋅b21+a23⋅b31a11⋅b12+a12⋅b22+a13⋅b32a21⋅b12+a22⋅b22+a23⋅b32a11⋅b13+a12⋅b23+a13⋅b33a21⋅b13+a22⋅b23+a23⋅b33⎤⎦⎥AB=[ a11⋅b11+a12⋅b21+a13⋅b31a21⋅b11+a22⋅b21+a23⋅b31a11⋅b12+a12⋅b22+a13⋅b32a21⋅b12+a22⋅b22+a23⋅b32a11⋅b13+a12⋅b23+a13⋅b33a21⋅b13+a22⋅b23+a23⋅b33 ] ##### PROPERTIES OF MATRIX MULTIPLICATION For the matrices A,B,A,B, and CC the following properties hold. • Matrix multiplication is associative: (AB)C=A(BC).(AB)C=A(BC). • Matrix multiplication is distributive: C(A+B)=CA+CB,(A+B)C=AC+BC.C(A+B)=CA+CB,(A+B)C=AC+BC. Note that matrix multiplication is not commutative. ### EXAMPLE 8 #### Multiplying Two Matrices Multiply matrix AA and matrix B.B. A=[1324] and B=[5768]A=[ 1234 ] and B=[ 5678 ] Answer ### EXAMPLE 9 #### Multiplying Two Matrices Given AA and B:B: 1. ⓐ Find AB.AB. 2. ⓑ Find BA.BA. A=[−123405]and B=⎡⎣⎢5−42−103⎤⎦⎥A=[ −123405 ]and B=[ 5−42−103 ] Answer #### Analysis Notice that the products ABAB and BABA are not equal. AB=[−7301011]≠⎡⎣⎢−941010−8410−1221⎤⎦⎥=BAAB=[ −7103011 ]≠[ −910104−8−1210421 ]=BA This illustrates the fact that matrix multiplication is not commutative. ##### Q&A Is it possible for AB to be defined but not BA? Yes, consider a matrix A with dimension 3×43×4 and matrix B with dimension 4×2.4×2. For the product AB the inner dimensions are 4 and the product is defined, but for the product BA the inner dimensions are 2 and 3 so the product is undefined. ### EXAMPLE 10 #### Using Matrices in Real-World Problems Let’s return to the problem presented at the opening of this section. We have Table 3, representing the equipment needs of two soccer teams. Wildcats Mud Cats Goals 6 10 Balls 30 24 Jerseys 14 20 Table 3 We are also given the prices of the equipment, as shown in Table 4.  Goal300 Ball $10 Jersey$30

Table 4

We will convert the data to matrices. Thus, the equipment need matrix is written as

E=⎡⎣⎢63014102420⎤⎦⎥E=[ 63014102420 ]

The cost matrix is written as

C=[3001030]C=[ 3001030 ]

We perform matrix multiplication to obtain costs for the equipment.

CE=[3001030]⎡⎣⎢63014102420⎤⎦⎥=[300(6)+10(30)+30(14)300(10)+10(24)+30(20)]=[2,5203,840]CE=[ 3001030 ][ 61030241420 ]=[ 300(6)+10(30)+30(14)300(10)+10(24)+30(20) ]=[ 2,5203,840 ]

The total cost for equipment for the Wildcats is $2,520, and the total cost for equipment for the Mud Cats is$3,840.

##### HOW TO

Given a matrix operation, evaluate using a calculator.

1. Save each matrix as a matrix variable [A],[B],[C],...[ A ],[ B ],[ C ],...
2. Enter the operation into the calculator, calling up each matrix variable as needed.
3. If the operation is defined, the calculator will present the solution matrix; if the operation is undefined, it will display an error message.

### EXAMPLE 11

#### Using a Calculator to Perform Matrix Operations

Find AB−CAB−C given

A=⎡⎣⎢−15411025−73432−28−2⎤⎦⎥,B=⎡⎣⎢45−2462152−48−3719−31⎤⎦⎥,and C=⎡⎣⎢−10025−67−89−5642−9874−75⎤⎦⎥.A=[ −15253241−7−281034−2 ],B=[ 4521−37−2452196−48−31 ],and C=[ −100−89−9825−5674−6742−75 ].

##### MEDIA

Access these online resources for additional instruction and practice with matrices and matrix operations.

### 9.5 Section Exercises

#### Verbal

1.

Can we add any two matrices together? If so, explain why; if not, explain why not and give an example of two matrices that cannot be added together.

2.

Can we multiply any column matrix by any row matrix? Explain why or why not.

3.

Can both the products ABAB and BABA be defined? If so, explain how; if not, explain why.

4.

Can any two matrices of the same size be multiplied? If so, explain why, and if not, explain why not and give an example of two matrices of the same size that cannot be multiplied together.

5.

Does matrix multiplication commute? That is, does AB=BA?AB=BA? If so, prove why it does. If not, explain why it does not.

#### Algebraic

For the following exercises, use the matrices below and perform the matrix addition or subtraction. Indicate if the operation is undefined.

A=[1037],B=[222146],C=⎡⎣⎢18125926⎤⎦⎥,D=⎡⎣⎢107514261⎤⎦⎥,E=[614125],F=⎡⎣⎢078159174⎤⎦⎥A=[ 1307 ],B=[ 214226 ],C=[ 15892126 ],D=[ 101472561 ],E=[ 612145 ],F=[ 097817154 ]

6.

A+BA+B

7.

C+DC+D

8.

A+CA+C

9.

B−EB−E

10.

C+FC+F

11.

D−BD−B

For the following exercises, use the matrices below to perform scalar multiplication.

A=[413612],B=⎡⎣⎢321091264⎤⎦⎥,C=[169035731829],D=⎡⎣⎢18871214413621⎤⎦⎥A=[ 461312 ],B=[ 392112064 ],C=[ 163718905329 ],D=[ 18121381467421 ]

12.

5A5A

13.

3B3B

14.

−2B−2B

15.

−4C−4C

16.

12C12C

17.

100D100D

For the following exercises, use the matrices below to perform matrix multiplication.

A=[−1352],B=[3−860412],C=⎡⎣⎢4−251069⎤⎦⎥,D=⎡⎣⎢290−338121−10⎤⎦⎥A=[ −1532 ],B=[ 364−8012 ],C=[ 410−2659 ],D=[ 2−31293108−10 ]

18.

ABAB

19.

BCBC

20.

CACA

21.

BDBD

22.

DCDC

23.

CBCB

For the following exercises, use the matrices below to perform the indicated operation if possible. If not possible, explain why the operation cannot be performed.

A=[26−57],B=[−9−462],C=[0791],D=⎡⎣⎢−840739−522⎤⎦⎥,E=⎡⎣⎢4715−603−59⎤⎦⎥A=[ 2−567 ],B=[ −96−42 ],C=[ 0971 ],D=[ −87−5432092 ],E=[ 4537−6−5109 ]

24.

A+B−CA+B−C

25.

4A+5D4A+5D

26.

2C+B2C+B

27.

3D+4E3D+4E

28.

C−0.5DC−0.5D

29.

100D−10E100D−10E

For the following exercises, use the matrices below to perform the indicated operation if possible. If not possible, explain why the operation cannot be performed. (Hint: A2=A⋅AA2=A⋅A )

A=[−1052025],B=[40−201030],C=⎡⎣⎢−1010−10⎤⎦⎥A=[ −1020525 ],B=[ 4010−2030 ],C=[ −100−110 ]

30.

ABAB

31.

BABA

32.

CACA

33.

BCBC

34.

A2A2

35.

B2B2

36.

C2C2

37.

B2A2B2A2

38.

A2B2A2B2

39.

(AB)2(AB)2

40.

(BA)2(BA)2

For the following exercises, use the matrices below to perform the indicated operation if possible. If not possible, explain why the operation cannot be performed. (Hint: A2=A⋅AA2=A⋅A )

A=[1203],B=[−2−1314−5],C=⎡⎣⎢0.51−0.50.10.20.3⎤⎦⎥,D=⎡⎣⎢1−64072−151⎤⎦⎥A=[ 1023 ],B=[ −234−11−5 ],C=[ 0.50.110.2−0.50.3 ],D=[ 10−1−675421 ]

41.

ABAB

42.

BABA

43.

BDBD

44.

DCDC

45.

D2D2

46.

A2A2

47.

D3D3

48.

(AB)C(AB)C

49.

A(BC)A(BC)

#### Technology

For the following exercises, use the matrices below to perform the indicated operation if possible. If not possible, explain why the operation cannot be performed. Use a calculator to verify your solution.

A=⎡⎣⎢−210.50849−35⎤⎦⎥,B=⎡⎣⎢0.5−48317062⎤⎦⎥,C=⎡⎣⎢101010101⎤⎦⎥A=[ −20918−30.545 ],B=[ 0.530−416872 ],C=[ 101010101 ]

50.

ABAB

51.

BABA

52.

CACA

53.

BCBC

54.

ABCABC

#### Extensions

For the following exercises, use the matrix below to perform the indicated operation on the given matrix.

B=⎡⎣⎢100001010⎤⎦⎥B=[ 100001010 ]

55.

B2B2

56.

B3B3

57.

B4B4

58.

B5B5

59.

Using the above questions, find a formula for Bn.Bn. Test the formula for B201B201 and B202,B202, using a calculator.

This page titled 9.6: Matrices and Matrix Operations is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by OpenStax via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.