Matrix Operations
A matrix is a rectangular array of numbers arranged in rows and columns. Basic matrix operations are adding, subtracting and multiplying by a number (a scalar). To add or subtract, the matrices must have the same dimensions, and you combine the entries in matching positions. To multiply by a scalar, multiply every entry by that number.
Before this lesson: You should know Systems of Equations in Three Variables, Adding and Subtracting Integers and Multiplying and Dividing Integers.
What a Matrix Is
A matrix organizes numbers in a grid, like a spreadsheet. We name matrices with capital letters, such as A. The dimensions of a matrix are its number of rows by its number of columns, always rows first. A matrix with 2 rows and 3 columns is a 2 \times 3 matrix.
Each number in a matrix is an entry. The entry in row i and column j of matrix A is written a_{ij}. In the picture, a_{23} = -3, because −3 is in row 2, column 3.
Rules for Matrix Operations
| Operation | When it works | How to do it |
|---|---|---|
| Addition A + B | Same dimensions | Add matching entries |
| Subtraction A - B | Same dimensions | Subtract matching entries |
| Scalar multiple kA | Always | Multiply every entry by k |
| Equality A = B | Same dimensions | Every pair of matching entries is equal |
\begin{bmatrix} a & b \\ c & d \end{bmatrix} + \begin{bmatrix} e & f \\ g & h \end{bmatrix} = \begin{bmatrix} a + e & b + f \\ c + g & d + h \end{bmatrix}, \quad k\begin{bmatrix} a & b \\ c & d \end{bmatrix} = \begin{bmatrix} ka & kb \\ kc & kd \end{bmatrix}Matrix addition is commutative, A + B = B + A, just like adding numbers. A zero matrix, with every entry 0, acts like the number 0: A + O = A.
Worked Examples
Example 1: Dimensions and entries
Let A = \begin{bmatrix} 4 & -1 & 0 \\ 2 & 7 & -3 \end{bmatrix}. Find the dimensions of A, a_{12} and a_{23}.
Count the rows: 2. Count the columns: 3. So A is 2 \times 3
a_{12} = -1a_{12} is in row 1, column 2.
a_{23} = -3a_{23} is in row 2, column 3.
Answer: 2 \times 3; a_{12} = -1; a_{23} = -3
Example 2: Add two matrices
Find A + B for A = \begin{bmatrix} 3 & -2 \\ 5 & 0 \end{bmatrix} and B = \begin{bmatrix} -1 & 4 \\ 2 & 6 \end{bmatrix}.
Both are 2 \times 2, so they can be added
\begin{bmatrix} 3 + (-1) & -2 + 4 \\ 5 + 2 & 0 + 6 \end{bmatrix}Add matching entries.
\begin{bmatrix} 2 & 2 \\ 7 & 6 \end{bmatrix}Simplify each entry.
Answer: A + B = \begin{bmatrix} 2 & 2 \\ 7 & 6 \end{bmatrix}
Example 3: Scalar multiples and subtraction
Find 3A - 2B for A = \begin{bmatrix} 1 & 4 \\ -2 & 3 \end{bmatrix} and B = \begin{bmatrix} 5 & 0 \\ 1 & -2 \end{bmatrix}.
3A = \begin{bmatrix} 3 & 12 \\ -6 & 9 \end{bmatrix}Multiply every entry of A by 3.
2B = \begin{bmatrix} 10 & 0 \\ 2 & -4 \end{bmatrix}Multiply every entry of B by 2.
\begin{bmatrix} 3 - 10 & 12 - 0 \\ -6 - 2 & 9 - (-4) \end{bmatrix}Subtract matching entries.
\begin{bmatrix} -7 & 12 \\ -8 & 13 \end{bmatrix}Simplify.
Answer: 3A - 2B = \begin{bmatrix} -7 & 12 \\ -8 & 13 \end{bmatrix}
Example 4: Solve a matrix equation
Solve for X: 2X + \begin{bmatrix} 1 & -3 \\ 4 & 0 \end{bmatrix} = \begin{bmatrix} 7 & 5 \\ -2 & 6 \end{bmatrix}.
2X = \begin{bmatrix} 7 - 1 & 5 - (-3) \\ -2 - 4 & 6 - 0 \end{bmatrix}Subtract the known matrix from both sides.
2X = \begin{bmatrix} 6 & 8 \\ -6 & 6 \end{bmatrix}Simplify.
X = \begin{bmatrix} 3 & 4 \\ -3 & 3 \end{bmatrix}Multiply both sides by \frac{1}{2}.
Answer: X = \begin{bmatrix} 3 & 4 \\ -3 & 3 \end{bmatrix}. The steps are the same as solving 2x + 1 = 7, done entry by entry.
Example 5: Word problem with store sales
Two stores sell small, medium and large shirts. The matrices show sales in weeks 1 and 2, with Store A in row 1 and Store B in row 2. Find the total sales for both weeks, and how many more each store sold in week 2 than week 1.
W_1 = \begin{bmatrix} 12 & 8 & 5 \\ 9 & 14 & 6 \end{bmatrix}, \quad W_2 = \begin{bmatrix} 10 & 11 & 7 \\ 13 & 9 & 4 \end{bmatrix}W_1 + W_2 = \begin{bmatrix} 12 + 10 & 8 + 11 & 5 + 7 \\ 9 + 13 & 14 + 9 & 6 + 4 \end{bmatrix} = \begin{bmatrix} 22 & 19 & 12 \\ 22 & 23 & 10 \end{bmatrix}Add for the total.
W_2 - W_1 = \begin{bmatrix} 10 - 12 & 11 - 8 & 7 - 5 \\ 13 - 9 & 9 - 14 & 4 - 6 \end{bmatrix} = \begin{bmatrix} -2 & 3 & 2 \\ 4 & -5 & -2 \end{bmatrix}Subtract for the change.
Answer: Store A sold 22 small, 19 medium and 12 large; Store B sold 22, 23 and 10. In week 2, Store A sold 2 fewer small shirts but 3 more medium, and Store B sold 5 fewer medium shirts.
Common Mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Columns first in dimensions | Calling a matrix with 2 rows and 3 columns 3 \times 2 | Always rows first: 2 \times 3. |
| Adding different sizes | Adding a 2 \times 3 and a 3 \times 2 matrix | Addition needs the same dimensions; the sum is undefined. |
| Scaling only one entry | 2\begin{bmatrix} 1 & 3 \\ 0 & 4 \end{bmatrix} = \begin{bmatrix} 2 & 3 \\ 0 & 4 \end{bmatrix} | Multiply every entry: \begin{bmatrix} 2 & 6 \\ 0 & 8 \end{bmatrix}. |
| Sign errors when subtracting | 9 - (-4) = 5 | Subtracting a negative adds: 9 + 4 = 13. |
| Mixing up a_ij | Reading a_{23} as row 3, column 2 | The first number is the row, the second is the column. |
Related Methods
Matrix multiplication
Multiplying two matrices is different from multiplying by a scalar. It combines rows of the first matrix with columns of the second. That is the next lesson, matrix multiplication.
Matrices for systems
A matrix can hold the coefficients of a system of equations, like the ones in systems of equations in three variables. Row operations on that matrix solve the system.
Graphing calculator
Calculators can store matrices and add, subtract or scale them. Enter each matrix in the matrix editor, then type the expression, such as 3[A] - 2[B].
Practice Problems
- Give the dimensions of \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bmatrix} and its entry a_{31}.
- Find \begin{bmatrix} 2 & -3 \\ 4 & 1 \end{bmatrix} + \begin{bmatrix} -5 & 3 \\ 0 & 6 \end{bmatrix}.
- Find \begin{bmatrix} 7 & 2 & -1 \end{bmatrix} - \begin{bmatrix} 4 & -3 & 5 \end{bmatrix}.
- Find -4\begin{bmatrix} 1 & -2 \\ 0 & 3 \end{bmatrix}.
- Find 2A + B for A = \begin{bmatrix} 3 & 0 \\ -1 & 2 \end{bmatrix} and B = \begin{bmatrix} -4 & 1 \\ 5 & -3 \end{bmatrix}.
- Can you add a 2 \times 3 matrix and a 3 \times 2 matrix? Explain.
- Solve for X: X - \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} = \begin{bmatrix} 0 & -1 \\ 2 & 5 \end{bmatrix}.
- Solve for X: 3X = \begin{bmatrix} 6 & -9 \\ 12 & 0 \end{bmatrix}.
- Find x and y if \begin{bmatrix} x + 2 & 5 \\ 3 & 2y \end{bmatrix} = \begin{bmatrix} 7 & 5 \\ 3 & -8 \end{bmatrix}.
- A matrix lists prices (in dollars) of three items at two stores: P = \begin{bmatrix} 4.00 & 2.50 \\ 6.00 & 5.20 \\ 1.80 & 2.10 \end{bmatrix}. During a 10%-off sale, every price is multiplied by 0.9. Find the sale prices.
Show answers
1.
3 rows and 2 columns
a_{31} is row 3, column 1
Answer: 3 \times 2; a_{31} = 5
2.
\begin{bmatrix} 2 + (-5) & -3 + 3 \\ 4 + 0 & 1 + 6 \end{bmatrix}Add matching entries.
Answer: \begin{bmatrix} -3 & 0 \\ 4 & 7 \end{bmatrix}
3.
\begin{bmatrix} 7 - 4 & 2 - (-3) & -1 - 5 \end{bmatrix}Subtract matching entries.
Answer: \begin{bmatrix} 3 & 5 & -6 \end{bmatrix}
4.
\begin{bmatrix} -4(1) & -4(-2) \\ -4(0) & -4(3) \end{bmatrix}Multiply each entry by −4.
Answer: \begin{bmatrix} -4 & 8 \\ 0 & -12 \end{bmatrix}
5.
2A = \begin{bmatrix} 6 & 0 \\ -2 & 4 \end{bmatrix}Multiply each entry by 2.
\begin{bmatrix} 6 + (-4) & 0 + 1 \\ -2 + 5 & 4 + (-3) \end{bmatrix}Add B.
Answer: \begin{bmatrix} 2 & 1 \\ 3 & 1 \end{bmatrix}
6.
The dimensions are different, so the entries don’t match up
Answer: no; the sum is undefined
7.
X = \begin{bmatrix} 0 + 1 & -1 + 2 \\ 2 + 3 & 5 + 4 \end{bmatrix}Add the known matrix to both sides.
Answer: X = \begin{bmatrix} 1 & 1 \\ 5 & 9 \end{bmatrix}
8.
X = \begin{bmatrix} \frac{6}{3} & \frac{-9}{3} \\ \frac{12}{3} & \frac{0}{3} \end{bmatrix}Multiply both sides by \frac{1}{3}.
Answer: X = \begin{bmatrix} 2 & -3 \\ 4 & 0 \end{bmatrix}
9.
x + 2 = 7
Match row 1, column 1.
x = 5
Subtract 2 from both sides.
2y = -8
Match row 2, column 2.
y = -4
Divide both sides by 2.
Answer: x = 5, y = -4
10.
Multiply each entry by 0.9: 0.9(4.00) = 3.60, 0.9(2.50) = 2.25, 0.9(6.00) = 5.40, 0.9(5.20) = 4.68, 0.9(1.80) = 1.62, 0.9(2.10) = 1.89
Answer: 0.9P = \begin{bmatrix} 3.60 & 2.25 \\ 5.40 & 4.68 \\ 1.62 & 1.89 \end{bmatrix}
FAQ
How do you add matrices?
Check that they have the same dimensions, then add the entries in matching positions. The sum has the same dimensions as each matrix.
What are the dimensions of a matrix?
The number of rows by the number of columns, rows first. A matrix with 3 rows and 4 columns is 3 \times 4.
What is scalar multiplication?
Multiplying a matrix by a single number, called a scalar. Every entry gets multiplied by that number.
Can you subtract matrices of different sizes?
No. Like addition, subtraction only works when both matrices have exactly the same dimensions.
Summary
- A matrix’s dimensions are rows by columns, rows first.
- a_{ij} is the entry in row i and column j.
- Add or subtract only matrices with the same dimensions, entry by entry.
- A scalar multiple multiplies every entry by the scalar.
- Solve matrix equations entry by entry, like ordinary equations.
Previous lesson: Logistic Functions
Next lesson: Matrix Multiplication
Back to the Precalculus Index