Crayonbird
Menu

Maths

What is a matrix in maths, and how do you multiply matrices?

Quick answer

A matrix is a rectangular grid of numbers in rows and columns. You add matrices entry by entry, and you multiply them row by column, which only works when the sizes match.

Ages 15–18Secondary

In one sentence

A matrix is a rectangle of numbers arranged in rows and columns, and the plural is matrices (say "MAY-trih-seez").

Explained

A matrix stores several numbers at once. A league table or the pixels of an image are grids of numbers. In maths a matrix is written inside big brackets. On this page we write a matrix on one line, row by row, with a semicolon between the rows: [1 2 3; 4 5 6] means the first row is 1 2 3 and the second row is 4 5 6.

The order (size) of a matrix is rows × columns. [1 2 3; 4 5 6] has 2 rows and 3 columns, so it is a 2 × 3 matrix ("two by three"). Each number is an entry (or element). The entry in row i, column j is written aᵢⱼ, so in this matrix a₂₁ = 4 and a₁₃ = 3.

  • blocks
  • computer
  • football
A matrix is a grid of numbers, like a table of scores or the pixels a computer uses to draw a game.

Some matrices have special names:

  • Row matrix: one row, like [3 1 4]. Column matrix: one column, like [2; 5].
  • Square matrix: the same number of rows and columns, like a 2 × 2 or 3 × 3.
  • Zero matrix: every entry is 0.
  • Identity matrix I: 1s on the main diagonal (top left to bottom right) and 0s elsewhere, like [1 0; 0 1]. It works like the number 1: AI = IA = A.

Adding and subtracting. You can only add two matrices of the same order. Add the entries in the same position: [1 2; 3 4] + [5 0; −1 2] = [6 2; 2 6]. Multiplying by a number (a scalar) multiplies every entry: 3 × [2 −1; 0 4] = [6 −3; 0 12].

Multiplying two matrices is different, and it is what most people search for. To find an entry of AB, take a row of A and a column of B, multiply the pairs of numbers and add them up. Row 1 with column 1 gives the entry in row 1, column 1; row 2 with column 1 gives row 2, column 1, and so on. That is why it only works when the number of columns of A equals the number of rows of B. A 2 × 3 matrix times a 3 × 4 matrix is allowed (the inside numbers, 3 and 3, match), and the answer is 2 × 4 (the outside numbers).

The order matters: usually AB ≠ BA, so matrix multiplication is not commutative.

For a 2 × 2 matrix [a b; c d], the determinant is ad − bc. If it is not zero, the matrix has an inverse A⁻¹ with AA⁻¹ = I:

A⁻¹ = (1 ÷ (ad − bc)) × [d −b; −c a]

Swap a and d, change the signs of b and c, divide by the determinant. The inverse lets you solve simultaneous equations in one go. Matrices also move shapes: [0 −1; 1 0] rotates every point 90° anticlockwise, which links them to transformations and column vectors. Computer graphics and AI run on huge numbers of matrix multiplications.

Examples

Worked example: multiply A = [1 2; 3 4] by B = [5 6; 7 8]. Both are 2 × 2, so AB is 2 × 2.

Entry of AB Row of A × column of B Value
row 1, column 1 1 × 5 + 2 × 7 19
row 1, column 2 1 × 6 + 2 × 8 22
row 2, column 1 3 × 5 + 4 × 7 43
row 2, column 2 3 × 6 + 4 × 8 50

So AB = [19 22; 43 50]. In the other order, BA = [5 × 1 + 6 × 3, 5 × 2 + 6 × 4; …] = [23 34; 31 46], which is different.

More examples:

  • 2 × 2 times 2 × 1: [2 1; 0 3] × [4; 5] = [2 × 4 + 1 × 5; 0 × 4 + 3 × 5] = [13; 15].
  • 3 × 3 times 3 × 1: [1 0 2; 0 1 0; 3 0 1] × [1; 2; 3] = [1 + 0 + 6; 0 + 2 + 0; 3 + 0 + 3] = [7; 2; 6].
  • Determinant: [5 2; 3 4] has determinant 5 × 4 − 2 × 3 = 14.

Common mistakes

  • Multiplying entry by entry. [1 2; 3 4] × [5 6; 7 8] is not [5 12; 21 32]. Fix: always go row by column, then add.
  • Swapping the order. AB and BA are usually different. Keep the matrices in the order the question gives.
  • Multiplying when the sizes don't fit. Write the orders side by side, like (3 × 2)(3 × 2). The inside numbers, 2 and 3, don't match, so the product does not exist.
  • Getting the inverse signs wrong. For [a b; c d] you swap a and d but only change the signs of b and c. Then divide by ad − bc, not by ad + bc.

Step by step

Step by step

  1. Check the sizesWrite the orders, like (2 × 3)(3 × 2). If the inside numbers match, you can multiply; the outside numbers give the size of the answer.
  2. Draw the answer gridMake an empty matrix of that size so you know how many entries to find.
  3. Row times columnFor the entry in row i, column j, take row i of the first matrix and column j of the second.
  4. Multiply and addMultiply the first numbers, the second numbers and so on, then add the results.
  5. Repeat and checkFill every entry. Check one entry again, and watch the minus signs.

Calculators help with checking: a TI-84 has a matrix menu, Desmos has a matrix calculator, and in Python with NumPy A @ B multiplies matrices. Exams still expect the row-by-column working.

Practice questions

Matrices practice

Try each one, then check your answer.

  1. What is the order of [1 2 3; 4 5 6]?
    Show answer
    2 rows and 3 columns: 2 × 3
  2. In A = [4 7; −2 5], what is a₂₁?
    Show answer
    Row 2, column 1: −2
  3. Work out [1 2; 3 4] + [5 0; −1 2].
    Show answer
    Add matching entries: [6 2; 2 6]
  4. Work out [7 3; 5 −1] − [2 4; 5 −3].
    Show answer
    7 − 2, 3 − 4, 5 − 5, −1 − (−3): [5 −1; 0 2]
  5. Work out 3 × [2 −1; 0 4].
    Show answer
    Multiply every entry by 3: [6 −3; 0 12]
  6. Can you add a 2 × 3 matrix and a 3 × 2 matrix?
    Show answer
    No: you can only add matrices of the same order.
  7. Work out [2 1; 0 3] × [4; 5].
    Show answer
    [2 × 4 + 1 × 5; 0 × 4 + 3 × 5] = [13; 15]
  8. Work out [1 2; 3 4] × [2 0; 1 3].
    Show answer
    [1 × 2 + 2 × 1, 1 × 0 + 2 × 3; 3 × 2 + 4 × 1, 3 × 0 + 4 × 3] = [4 6; 10 12]
  9. Work out [2 0; 1 3] × [1 2; 3 4]. Is it the same as AB = [1 2; 3 4] × [2 0; 1 3]?
    Show answer
    [2 + 0, 4 + 0; 1 + 9, 2 + 12] = [2 4; 10 14]: no, AB was [4 6; 10 12], so the order matters.
  10. A is 2 × 3 and B is 3 × 4. What is the order of AB?
    Show answer
    The inside numbers match (3 and 3); the answer is 2 × 4.
  11. A is 3 × 2 and B is 3 × 2. Does AB exist?
    Show answer
    A has 2 columns but B has 3 rows, so no.
  12. Work out [1 2 3] × [4; 5; 6].
    Show answer
    1 × 4 + 2 × 5 + 3 × 6 = 4 + 10 + 18 = [32]
  13. Find the determinant of [5 2; 3 4].
    Show answer
    5 × 4 − 2 × 3 = 20 − 6 = 14
  14. Find the determinant of [3 6; 1 2]. Does the matrix have an inverse?
    Show answer
    3 × 2 − 6 × 1 = 0, so no inverse (the matrix is singular).
  15. Find the inverse of [4 7; 2 6].
    Show answer
    Determinant = 24 − 14 = 10. Inverse = (1/10) × [6 −7; −2 4] = [0.6 −0.7; −0.2 0.4]
  16. Work out [1 0; 0 1] × [3 −2; 5 7].
    Show answer
    The identity changes nothing: [3 −2; 5 7]

Word problems

Matrices in real life

Try each one, then check your answer.

  1. A café sells juice at $2 and sandwiches at $5. On Monday it sold 3 juices and 2 sandwiches; on Tuesday 1 juice and 4 sandwiches. Use [3 2; 1 4] × [2; 5] to find each day's takings.
    Show answer
    [3 × 2 + 2 × 5; 1 × 2 + 4 × 5] = [16; 22]: Monday $16, Tuesday $22
  2. A league gives 3 points for a win, 1 for a draw and 0 for a loss. Team A has 5 wins, 2 draws, 1 loss; Team B has 4 wins, 4 draws, 0 losses. Work out [5 2 1; 4 4 0] × [3; 1; 0].
    Show answer
    [15 + 2 + 0; 12 + 4 + 0] = [17; 16]: Team A 17 points, Team B 16 points
  3. The matrix [0 −1; 1 0] rotates points 90° anticlockwise about the origin. Where does the point (3, 1) go?
    Show answer
    [0 × 3 + (−1) × 1; 1 × 3 + 0 × 1] = [−1; 3]: (−1, 3)
  4. The matrix [1 0; 0 −1] reflects points in the x-axis. Where does (4, 2) go?
    Show answer
    [1 × 4 + 0 × 2; 0 × 4 + (−1) × 2] = [4; −2]: (4, −2)
  5. Solve 2x + y = 5 and x + 3y = 10 with matrices.
    Show answer
    A = [2 1; 1 3], determinant 6 − 1 = 5, A⁻¹ = (1/5) × [3 −1; −1 2]. Then [x; y] = (1/5) × [3 × 5 − 1 × 10; −1 × 5 + 2 × 10] = (1/5) × [5; 15] = x = 1, y = 3

Questions people ask

What is a matrix in simple words?

A rectangular table of numbers in rows and columns, written in brackets. A 2 × 3 matrix has 2 rows and 3 columns.

Is the plural matrices or matrixes?

Matrices is the standard plural in maths and is pronounced "MAY-trih-seez". "Matrixes" appears in some dictionaries, but textbooks and exams use matrices.

What is the rule for matrix multiplication?

The number of columns in the first matrix must equal the number of rows in the second. Each entry of the answer is a row of the first matrix times a column of the second: multiply in pairs and add.

Why is matrix multiplication not commutative?

Because AB uses the rows of A with the columns of B, while BA uses the rows of B with the columns of A, which are different calculations. Sometimes BA does not even exist when AB does.

How do you multiply 3 × 3 matrices?

The same way as 2 × 2: each of the 9 entries is a row times a column, with three products added together. For example, row 1 of [1 0 2; …] with the column [1; 2; 3] gives 1 + 0 + 6 = 7.

What are matrices and determinants used for?

Solving systems of equations, describing rotations, reflections and enlargements, computer graphics and games, and AI: neural networks are built from huge matrix multiplications.

Quick quiz

Matrices

Check what you know with 5 quick questions.

Question 1 of 5

A matrix has 3 rows and 2 columns. What is its order (size)?

Practise it

Try it

All Algebra sheets

Practise it step by step in a full course: Grade 12 Maths

For grown-ups

Simultaneous equations (systems of equations)

Simultaneous equations (a system of equations in the US) are two or more equations that share unknowns and must all be true at once. Solve them by elimination, substitution or graphing.

Maths · Ages 13–16

Vectors

A vector is a quantity with both size (magnitude) and direction, like “5 km north”. In maths it is written as a column of numbers, such as (3, 4), and drawn as an arrow.

Maths · Ages 14–17

Algebra

Algebra is maths that uses letters, like x or n, to stand for numbers we don't know yet or numbers that can change. For example, if n + 3 = 10, then n = 7.

Maths · Ages 10–16

Completing the square

Completing the square rewrites x² + bx + c as (x + b/2)² − (b/2)² + c. It solves quadratics, finds the vertex (turning point) of a parabola and proves the quadratic formula.

Maths · Ages 13–17

Composite functions

A composite function applies one function and then another. f(g(x)), also written (f ∘ g)(x) or fg(x), means do g first, then put the answer into f.

Maths · Ages 14–18

Back to the Learning Wiki