Matrices

A spreadsheet, a seating chart, the pixels of a photo, a table of who-owes-whom: all of them are rectangles of numbers. Math has a name for a rectangle of numbers, and by the end of this course it will be doing a lot more than sitting there. A matrix will turn out to be a machine that moves vectors around. But first we need to learn to read one, add two of them, flip one over, and feed it a vector.

The practice is mixed into the lesson: each question sits right after the idea it needs, and the Mixed Practice at the bottom takes that hint away. Flip the switch on a question to type your answer instead: a matrix row by row with semicolons between the rows, like 2, -1; 1, 0, and a vector on one line, like 3, -1, 2.

What a Matrix Is

Every number in a rectangle has an address: which row it's in, and which column. That address is the whole idea, so the definition is mostly about how to name things.

An $m \times n$ matrix $A$ is a rectangular array of real numbers with $m$ rows and $n$ columns: $$A = \begin{pmatrix} A_{11} & A_{12} & \cdots & A_{1n} \\ A_{21} & A_{22} & \cdots & A_{2n} \\ \vdots & \vdots & & \vdots \\ A_{m1} & A_{m2} & \cdots & A_{mn} \end{pmatrix}.$$ The number $A_{ij}$ in row $i$ and column $j$ is the $(i, j)$ entry of $A$, and $m \times n$ is the size of $A$.

A matrix $A$ is a rectangle of real numbers. On these pages it has at most $3$ rows and at most $3$ columns. A $3 \times 3$ matrix is written $$A = \begin{pmatrix} A_{11} & A_{12} & A_{13} \\ A_{21} & A_{22} & A_{23} \\ A_{31} & A_{32} & A_{33} \end{pmatrix}.$$ The number $A_{ij}$ in row $i$ and column $j$ is the $(i, j)$ entry of $A$. A matrix with $m$ rows and $n$ columns has size $m \times n$.

Say "$m$ by $n$," and always rows first. Row $i$ runs across, $(A_{i1} \ \ A_{i2} \ \cdots \ A_{in})$, and column $j$ runs down. Here's one to read.

Let $A = \begin{pmatrix} 3 & 0 & -2 \\ 1 & 5 & 4 \end{pmatrix}$. Find its size, $A_{13}$, $A_{21}$, its second row, and its third column.


Two rows and three columns, so $A$ is $2 \times 3$. $A_{13}$ is row $1$, column $3$: that's $-2$. $A_{21}$ is row $2$, column $1$: that's $1$. The second row is $(1 \ \ 5 \ \ 4)$, and the third column is $\begin{pmatrix} -2 \\ 4 \end{pmatrix}$.

Watch the addresses get read: row first, then column, and the crossing is the entry.

Row, then column. Every time. My brain keeps reading $A_{23}$ like the point $(2, 3)$, $x$ first, which would be the column first. Matrices did not ask my brain.

So which comes first is the one thing you can't get backward. Go hunting for addresses; the missions get pickier as you go.

Row $i$, Column $j$

Notice that $A_{23}$ and $A_{32}$ are different entries, unless you get lucky. That trap comes back all over this page.

When an entry's address needs two digits, put a comma in: $A_{1,12}$ is row $1$, column $12$, not row $11$, column $2$. (Other books write the entries with a lowercase letter, a sub ij, or as [A] sub ij, and some draw matrices with square brackets instead of round ones. Same matrix.)

Read an address like a theater ticket: Row C, Seat 4 means find the row first, then walk along it to the seat. $A_{23}$ is row $2$, then the third entry along it. (Other books write the entries with a lowercase letter, a sub ij, or as [A] sub ij, and some draw matrices with square brackets instead of round ones. Same matrix.)

An address can also be a recipe. If you know a formula for $A_{ij}$ in terms of $i$ and $j$, you know the whole matrix: plug in each address.

Write out the $3 \times 2$ matrix with $A_{ij} = i - 2j$.


Three rows, two columns. Row $1$: $A_{11} = 1 - 2 = -1$ and $A_{12} = 1 - 4 = -3$. Row $2$: $A_{21} = 0$ and $A_{22} = -2$. Row $3$: $A_{31} = 1$ and $A_{32} = -1$. So $$A = \begin{pmatrix} -1 & -3 \\ 0 & -2 \\ 1 & -1 \end{pmatrix}.$$

The rule visits every address, one at a time:

Your turn. Keep $i$ on the rows and $j$ on the columns, and check the size before you pick.

Loading practice engine...

One more word before we do anything with matrices: when are two of them the same?

Two matrices $A$ and $B$ are equal if they have the same size and $A_{ij} = B_{ij}$ for every $i$ and $j$.

Same size, same numbers in the same spots. So $\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \neq \begin{pmatrix} 1 & 3 \\ 2 & 4 \end{pmatrix}$, even though they hold the same four numbers, and a $2 \times 3$ matrix never equals a $3 \times 2$ one. An equation between matrices is really a stack of little equations, one per entry.

Find $x$ and $y$ if $\begin{pmatrix} x + 1 & 2 \\ 3 & 2y \end{pmatrix} = \begin{pmatrix} 4 & 2 \\ 3 & -6 \end{pmatrix}$.


Match the entries. The $(1, 1)$ entries give $x + 1 = 4$, so $x = 3$. The $(2, 2)$ entries give $2y = -6$, so $y = -3$. The other two entries already agree.

One matrix equation, four little equations:

Adding and Scaling

Now the arithmetic. If you've added vectors component by component, you already know how this goes: matrices add entry by entry.

For $m \times n$ matrices $A$ and $B$, the sum $A + B$ is the $m \times n$ matrix with $(A + B)_{ij} = A_{ij} + B_{ij}$.

Each entry of $A$ teams up with its partner in $B$, the one at the same address, and nothing else. Multiplying by a number works the same way: it hits every entry.

For a real number $c$ and an $m \times n$ matrix $A$, the scalar multiple $cA$ is the $m \times n$ matrix with $(cA)_{ij} = c\,A_{ij}$.

Watch both happen, one entry at a time:

That's all there is to it. Subtracting is adding a negative, $A - B = A + (-1)B$, so it's entry by entry too. The size rule is where people slip.

You can only add matrices of the same size. A $2 \times 3$ plus a $3 \times 2$ isn't "a $3 \times 3$" or anything else: it's undefined, because some entries would have no partner. And scale before you add: in $3A - 2B$, every entry of $B$ gets multiplied by $2$, not just the first row.

Here's a combination worked all the way out.

Let $A = \begin{pmatrix} 1 & -2 & 0 \\ 3 & 4 & -1 \end{pmatrix}$ and $B = \begin{pmatrix} 2 & 1 & 5 \\ -3 & 0 & 2 \end{pmatrix}$. Find (a) $A + B$   (b) $3A - 2B$.


(a) Add partners: $A + B = \begin{pmatrix} 3 & -1 & 5 \\ 0 & 4 & 1 \end{pmatrix}$.

(b) Scale first, then subtract entry by entry: $$3A - 2B = \begin{pmatrix} 3 & -6 & 0 \\ 9 & 12 & -3 \end{pmatrix} - \begin{pmatrix} 4 & 2 & 10 \\ -6 & 0 & 4 \end{pmatrix} = \begin{pmatrix} -1 & -8 & -10 \\ 15 & 12 & -7 \end{pmatrix}.$$

Here's the same example as a picture. Each column of a $2 \times 3$ matrix is an arrow in the plane, so $A$ is three orange arrows and $B$ is three blue ones. Adding and scaling matrices is adding and scaling those arrows, one column at a time:

Since everything happens one entry at a time, matrix arithmetic inherits every rule that plain numbers follow. Here they are, with the zero matrix $0_{m \times n}$ (every entry $0$) playing the role of $0$, and $-A = (-1)A$ the role of a negative.

For $m \times n$ matrices $A$, $B$, $C$ and real numbers $c$, $d$:

  1. $A + B = B + A$
  2. $(A + B) + C = A + (B + C)$
  3. $A + 0_{m \times n} = A$
  4. $A + (-A) = 0_{m \times n}$
  5. $1A = A$
  6. $(cd)A = c(dA)$
  7. $c(A + B) = cA + cB$
  8. $(c + d)A = cA + dA$
Show proof

Each side of each rule is an $m \times n$ matrix, so by the definition of equality it's enough to check one entry at a time, and each entry is a statement about real numbers. For example, rule 7: the $(i, j)$ entry of $c(A + B)$ is $c(A_{ij} + B_{ij})$, and the $(i, j)$ entry of $cA + cB$ is $cA_{ij} + cB_{ij}$, which are equal by the distributive law for numbers. Rule 1 is $A_{ij} + B_{ij} = B_{ij} + A_{ij}$; rule 4 is $A_{ij} + (-1)A_{ij} = 0$; rule 8 is $(c + d)A_{ij} = cA_{ij} + dA_{ij}$; and the others go the same way. $\blacksquare$

Why it's true (picture)

This is a visual argument, not a formal proof. Everything happens one column at a time, and each column is an arrow, so every rule here is a rule about arrows you already met on Vectors. Here are two of them, column by column:

(1) Walk along a column of $A$ and then the matching column of $B$, or the other way around: you end at the same corner of a parallelogram, so $A + B = B + A$. (7) Doubling the picture keeps the parallelogram's shape, so doubling the sum is the same as summing the doubles: $2(A + B) = 2A + 2B$, and the same goes for any $c$. The other six rules are arrow rules the same way (rule 3: adding the zero arrow goes nowhere), and the picture shows only these two. The full proof is in the n version.

Those eight rules are worth a second look, because they're the same eight rules vectors in $\mathbb{R}^n$ follow.

Those eight rules are worth a second look, because they're the same eight rules arrows in the plane and in space follow.

On Vector Spaces, these eight rules become the axioms of a vector space. Since matrices follow all of them, the set $M_{m \times n}(\mathbb{R})$ of all $m \times n$ matrices is a vector space too: a matrix is a vector that happens to be shaped like a rectangle.

On Vectors, arrows added tip to tail and stretched, and they followed these same rules. No surprise: a matrix's columns are arrows, and everything happens column by column.

Your turn. Scale each matrix first, then combine.

Loading practice engine...

The Transpose

Adding and scaling never move an entry. This next operation does nothing but move entries: it trades every entry's row number for its column number.

The transpose of an $m \times n$ matrix $A$ is the $n \times m$ matrix $A^t$ with $(A^t)_{ij} = A_{ji}$.

The rows of $A$ become the columns of $A^t$. Picture it as a flip across the diagonal that starts at the top-left corner:

$A^t$ looks exactly like "$A$ to the power $t$." Nobody raised $A$ to anything. $A$ got flipped. I will be reading it as a power anyway.

The entries on the diagonal ($i = j$) never move, and everything else swaps sides. Two quick transposes by hand:

Find the transpose of (a) $A = \begin{pmatrix} 1 & 4 & -2 \\ 0 & 3 & 5 \end{pmatrix}$   (b) the column $x = \begin{pmatrix} 2 \\ -1 \\ 6 \end{pmatrix}$.


(a) Row $1$, $(1 \ \ 4 \ \ {-2})$, becomes column $1$, and row $2$ becomes column $2$: $$A^t = \begin{pmatrix} 1 & 0 \\ 4 & 3 \\ -2 & 5 \end{pmatrix}.$$ A $2 \times 3$ matrix, flipped into a $3 \times 2$ one. Check one entry: $(A^t)_{31} = A_{13} = -2$.

(b) A column vector is a $3 \times 1$ matrix, so its transpose is the $1 \times 3$ row $x^t = (2 \ \ {-1} \ \ 6)$. Transposing is how we'll switch between columns and rows.

Each row lifts out, turns a quarter turn, and stands up as a column:

Now predict before you see the flip. Each round, one entry of $A$ glows; tap where it lands in $A^t$.

Where Does It Land?

The transpose plays nicely with adding and scaling: you can flip before you combine or after, and you get the same matrix. Flip twice and you're back where you started.

For $m \times n$ matrices $A$ and $B$ and a real number $c$:

  1. $(A + B)^t = A^t + B^t$
  2. $(cA)^t = cA^t$
  3. $(A^t)^t = A$
Show proof

All three sides are $n \times m$ (or, in rule 3, $m \times n$) matrices, so compare entries. (1) $((A + B)^t)_{ij} = (A + B)_{ji} = A_{ji} + B_{ji} = (A^t)_{ij} + (B^t)_{ij}$. (2) $((cA)^t)_{ij} = (cA)_{ji} = cA_{ji} = c(A^t)_{ij}$. (3) $((A^t)^t)_{ij} = (A^t)_{ji} = A_{ij}$. $\blacksquare$

Why it's true (picture)

This is a visual argument, not a formal proof. Each rule is about where an entry ends up, so follow one entry (in orange) along both sides of the rule:

(1) Add then flip, or flip then add: either way the orange entries meet at address $(2, 1)$ and add to the same number. Every other entry goes through the same two routes, so the two matrices match entry by entry. (2) works the same way with scaling in place of adding. (3) A flip sends address $(1, 2)$ to $(2, 1)$, and a second flip sends it back, so $(A^t)^t = A$. The full proof is in the n version.

Those rules let you move a transpose around an expression without computing anything first.

Let $A = \begin{pmatrix} 1 & 2 \\ 0 & -1 \end{pmatrix}$ and $B = \begin{pmatrix} 3 & -1 \\ 4 & 2 \end{pmatrix}$. Find $(2A - B^t)^t$.


By the rules, $(2A - B^t)^t = 2A^t - (B^t)^t = 2A^t - B$, so flip only $A$: $$2A^t - B = \begin{pmatrix} 2 & 0 \\ 4 & -2 \end{pmatrix} - \begin{pmatrix} 3 & -1 \\ 4 & 2 \end{pmatrix} = \begin{pmatrix} -1 & 1 \\ 0 & -4 \end{pmatrix}.$$ Check the long way: $2A - B^t = \begin{pmatrix} 2 & 4 \\ 0 & -2 \end{pmatrix} - \begin{pmatrix} 3 & 4 \\ -1 & 2 \end{pmatrix} = \begin{pmatrix} -1 & 0 \\ 1 & -4 \end{pmatrix}$, and its transpose is the same answer.

The two routes, side by side:

Flipping first saved us a step, but only because we flipped the right matrices.

Keep track of which matrices wear the $t$. In $2A^t + B$, only $A$ gets flipped, and transposing $B$ "to be safe" gives a different matrix. (Other books write the transpose with a capital T, or with a prime, A′. Same flip.)

Your turn. Some ask for a single flip, some put the flip in the middle of an expression.

Loading practice engine...

Square Matrices

That diagonal the transpose flipped across only runs corner to corner when the matrix is a square. Square matrices are the ones we'll care about most, so they get their own vocabulary.

A matrix with the same number of rows and columns is square.

An $n \times n$ matrix has a main diagonal running from the top-left to the bottom-right, and the entries on it, $A_{11}, A_{22}, \ldots, A_{nn}$, are its diagonal entries.

A square matrix has a main diagonal running from the top-left corner to the bottom-right corner, and the entries on it are its diagonal entries: $A_{11}$, $A_{22}$, $A_{33}$ for a $3 \times 3$ matrix, and just $A_{11}$, $A_{22}$ for a $2 \times 2$.

Which of $B = \begin{pmatrix} 7 & -1 & 0 \\ 2 & 4 & 9 \\ -3 & 5 & 6 \end{pmatrix}$ and $C = \begin{pmatrix} 7 & -1 & 0 \\ 2 & 4 & 9 \end{pmatrix}$ is square? List the diagonal entries of the square one.


$B$ is $3 \times 3$, so it's square, and its diagonal entries are $B_{11} = 7$, $B_{22} = 4$, $B_{33} = 6$. $C$ is $2 \times 3$, so it isn't square. $C_{11} = 7$ and $C_{22} = 4$ still exist, but the line through them stops at the bottom edge instead of reaching a corner.

Shine a laser down each diagonal:

Some square matrices keep all their nonzero numbers on that diagonal.

A square matrix $D$ is diagonal if $D_{ij} = 0$ whenever $i \neq j$.

Others only keep the zeros on one side of it.

A square matrix $A$ is upper triangular if $A_{ij} = 0$ whenever $i > j$.

So everything below the diagonal is $0$. Flip it around: $A$ is lower triangular if $A_{ij} = 0$ whenever $i < j$, so everything above the diagonal is $0$. The diagonal itself can hold anything, zeros included.

Which of these are diagonal, upper triangular, or lower triangular?

$D = \begin{pmatrix} 4 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 0 & 2 \end{pmatrix}$$U = \begin{pmatrix} 1 & 3 & -2 \\ 0 & 5 & 7 \\ 0 & 0 & 6 \end{pmatrix}$$L = \begin{pmatrix} 2 & 0 & 0 \\ 1 & 3 & 0 \\ -4 & 0 & 1 \end{pmatrix}$$N = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$

$D$ is diagonal, and that makes it upper and lower triangular too: its zeros are on both sides. $U$ is upper triangular (zeros below the diagonal). $L$ is lower triangular (zeros above; the $0$ in row $3$, column $2$ is allowed but not required). $N$ is none of them.

Check each side of the diagonal, one side at a time:

The most famous diagonal matrix is the identity $I_n$, with $1$s down the diagonal and $0$s everywhere else. It gets its name on Composition & Matrix Multiplication, where it turns out to be the "multiply by $1$" of matrices.

A square matrix also has a number attached to its diagonal: add the diagonal up.

The trace of an $n \times n$ matrix $A$ is the sum of its diagonal entries: $\operatorname{tr}(A) = A_{11} + A_{22} + \cdots + A_{nn}$.

The trace of a square matrix $A$ is the sum of its diagonal entries: $\operatorname{tr}(A) = A_{11} + A_{22}$ for a $2 \times 2$ matrix, and $\operatorname{tr}(A) = A_{11} + A_{22} + A_{33}$ for a $3 \times 3$.

For the matrices above, $\operatorname{tr}(D) = 4 - 1 + 2 = 5$ and $\operatorname{tr}(U) = 1 + 5 + 6 = 12$, and $N$'s trace is $1 + 4 = 5$. Only square matrices have one: a $2 \times 3$ matrix has no corner-to-corner diagonal to add. The trace gets along with everything so far.

For $n \times n$ matrices $A$ and $B$ and a real number $c$: $\operatorname{tr}(A + B) = \operatorname{tr}(A) + \operatorname{tr}(B)$, $\ \operatorname{tr}(cA) = c \operatorname{tr}(A)$, and $\operatorname{tr}(A^t) = \operatorname{tr}(A)$.

Show proof

The diagonal entries of $A + B$ are $A_{ii} + B_{ii}$, so $\operatorname{tr}(A + B) = \sum_{i=1}^{n} (A_{ii} + B_{ii}) = \sum_{i=1}^{n} A_{ii} + \sum_{i=1}^{n} B_{ii}$. The diagonal entries of $cA$ are $cA_{ii}$, and $\sum_{i=1}^{n} cA_{ii} = c\sum_{i=1}^{n} A_{ii}$. And $(A^t)_{ii} = A_{ii}$: the diagonal doesn't move in the flip, so the sum doesn't change. $\blacksquare$

Why it's true (picture)

This is a visual argument, not a formal proof. The trace only looks at the diagonal, so watch what each rule does to the diagonal:

Adding matrices adds their diagonal entries in pairs, so the traces add. Scaling multiplies every diagonal entry by $c$, so the trace gets multiplied by $c$. And the flip moves everything except the diagonal, so the trace stays put. The numbers are one example, but the reasons hold for any square matrices of the same size. The full proof is in the n version.

That last rule is the flip from before, seen from the diagonal's point of view: it stays put. Next up, the matrices that don't change at all when you flip them.

Symmetric Matrices

Most matrices look different after a transpose. The ones that don't are special enough to get a name.

A matrix $A$ is symmetric if $A^t = A$.

Two things are packed into that equation. $A^t$ has to be the same size as $A$, so a symmetric matrix is square. And entry by entry, $A_{ij} = A_{ji}$: every entry matches its mirror image across the diagonal. Fold one along the diagonal and watch:

There's a twisted cousin, where flipping turns every entry into its negative.

A matrix $A$ is skew-symmetric if $A^t = -A$.

Now $A_{ij} = -A_{ji}$ for every $i$ and $j$. Look at what that says on the diagonal, where $i = j$: $A_{ii} = -A_{ii}$. Try it before reading on.

Make It Symmetric

The only number equal to its own negative is $0$, so every diagonal entry of a skew-symmetric matrix is $0$. A symmetric matrix is the opposite: its diagonal can hold anything, because each diagonal entry is its own mirror image.

A rule $A_{ij} = f(i, j)$ makes all of this easy to test. If swapping $i$ and $j$ leaves $f$ alone, the matrix is symmetric (as long as it's square); if swapping them flips the sign, it's skew-symmetric. Pick a rule and a size, and see which shapes light up:

Matrix from a Rule

Here's a surprise: every square matrix is built out of one symmetric piece and one skew-symmetric piece, and there's only one way to split it.

Every square matrix $A$ is the sum of a symmetric matrix and a skew-symmetric matrix in exactly one way: $$A = \tfrac{1}{2}(A + A^t) + \tfrac{1}{2}(A - A^t).$$

Show proof

The two pieces add to $\tfrac{1}{2}A + \tfrac{1}{2}A^t + \tfrac{1}{2}A - \tfrac{1}{2}A^t = A$. By the transpose rules, $\left(\tfrac{1}{2}(A + A^t)\right)^t = \tfrac{1}{2}(A^t + A)$, so the first piece is symmetric, and $\left(\tfrac{1}{2}(A - A^t)\right)^t = \tfrac{1}{2}(A^t - A) = -\tfrac{1}{2}(A - A^t)$, so the second is skew-symmetric.

For "exactly one way," suppose $A = S + K$ with $S$ symmetric and $K$ skew-symmetric. Transposing gives $A^t = S^t + K^t = S - K$. Adding the two equations, $A + A^t = 2S$; subtracting them, $A - A^t = 2K$. So $S$ and $K$ have to be the two pieces above. $\blacksquare$

Why it's true (picture)

This is a visual argument, not a formal proof. A symmetric matrix $S$ puts the same number $s$ in both spots of every mirror pair, and a skew-symmetric matrix $K$ puts opposite numbers $k$ and $-k$ there. So split $A$ one mirror pair $(p, q)$ at a time, on a number line:

We need $p = s + k$ and $q = s - k$. That forces $s$ to be the midpoint of $p$ and $q$ and $k$ to be half the gap between them, and a pair of numbers has only one midpoint, so each pair splits in exactly one way. A diagonal entry is its own mirror image, so it goes entirely into $S$ and $K$ gets $0$ there. Every pair splitting one way means the whole matrix splits one way, and the midpoint is the average, $\tfrac{1}{2}(A + A^t)$. The full proof is in the n version.

The proof is also the recipe: average $A$ with its flip for the symmetric part, and take half the difference for the rest.

Split $A = \begin{pmatrix} 1 & 4 \\ 2 & 3 \end{pmatrix}$ into a symmetric matrix plus a skew-symmetric matrix.


$A^t = \begin{pmatrix} 1 & 2 \\ 4 & 3 \end{pmatrix}$. The symmetric part is $\tfrac{1}{2}(A + A^t) = \tfrac{1}{2}\begin{pmatrix} 2 & 6 \\ 6 & 6 \end{pmatrix} = \begin{pmatrix} 1 & 3 \\ 3 & 3 \end{pmatrix}$, and the skew-symmetric part is $\tfrac{1}{2}(A - A^t) = \tfrac{1}{2}\begin{pmatrix} 0 & 2 \\ -2 & 0 \end{pmatrix} = \begin{pmatrix} 0 & 1 \\ -1 & 0 \end{pmatrix}$. Check: $\begin{pmatrix} 1 & 3 \\ 3 & 3 \end{pmatrix} + \begin{pmatrix} 0 & 1 \\ -1 & 0 \end{pmatrix} = A$.

The split, then the check:

Your turn, running the definitions backward: the unknown has to make every mirror pair match (or, for skew-symmetric, cancel).

Loading practice engine...

A Matrix Times a Vector

Here's where a matrix stops being a table and starts being a machine: you feed it a vector, and it hands you back a new one. The recipe is built out of dot products.

On Dot & Cross Products, the dot product multiplied matching entries and added: $(1, 0, 2, -1) \cdot (3, 5, 1, 2) = 3 + 0 + 2 - 2 = 3$. Here each row of the matrix gets dotted with the vector.

On Dot & Cross Products, the dot product multiplied matching entries and added: $(1, 2, 2) \cdot (3, 0, 3) = 3 + 0 + 6 = 9$. Its sign said whether two arrows lean together or apart. Here each row of the matrix gets dotted with the vector.

A vector in $\mathbb{R}^n$ is written as a column here, an $n \times 1$ matrix, so it can stand next to a matrix.

A vector in $\mathbb{R}^2$ or $\mathbb{R}^3$ is written as a column here, a $2 \times 1$ or $3 \times 1$ matrix, so it can stand next to a matrix.

For an $m \times n$ matrix $A$ and a vector $x = \begin{pmatrix} x_1 \\ \vdots \\ x_n \end{pmatrix}$ in $\mathbb{R}^n$, the product $Ax$ is the vector in $\mathbb{R}^m$ whose $i$-th entry is $$(Ax)_i = A_{i1}x_1 + A_{i2}x_2 + \cdots + A_{in}x_n.$$

If a matrix $A$ has as many columns as the vector $x$ has entries, the product $Ax$ is the vector with one entry for each row of $A$: $$\text{entry } i \text{ of } Ax = (\text{row } i \text{ of } A) \cdot x.$$ For a $3 \times 3$ matrix and $x = (x_1, x_2, x_3)$, that's $(Ax)_i = A_{i1}x_1 + A_{i2}x_2 + A_{i3}x_3$.

Row $i$ of $A$ times $x$ gives entry $i$ of $Ax$. So $A$ needs exactly as many columns as $x$ has entries, and $Ax$ has one entry per row of $A$.

What happens if I multiply a $2 \times 3$ matrix by a vector with $2$ entries? Nothing. It just sits there. Rude.

Here's one by hand, row by row.

Compute $Ax$ for $A = \begin{pmatrix} 1 & -2 & 3 \\ 4 & 0 & -1 \end{pmatrix}$ and $x = \begin{pmatrix} 2 \\ 1 \\ -1 \end{pmatrix}$.


$A$ is $2 \times 3$ and $x$ has $3$ entries, so it works, and $Ax$ has $2$ entries. Row $1$ times $x$: $(1)(2) + (-2)(1) + (3)(-1) = -3$. Row $2$ times $x$: $(4)(2) + (0)(1) + (-1)(-1) = 9$. So $Ax = \begin{pmatrix} -3 \\ 9 \end{pmatrix}$.

Each row of $A$ is an arrow in space, and so is $x$. An entry of $Ax$ is a dot product, so its sign says which way $x$ leans against that row:

Now look at that same product sideways. Collect everything $x_1$ multiplies, then everything $x_2$ multiplies, and so on: $$Ax = 2\begin{pmatrix} 1 \\ 4 \end{pmatrix} + 1\begin{pmatrix} -2 \\ 0 \end{pmatrix} + (-1)\begin{pmatrix} 3 \\ -1 \end{pmatrix} = \begin{pmatrix} -3 \\ 9 \end{pmatrix}.$$ Those three vectors are the columns of $A$. That's no coincidence.

If $a_1, a_2, \ldots, a_n$ are the columns of the $m \times n$ matrix $A$, then for every $x$ in $\mathbb{R}^n$, $$Ax = x_1a_1 + x_2a_2 + \cdots + x_na_n.$$

Show proof

Column $j$ is $a_j = \begin{pmatrix} A_{1j} \\ \vdots \\ A_{mj} \end{pmatrix}$, so the $i$-th entry of $x_1a_1 + \cdots + x_na_n$ is $x_1A_{i1} + x_2A_{i2} + \cdots + x_nA_{in}$. That's exactly $(Ax)_i$. Both sides are vectors in $\mathbb{R}^m$ with the same entries, so they're equal. $\blacksquare$

If $a_1, a_2, a_3$ are the columns of $A$, then for every $x = (x_1, x_2, x_3)$, $$Ax = x_1a_1 + x_2a_2 + x_3a_3.$$ (When $A$ has two columns, drop the third term.)

Why it's true (picture)

This is a visual argument, not a formal proof. Lay the columns tip to tail, each stretched by its entry of $x$, and see where the chain ends. Then compute $Ax$ row by row and compare:

Same three numbers. And it isn't luck: the first coordinate of the chain's end collects the first coordinate of each piece, $x_1A_{11} + x_2A_{12} + x_3A_{13}$, and that's exactly row $1$ of $A$ dotted with $x$. The same goes for every row, whatever $A$ and $x$ are. The full proof is in the n version.

So $Ax$ is a linear combination of the columns of $A$, and the entries of $x$ are the amounts. In the plane, that's a chain of stretched columns, tip to tail:

Two pictures, one product: rows times $x$ for the entries, or columns mixed by $x$ for the whole thing. Change $x$ and check that they always agree:

Two Ways to Get $Ax$

That last mission asks for a nonzero $x$ with $Ax = 0$, and $x = (1, -3, -2)$ is one: the columns cancel each other out. Hold on to that idea; whole pages are coming about it.

In the plane, cancelling means the chain of columns makes a loop and comes home:

One more pair of rules says that multiplying by $A$ respects adding and scaling vectors.

For an $m \times n$ matrix $A$, vectors $x$ and $y$ in $\mathbb{R}^n$, and a real number $c$: $$A(x + y) = Ax + Ay \quad \text{and} \quad A(cx) = c(Ax).$$

Show proof

Compare entries. $(A(x + y))_i = \sum_{k=1}^{n} A_{ik}(x_k + y_k) = \sum_{k=1}^{n} A_{ik}x_k + \sum_{k=1}^{n} A_{ik}y_k = (Ax)_i + (Ay)_i$, and $(A(cx))_i = \sum_{k=1}^{n} A_{ik}(cx_k) = c\sum_{k=1}^{n} A_{ik}x_k = c(Ax)_i$. $\blacksquare$

Why it's true (picture)

This is a visual argument, not a formal proof. $Ax$ is a chain of columns, so follow the chains:

Arrows add in any order, so the chain for $Ax$ followed by the chain for $Ay$ can be rearranged into the chain for $x + y$ (here the extra pieces $a_2$ and $-a_2$ cancel; in general each column's two pieces just merge into one, $x_ja_j + y_ja_j = (x_j + y_j)a_j$). Scaling $x$ by $c$ scales every piece of the chain, so the whole chain is a similar copy, $c$ times the size, and so is where it ends. The full proof is in the n version.

A function that respects adding and scaling like that has a name, a linear transformation, and it's what the rest of this course is about: every matrix is one, and as it turns out, every linear transformation between $\mathbb{R}^n$'s is a matrix.

A function that respects adding and scaling like that has a name, a linear transformation, and it's what the rest of this course is about. Every matrix is one: it moves arrows in the plane or in space, and the coming pages watch it move the whole plane at once.

This product also tidies up the last two pages. Back on Systems, every system of linear equations was secretly one equation, $Ax = b$, with $A$ its coefficient matrix and $x$ unknown, and on Solution Sets its homogeneous partner is $Ax = 0$.

Check sizes before you multiply: an $m \times n$ matrix eats vectors with $n$ entries and spits out vectors with $m$ entries. The middle numbers have to match, and the answer's size is the outside number. And use rows, not columns, when you go entry by entry: using the columns as rows computes $A^tx$ instead.

Your turn. Some ask for $Ax$, some for the $x$ that mixes the columns a certain way, and the hardest hide one entry of $x$.

Loading practice engine...

That's the whole toolkit: reading entries, adding and scaling, flipping, the square shapes, symmetry, and feeding a matrix a vector. Before you go, some practice without the hints.

Mixed Practice

Every question so far came right after its idea, which is a hint a quiz never gives you. Down here the hint is gone. First, true or false: a claim about matrices from anywhere on this page, and you decide whether it holds.

Loading practice engine...

Next, a mixed set: every question type on this page, shuffled. Figuring out which idea a question needs is half the work.

Loading practice engine...

Made it this far? Time for something with a little heat. These chain the whole page together: an equation where the unknown matrix shows up twice, once flipped. Hint: go entry by entry, and remember which entries the transpose leaves alone.

🌶️ SPICY BONUS 🌶️

Loading practice engine...