Advanced Placement
Skip to the notes

AP Precalculus

Topic 4.10: Matrices

Watch now18 min

Updated · For the May 2027 AP exam

Matrices: rows and columns, when a product exists, and each entry of a product as a row times a column. Score three songs for every dancer at a rooftop silent disco, and work out which song each one ends up hearing.

Topic 4.10 key terms

matrix
A rectangular array of numbers arranged in rows and columns. In the lesson, each row of the song matrix FF is a song and each column is a feature.
dimensions (n × m)
An n×mn \times m matrix has nn rows and mm columns. The size is always given rows first, then columns.
entry (row i, column j)
The number in row ii, column jj of a matrix, written aija_{ij}: row first, then column. a12a_{12} and a21a_{21} are different entries.
when a product is defined
ABAB exists only when the number of columns of AA equals the number of rows of BB: (n×m)(m×p)→n×p(n \times m)(m \times p) \to n \times p.
entry of a product
The entry in row ii, column jj of ABAB is the dot product of row ii of AA with column jj of BB: multiply matching entries and add.
not commutative
In general AB≠BAAB \ne BA: the reversed product may not exist, may have a different size, or may have different entries. Some pairs (two diagonal matrices) happen to commute.

Transcript

2,303 words · 8 parts

Music you can’t hear

Listen for a second. There are about a hundred and fifty people dancing on this roof. And you can’t hear a single note of their music. It’s a silent disco, so everyone’s wearing wireless headphones, and the light on each pair shows which of three songs that person is hearing, red, green or blue.

This is Ava. Right now her headphones are playing a song called Ember. And Ben, right next to her, is listening to something completely different, a song called Canopy. At a normal silent disco, you’d flip a switch on your headphones to pick a channel. But on our roof tonight, nobody picked their own song.

The headphones picked it for them, from a few numbers about each song and a few numbers about each person’s taste, and that’s the same kind of math your music app uses to pick your next song. So watch what happens when I change just one of Ben’s numbers. One number. And he’s listening to a completely different song.

By the end of this lesson, you’ll be able to work out which song anyone on this roof is hearing, switch it by changing a single number, and read the one calculation that picks a song for every single one of them at once. We call that calculation matrix multiplication, and it starts with something pretty ordinary, a table of numbers. So let’s go and meet the songs.

Every song is a row

For a minute, let’s switch off the blue channel, so there are just two songs, Ember and Canopy, and look at the DJ booths. Every song gets three numbers, each from zero to three, for how much energy it has, how much of it is voices, and how acoustic it sounds, real guitars and pianos instead of synthesizers. Ember is all energy, so it gets a three there, then a one for vocals and a zero for acoustic.

Canopy is close to the opposite, zero energy, a two for vocals and a three for acoustic, because it’s really just a voice and a guitar. Stack those two rows up and you get a table with two rows, one for each song, and three columns, one for each feature, and we call a table of numbers like this a matrix. We give its size as rows first, then columns, so this is a two by three matrix.

Here’s a quick one to get your hands on it. Tap the number in row one, column two, and think about what it’s telling you.

Now for the people. Each guest answered three questions on the way in, how much they care about energy, vocals and acoustic, and their headphones keep those three numbers as a column. Ava loves energy, so her column is a two for energy, a one for vocals and a zero for acoustic, and Ben’s is zero, one, two. Let’s put both tables on the board. Songs and people go side by side.

So here are our two matrices. I’ll call the songs F, for features, and the people T, for taste. F has two rows and three columns, so it’s two by three, and T has three rows and two columns, so it’s three by two. In general, an n by m matrix has n rows and m columns, and the size always goes rows first, then columns.

Every entry has an address too, written row first and then column, so f one two is the entry in row one, column two, Ember’s vocals, a one, and f two three is Canopy’s acoustic, a three. And f two one is somewhere else entirely, row two, column one, which is Canopy’s energy, a zero.

One score, three contributions

How do the headphones decide that Ava should hear Ember? They give every song a score for her. The song with the biggest score wins. To score Ember for Ava, we take Ember’s row of numbers and stand it up right next to Ava’s column, so energy sits beside energy, vocals beside vocals, and acoustic beside acoustic.

Then we multiply each pair. Ember’s energy is a three and Ava’s love of energy is a two, so three times two gives six points, vocals is one times one, one more point, and acoustic is zero times zero, nothing. Add them up, six plus one plus zero, and Ember scores a seven for Ava. Six of that seven came from Ember’s big energy times Ava’s love of energy, and acoustic added nothing at all.

Now let’s score Canopy for Ben. Energy is zero times zero, vocals is two times one, two, and acoustic is three times two, six, so Canopy scores zero plus two plus six, eight, and most of it comes from that acoustic pair. The headphones do this for every song and every person, and all of those scores fit into one more matrix, so let’s take it to the board.

Here’s the same thing in matrix form. F times T makes a new matrix of scores, which I’ll call S, and each score sits right where its song’s row meets its person’s column. Row one of F, Ember, is three, one, zero, and column one of T, Ava, is two, one, zero. Multiply the matching entries and add them, and you get the same seven.

In general, the entry in row i, column j of the product comes from row i of the first matrix and column j of the second, and it lands exactly where that row and that column cross. If that looks familiar, it should. It’s the dot product from vectors, just with three numbers in each list instead of two. Now you find one. Using row two of F and column one of T, what score does Canopy get for Ava?

Ember for Ben is just one, from vocals times vocals, and Canopy for Ben is the eight from the roof. So the whole score matrix is two by two. Each column is one person, Ava’s scores are seven and two and Ben’s are one and eight, and each row is one song. Ava’s biggest score is seven, for Ember, and Ben’s biggest is eight, for Canopy, which is exactly what their headphones were showing us at the start.

When the lists don’t match

Someone new just walked onto the roof. This is Cleo, and her headphones haven’t lit up at all. She answered the energy and vocals questions on the way in, but she skipped the acoustic one, so her column only has two numbers. Watch what happens when we try to score Canopy for her. Energy pairs with energy, and vocals pairs with vocals, but Canopy’s acoustic three has nothing to pair with.

There’s nothing to multiply it by, so there’s no score and no song, because the two lists have to be the same length. Once Cleo answers the acoustic question with a two, everything lines up, and zero plus four plus six makes ten, so her headphones light up green. So when exactly can you multiply two matrices? Let’s work it out on the board.

Start with just Ava and Ben, and write the two sizes side by side. F is two by three and T is three by two. The two numbers in the middle are the ones that have to match. F’s columns are a song’s three features and T’s rows are a person’s three features, so every song number has a taste number to pair with.

Then the two outside numbers tell you the size of the answer, two by two, one row for each song and one column for each person. With two numbers, Cleo’s column was two by one. The middle pair was three and two, so there was no product. Her third answer made her a third column of T. Now T is three by three, and the answer grows to two by three.

A three by two times a two by four gives a three by four. But a two by three, times another two by three, doesn’t work, even though they’re the same shape. The middle numbers are a three and a two. And a one by three times a three by one is a one by one. That’s a single dot product.

Now you try it. Say A is two by three and B is three by four. What can you say about A times B, and about B times A?

Matrices don’t have to be about songs, and their entries can be negative. Here’s a two by three times a three by two with no story at all. What’s the entry in row one, column two of this product? The other three entries work the same way, and the whole product is four, negative eleven, eight, and six.

The whole roof at once

Back on the roof, let’s switch the blue channel on again. Halo’s numbers are one for energy, three for vocals and one for acoustic. A new song means a new row in F, so every person gets one more score, a third lantern over their head. Before the headphones do it, can you work out Halo’s score for Ava? Take your time with it.

Now let’s do everybody. Every guest has a column of three taste numbers, so the whole party’s taste matrix is three by a hundred and fifty. F is three by three, and T is three by a hundred and fifty, so the middle numbers match, and one multiplication scores every song for every person, four hundred and fifty scores. And if we lift all of those lanterns up and line them up side by side, we get the whole product, one giant matrix hanging over the roof.

Every column is one person, and the biggest number in it picks their song, so fifty-four people up here are hearing Ember, fifty-one are hearing Canopy, and forty-five are hearing Halo. Real music apps work out their numbers from what millions of people actually play, and then score millions of songs with this same kind of multiplication. Here’s that same product. This time it’s on paper.

Read down a column, and you get one person’s scores for every song. Read across a row, and you get one song’s score for every person on the roof.

Order matters

Could we multiply the other way round, T times F? Go back to just Ava, Ben and two songs. T is three by two, and F is two by three. The middle numbers match, so T times F exists.

But it’s three by three. It isn’t even the same size as F times T. With the whole roof, T is three by a hundred and fifty. Now the middle numbers are a hundred and fifty and three, people and songs. They don’t match, so there’s no product at all.

Even when both orders work and give the same size, the answers usually come out different. Take these two small matrices, A and B. Row one of A is one, one. With column one of B, that’s one plus one, two. With column two, it’s just one.

Row two of A is zero, one. It gives one, then one. A times B is two, one, one, one. Now the order’s flipped, with B first and A second. What do you get for B times A?

A times B and B times A came out different. Swapping the order changed the answer. That’s why we say matrix multiplication isn’t commutative. And watch out for one more trap. Multiplying matching entries, top-left times top-left and so on, gives one, zero, zero, one here, which isn’t A times B at all.

Switch Ava’s song

Let’s go back up to the roof, where Ava’s still dancing to Ember. Her scores are seven for Ember, two for Canopy, and five for Halo. I promised you’d be able to switch someone’s song with a single number, so here’s your chance. Change just one number in Ava’s column so that her headphones turn green.

And notice what didn’t change. Nobody else on this roof switched songs, because changing one person’s taste only changes that person’s own column of scores. That’s also what happened to Ben at the start. Dropping his acoustic number to zero cost Canopy six points but Halo only two, so Halo won, three to two.

Now let’s put Ava back and change a song instead of a person. Canopy’s DJ is dropping a remix with more energy, so Canopy’s energy number goes from zero to two. Before it plays, think about which numbers up in that giant matrix can change. Only the Canopy row. Each Canopy score gains twice that person’s energy number, all at once. Canopy jumps from fifty-one listeners to a hundred and four.

Change a person, and you change one column. Change a song, and you change a whole row. You can see it right here in the light over this roof. So now you can do what these headphones do. You can find anyone’s score for any song with a row times a column, switch their song by changing one number, and read the whole roof’s choices off one matrix product.

What to remember

Here’s what to take with you. An n by m matrix has n rows and m columns, and an entry’s address is row first, then column. You can multiply A times B only when A’s number of columns matches B’s number of rows, and the answer has A’s number of rows and B’s number of columns.

Each entry of the product is a dot product, row i of the first matrix with column j of the second, and it lands in row i, column j. And order matters, because B times A might not exist, might be a different size, or might just have different numbers. Next time, we’ll meet a matrix that changes nothing when you multiply by it, and find out how to undo a multiplication.

Unit 4: Functions Involving Parameters, Vectors, and Matrices

  1. 4.1Parametric Functions
  2. 4.2Parametric Functions Modeling Planar Motion
  3. 4.3Parametric Functions and Rates of Change
  4. 4.4Parametrically Defined Circles and Lines
  5. 4.5Implicitly Defined Functions
  6. 4.6Conic Sections
  7. 4.7Parametrization of Implicitly Defined Functions
  8. 4.8Vectors
  9. 4.9Vector-Valued Functions
  10. 4.10Matrices
  11. 4.11The Inverse and Determinant of a Matrix
  12. 4.12Linear Transformations and Matrices
  13. 4.13Matrices as Functions
  14. 4.14Matrices Modeling Contexts