Matrices

⏱ 5 min✏️ Quiz at the end

Introduction

A matrix (plural: matrices) is a rectangular arrangement of numbers organised into rows and columns, enclosed in brackets. Matrices are a compact way to store and manipulate sets of numbers, and they show up anywhere data needs to be organised in a grid β€” from simultaneous equations to the transformations that move characters around a screen in a video game.

A single number inside a matrix is called an element or entry. Matrices are usually named with a capital letter, such as A or B.

A = | 2  3 |
    | 1  4 |

This matrix A has 2 rows and 2 columns.

Matrix Notation and Order

The order (or dimensions) of a matrix describes its size, written as rows Γ— columns.

B = | 5  0  2 |
    | 1  7  3 |

Matrix B has 2 rows and 3 columns, so its order is 2Γ—3. A matrix with the same number of rows and columns (like matrix A above) is called a square matrix.

To identify an individual element, use its row and column position. In matrix B, the element in row 1, column 3 is 2, and the element in row 2, column 2 is 7.

Adding and Subtracting Matrices

Matrices can only be added or subtracted if they have exactly the same order. When they do, you simply add or subtract the elements in matching positions.

Example: Add these two 2Γ—2 matrices.

| 2  1 |   | 4  3 |   | 6  4 |
| 5  0 | + | 2  6 | = | 7  6 |

Each entry is combined with the entry in the same position: 2 + 4 = 6, 1 + 3 = 4, 5 + 2 = 7, 0 + 6 = 6.

Subtraction works the same way, but you subtract each pair of matching elements instead.

Scalar Multiplication

A scalar is just an ordinary number (as opposed to a matrix). To multiply a matrix by a scalar, multiply every element by that number.

Example: Multiply the matrix by 3.

     | 2   -1 |   | 6   -3 |
 3 Γ— | 0    4 | = | 0   12 |

Every entry has simply been scaled up by the same factor.

Matrix Multiplication

Multiplying two matrices together is more involved than addition, and it does not work by multiplying matching elements. Instead, each entry in the result comes from multiplying a row of the first matrix by a column of the second matrix and adding the products together.

Compatibility rule: you can only multiply matrix A by matrix B if the number of columns in A equals the number of rows in B. If A has order pΓ—q and B has order qΓ—z, the result AB has order pΓ—z.

Example: Multiply a 2Γ—2 matrix by a 2Γ—2 matrix.

| 1  2 |   | 5  6 |   | (1Γ—5 + 2Γ—7)  (1Γ—6 + 2Γ—8) |   | 19  22 |
| 3  4 | Γ— | 7  8 | = | (3Γ—5 + 4Γ—7)  (3Γ—6 + 4Γ—8) | = | 43  50 |

Notice how the top-left entry, 19, comes from row 1 of the first matrix (1, 2) paired with column 1 of the second matrix (5, 7): (1 Γ— 5) + (2 Γ— 7) = 19.

An important property to remember: matrix multiplication is generally not commutative, meaning AB does not usually equal BA. The order in which you multiply matrices matters.

The Determinant of a 2x2 Matrix

The determinant is a single number calculated from a square matrix that reveals important properties about it β€” including whether the matrix has an inverse.

For a 2Γ—2 matrix with entries a, b, c, d:

      | a  b |
det = | c  d |  =  ad - bc

Example: Find the determinant of this matrix.

| 4  2 |
| 3  1 |

det = (4 Γ— 1) - (2 Γ— 3) = 4 - 6 = -2

If a matrix's determinant equals 0, the matrix is called singular and does not have an inverse β€” this is similar to how you cannot divide an ordinary number by 0.

Real-World Uses of Matrices

Matrices are far more than an abstract exercise. They are used to:

  • Represent transformations (rotation, reflection, enlargement) in computer graphics and video games
  • Solve systems of simultaneous equations efficiently, especially with three or more unknowns
  • Encode and decode information in computer science and cryptography
  • Model networks, populations, and probabilities in statistics and economics

Common Mistakes

  • Adding matrices of different orders β€” this is impossible; check the orders match first.
  • Multiplying matrices element-by-element β€” matrix multiplication uses the row-by-column method, not simple pairing.
  • Ignoring the order of multiplication β€” remember AB does not usually equal BA.
  • Mixing up rows and columns β€” the order is always rows Γ— columns, never the other way around.
  • Sign errors in the determinant β€” the formula is ad minus bc, not ad plus bc.

Tips and Tricks

  • Before adding or multiplying, always write down the order of each matrix first β€” it tells you immediately whether the operation is even possible.
  • When multiplying, work through the result one entry at a time: pick a row from the first matrix and a column from the second, multiply matching pairs, then add.
  • A quick way to check if an inverse exists is to calculate the determinant first β€” if it is 0, stop, because no inverse exists.
  • Practise 2Γ—2 examples until the row-by-column pattern of multiplication feels automatic before moving on to larger matrices.