math.wiki
Linear algebra › Matrices › Rows, columns and dimensions
Open on the map
Precalculus

Rows, columns and dimensions

You have a rectangle of numbers with no labels on it. How do you say how big it is, and point to exactly one number inside it?

Where you are 12 in Matrices

Why this exists

A system of equations such as

\begin{aligned} 2x + 3y &= 7 \\ x - 4y &= 5 \end{aligned}

carries its information in six numbers. The letters x and y, the plus signs and the equals signs only say where each number sits. Strip them away, keep the positions, and what is left is a rectangle of numbers. The same rectangle turns up whenever data comes in two directions at once: items down the side and days across the top, or cities down the side and cities across the top.

A rectangle of numbers is only useful if you can talk about it precisely. You need to say how big it is, and you need to point at one number in it without drawing an arrow. This lesson sets up exactly that language: a name for the shape of the whole block, and an address for every position inside it. Every later piece of matrix arithmetic, from adding matrices to multiplying them, is written in these words.

Definition

A matrix is a rectangular array of numbers, arranged in rows and columns. A row is a line of numbers running across, left to right. A column is a line of numbers running down, top to bottom. Each number in the array is an entry (some books say element) of the matrix. The plural is matrices. A matrix is enclosed in square brackets, or in some books round ones, and is named with a capital letter.

A = \begin{bmatrix} 5 & -2 & 0 & 8 \\ 1 & 4 & 7 & -3 \\ 6 & 9 & -1 & 2 \end{bmatrix}

Dimension. A matrix with m rows and n columns is called an m \times n matrix, read “m by n”. The pair m \times n is its dimension, or its size. The number of rows always comes first. The matrix A above has 3 rows and 4 columns, so it is a 3 \times 4 matrix. It is not a 4 \times 3 matrix: that would be a different shape, three entries wide and four tall.

Entries by address. The rows are numbered 1, 2, 3, \dots from the top, and the columns 1, 2, 3, \dots from the left. The entry of A in row i and column j is written a_{ij}: the lower-case form of the matrix’s letter, with two subscripts. The first subscript is the row and the second is the column, the same order as in m \times n.

5 −2 0 8 1 4 7 −3 6 9 −1 2 1 2 3 1 2 3 4 row column
a_{23} = 7
Figure 1Row 2 and column 3 cross at exactly one entry, so a_{23} = 7.

In Figure 1, a_{23} is the entry where row 2 meets column 3, which is 7. The entry a_{32} is in row 3 and column 2, which is 9. Same two digits, different position, different number. The name a_{23} is read “a two three”, not “a twenty-three”, since the 2 and the 3 are separate numbers. When a subscript has two digits, a comma keeps them apart: a_{12,3} is row 12, column 3. Many books write the comma every time, as a_{2,3}.

For an m \times n matrix, i can be any of 1, 2, \dots, m and j any of 1, 2, \dots, n, and each such pair names exactly one entry. So a matrix can be described completely by a rule for its entries, written A = [a_{ij}].

A few shapes and patterns come up so often that they have names.

Square matrix. A matrix with the same number of rows as columns, n \times n.

Row vector and column vector. A matrix with exactly one row, 1 \times n, is a row vector (or row matrix). A matrix with exactly one column, m \times 1, is a column vector (or column matrix). Their entries are often given a single subscript, such as v_1, v_2, v_3, since the other index never changes.

Main diagonal. The entries whose row number equals their column number, a_{11}, a_{22}, a_{33}, \dots, form the main diagonal. In a square matrix it runs from the top left corner to the bottom right corner. In a matrix that is not square it still starts at the top left, but it stops at the bottom row or the right column before reaching the opposite corner.

Zero matrix. A matrix in which every entry is 0. There is one of each size, written O_{m \times n}, or just O when the size is clear. Some books write 0.

Identity matrix. For each n, the identity matrix I_n is the n \times n matrix with 1 in every position of the main diagonal and 0 in every other position:

I_2 = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \qquad I_3 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}

As a rule for its entries, the entry of I_n in row i and column j is 1 when i = j and 0 when i \ne j. An identity matrix is always square. Its name comes from what it does in a product, which is the subject of the identity matrix.

Equal matrices. Two matrices A and B are equal, written A = B, when both of these hold:

  • they have the same dimension, and
  • every pair of entries in the same position agree: a_{ij} = b_{ij} for every row i and every column j.

Both conditions are needed. Two matrices that hold the same numbers in a different arrangement are not equal, and a matrix is never equal to one of a different size.

Intuition

Think of a matrix as a block of seats in a theater. The dimension tells you how the block is laid out: so many rows, so many seats in each row. A ticket reads “row 2, seat 3”, and it names one seat, not a number of seats. The subscripts on a_{23} work the same way. They are an address, and the entry is whoever is sitting there.

Row first is a convention, not a fact about rectangles. It could have been the other way round, but everyone agreed on this order, so a_{23} means the same seat to every reader. The same convention runs through the dimension: 3 \times 4 means 3 rows, just as a_{34} means row 3.

A matrix is not just a bag of numbers; it is the numbers together with their places. Two matrices are equal only when you could lay one on top of the other and every seat holds the same number.

Results

Counting entries. An m \times n matrix has exactly mn entries.

One equation for every position. If A and B are both m \times n, the single statement A = B says the same thing as the mn separate statements

a_{ij} = b_{ij}

one for every row number i from 1 to m and every column number j from 1 to n. If A and B have different dimensions, A = B is false, whatever their entries.

The diagonal of a square matrix. An {n \times n} matrix has n entries on its main diagonal and n^2 - n entries off it. In particular I_n has n ones and n^2 - n zeros.

Why it is true

Counting. There are m rows, and each row has one entry in each of the n columns, so there are n + n + \dots + n (m times) = mn entries.

Equality. When the dimensions agree, the definition of equality asks for a_{ij} = b_{ij} at every position, and there are mn positions, so that is mn equations. When the dimensions differ, the first condition of the definition already fails.

The diagonal. The diagonal positions are the ones with i = j, which are (1, 1), (2, 2), \dots, (n, n): exactly n of them. The matrix has n^2 positions in all, so n^2 - n of them are off the diagonal. The identity matrix has a 1 at each diagonal position and a 0 at each of the others.

Worked examples

Example 1

Reading the dimension and the entries

B = \begin{bmatrix} 3 & -1 & 0 & 5 \\ 2 & 8 & -4 & 1 \\ 7 & 6 & 9 & -2 \end{bmatrix}

Find the dimension of B and the number of entries it has. Then find b_{23}, b_{32} and b_{14}, and say whether b_{41} exists.

Solution

Count the lines of numbers running across: there are 3 rows. Count the lines running down: there are 4 columns. Rows come first, so B is a 3 \times 4 matrix, and it has 3 \cdot 4 = 12 entries.

For each entry, the first subscript picks the row and the second picks the column.

  • b_{23} is in row 2, column 3. Row 2 is 2, 8, -4, 1, and its third number is b_{23} = -4.
  • b_{32} is in row 3, column 2. Row 3 is 7, 6, 9, -2, and its second number is b_{32} = 6.
  • b_{14} is in row 1, column 4, the top right corner: b_{14} = 5.

The name b_{41} asks for row 4, but B has only 3 rows. There is no such entry, so b_{41} does not exist.

Example 2

Building a matrix from a rule

A = [a_{ij}] is the 2 \times 3 matrix with a_{ij} = 3i - 2j. Write out A, and compare a_{12} with a_{21}.

Solution

A has 2 rows and 3 columns, so i runs over 1, 2 and j over 1, 2, 3. Each entry comes from putting its own row and column numbers into the rule. Row 1 has i = 1:

\begin{aligned} a_{11} &= 3 - 2 = 1 \\ a_{12} &= 3 - 4 = -1 \\ a_{13} &= 3 - 6 = -3 \end{aligned}

Row 2 has i = 2:

\begin{aligned} a_{21} &= 6 - 2 = 4 \\ a_{22} &= 6 - 4 = 2 \\ a_{23} &= 6 - 6 = 0 \end{aligned}

Place each value at its address:

A = \begin{bmatrix} 1 & -1 & -3 \\ 4 & 2 & 0 \end{bmatrix}

The two entries asked about are a_{12} = -1 and a_{21} = 4. They are different, because the rule treats the row number and the column number differently. Swapping the subscripts moves you to a different position, and in general to a different number.

Example 3

Naming the shapes

For each matrix, give its dimension and say which of these names apply: square, row vector, column vector, zero matrix, identity matrix.

P = \begin{bmatrix} 4 & 0 & -1 \end{bmatrix} \qquad Q = \begin{bmatrix} 2 \\ 5 \end{bmatrix}
R = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \qquad S = \begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}
T = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix} \qquad U = \begin{bmatrix} 7 \end{bmatrix}
Solution

P has one row and three columns, so it is 1 \times 3, a row vector. It is not square.

Q has two rows and one column, so it is 2 \times 1, a column vector.

R is 2 \times 2, so it is square. Its diagonal entries are 1 and its other entries are 0, so R = I_2.

S is 2 \times 3 and every entry is 0, so S is the zero matrix O_{2 \times 3}. It is not square.

T is 2 \times 3. Its diagonal entries t_{11} and t_{22} are 1 and every other entry is 0, which is the pattern of an identity matrix, but T is not square. An identity matrix is square by definition, so T is not an identity matrix. It is neither I_2, which is 2 \times 2, nor I_3, which is 3 \times 3. None of the five names applies to T.

U is 1 \times 1. It has one row, so it is a row vector; one column, so it is a column vector; and as many rows as columns, so it is square. All three names apply at once.

Example 4

Solving for unknowns in equal matrices

Find x and y so that

\begin{bmatrix} x + 3 & 4 \\ -1 & 2y \end{bmatrix} = \begin{bmatrix} 10 & 4 \\ -1 & y + 6 \end{bmatrix}
Solution

Both matrices are 2 \times 2, so the first condition for equality holds. The second condition asks for the entries in each position to agree, which gives one equation per position, laid out here in the same places as the entries:

\begin{aligned} x + 3 &= 10 & 4 &= 4 \\ -1 &= -1 & 2y &= y + 6 \end{aligned}

The equations in the top right and bottom left hold already. The top left gives x = 7 and the bottom right gives y = 6.

Check. With x = 7 and y = 6 the left matrix has entries 7 + 3 = 10, 4, -1 and 2 \cdot 6 = 12, and the right has 10, 4, -1 and 6 + 6 = 12. They agree in every position.

Example 5

When one position is not enough

Find every value of x for which

\begin{bmatrix} x^2 & 5 \\ 2x + 1 & 0 \end{bmatrix} = \begin{bmatrix} 9 & 5 \\ -5 & 0 \end{bmatrix}
Solution

Both matrices are 2 \times 2. Row 1, column 1 gives

x^2 = 9, \quad\text{so}\quad x = 3 \ \text{ or } \ x = -3

That is not yet the answer, because equality needs every position to agree at once. Row 2, column 1 gives

\begin{aligned} 2x + 1 &= -5 \\ 2x &= -6 \\ x &= -3 \end{aligned}

Only x = -3 satisfies both. The value x = 3 fails the second equation, since 2(3) + 1 = 7 \ne -5. The two remaining positions hold (5 = 5 and 0 = 0) for every x. So the only value is x = -3.

Example 6

When equality is impossible

Explain why neither of these equations can ever be true, the second whatever the value of x.

\begin{bmatrix} 1 & 2 & 3 \end{bmatrix} = \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}
\begin{bmatrix} x + 1 & 2x \end{bmatrix} = \begin{bmatrix} 4 & 8 \end{bmatrix}
Solution

In the first equation the left side is 1 \times 3 and the right side is 3 \times 1. The dimensions differ, so the matrices are not equal, even though they list the same three numbers in the same order.

In the second, both sides are 1 \times 2, so the sizes match. The first position asks for x + 1 = 4, so x = 3. The second asks for 2x = 8, so x = 4. No number is both 3 and 4, so no x makes every position agree, and the matrices are never equal.

Example 7

A table of data as a matrix

A café records how many cups of tea, coffee and juice it sells on Saturday and on Sunday. Tea: 40 on Saturday and 35 on Sunday. Coffee: 62 and 71. Juice: 18 and 24. Write this as a matrix S with one row for each drink, in that order, and one column for each day. Give its dimension, say what s_{21} means, and name the entry for juice on Sunday. What would the dimension be if a third day were added?

Solution

One row per drink gives 3 rows, and one column per day gives 2 columns:

S = \begin{bmatrix} 40 & 35 \\ 62 & 71 \\ 18 & 24 \end{bmatrix}

S is 3 \times 2.

The first subscript is the row, which here is the drink, and the second is the column, the day. So s_{21} is drink 2 on day 1: 62 cups of coffee sold on Saturday. Juice is row 3 and Sunday is column 2, so the juice sold on Sunday is s_{32} = 24.

A third day adds a column and leaves the number of rows alone, so the matrix would become 3 \times 3.

The matrix only carries the numbers. What each row and column stands for lives outside it, in the sentence that says how it was set up. Had the days been made the rows, the same data would have filled a 2 \times 3 matrix, and every address would mean something else.

Boundaries

A matrix is a full rectangle. Every row has the same number of entries and no position is empty. Rows of different lengths do not make a matrix.

Counting starts at 1, from the top left. Row 1 is the top row and column 1 the left column. Many programming languages number from 0 instead; the mathematical notation in this lesson does not.

Dimension is a shape, not a count. A 2 \times 3 and a 3 \times 2 matrix both have 6 entries, but they are different shapes, and no 2 \times 3 matrix equals a 3 \times 2 one. The word “dimension” here means the size of an array. It is not the dimension of a space, an idea met later in linear algebra.

An identity matrix must be square. A matrix that is not square, with 1s down its main diagonal and 0s elsewhere, is not an identity matrix, and it is not equal to I_2 or I_3 or any other.

Equality is all or nothing. Matrices that agree in every position but one are not equal, and there is no such thing as “nearly equal” in this definition.

Brackets, not bars. A matrix is written in square or round brackets. Straight vertical bars around a square array, as in \begin{vmatrix} 1 & 2 \\ 3 & 4 \end{vmatrix}, mean something else: a single number worked out from a square matrix, called its determinant.

Where this goes next

With addresses in hand, matrix arithmetic can be stated in one line. Two matrices of the same dimension are added by adding the entries at matching addresses, and a matrix is scaled by multiplying every entry by the same number. Both rules depend on being able to say “the entry in row i, column j” and mean one number.

Dimension matters even more for products. Whether two matrices can be multiplied at all is decided by their dimensions alone, as when the product exists explains, and the identity matrix earns its name there.

And the system at the top of this lesson comes back: written as an augmented matrix, a system can be solved by working on its numbers alone, without ever writing the letters.

Exercises

Reading a matrix

Use this matrix for Exercises 1 to 5.

C = \begin{bmatrix} 2 & -5 & 0 \\ 7 & 1 & 4 \\ -3 & 6 & 8 \\ 9 & 0 & -1 \end{bmatrix}
  1. What is the dimension of C, and how many entries does it have?
  2. Find c_{21} and c_{12}.
  3. Find c_{43}. Does c_{34} exist?
  4. The number 6 appears once in C. Name its position in double-subscript notation.
  5. Write the third row of C as a row vector, and the second column of C as a column vector.

Building a matrix from a rule

  1. Write the 2 \times 2 matrix A with a_{ij} = i + j.
  2. Write the 3 \times 2 matrix B with b_{ij} = 2i - j.
  3. Write the 3 \times 3 matrix D with d_{ij} = i - j. What do you notice about its main diagonal?
  4. Write the 2 \times 3 matrix E with e_{ij} = i \cdot j.
  5. Write out I_4.
  6. Write the 3 \times 3 matrix F with f_{ij} = 1 when i \le j and f_{ij} = 0 when i > j.

Naming shapes

For Exercises 12 to 14, give the dimension of each matrix and say which of these names apply: square, row vector, column vector, zero matrix, identity matrix.

  1. \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} and \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}
  2. \begin{bmatrix} -6 \end{bmatrix}
  3. \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}
  4. How many entries of I_5 are 0? How many entries of I_n are 0?
  5. A matrix has 18 entries. List every dimension it could have.

Equal matrices

Find every value of the unknowns that makes the two matrices equal, or explain why there is none.

  1. \begin{bmatrix} 2x & 5 \\ 3 & y - 1 \end{bmatrix} = \begin{bmatrix} 8 & 5 \\ 3 & 4 \end{bmatrix}
  2. \begin{bmatrix} a + b & 3 \\ a - b & 0 \end{bmatrix} = \begin{bmatrix} 7 & 3 \\ 1 & 0 \end{bmatrix}
  3. \begin{bmatrix} x^2 & 1 \\ 0 & x + 4 \end{bmatrix} = \begin{bmatrix} 16 & 1 \\ 0 & 0 \end{bmatrix}
  4. \begin{bmatrix} x & 3x \end{bmatrix} = \begin{bmatrix} 5 & 12 \end{bmatrix}

Reasoning

  1. In a 3 \times 3 matrix, for which positions do a_{ij} and a_{ji} name the same entry? Explain.
  2. Can a row vector ever equal a column vector? Explain exactly when.
  3. A 2 \times 3 matrix has 1 in each main-diagonal position and 0 everywhere else. Is it equal to I_2, to I_3, or to neither? Explain.
  4. Prove that if A = B and B = C, then A = C.
  5. Is there one zero matrix or many? Say exactly when two zero matrices are equal.
Answers
  1. 4 \times 3, with 12 entries. There are 4 rows and 3 columns, rows first, and 4 \cdot 3 = 12.
  2. c_{21} = 7 and c_{12} = -5. Row 2, column 1 holds 7; row 1, column 2 holds -5.
  3. c_{43} = -1, the bottom right corner. c_{34} does not exist: it asks for column 4, and C has only 3 columns.
  4. c_{32}. The 6 is in row 3 and column 2, and the row is named first.
  5. Third row \begin{bmatrix} -3 & 6 & 8 \end{bmatrix}; second column \begin{bmatrix} -5 \\ 1 \\ 6 \\ 0 \end{bmatrix}. A row is read across and a column down.
  6. \begin{bmatrix} 2 & 3 \\ 3 & 4 \end{bmatrix}. For example a_{12} = 1 + 2 = 3 and a_{22} = 2 + 2 = 4.
  7. \begin{bmatrix} 1 & 0 \\ 3 & 2 \\ 5 & 4 \end{bmatrix}. Row i is 2i - 1 then 2i - 2: row 3 is 6 - 1 = 5 and 6 - 2 = 4.
  8. \begin{bmatrix} 0 & -1 & -2 \\ 1 & 0 & -1 \\ 2 & 1 & 0 \end{bmatrix}. Every main-diagonal entry is 0, because on the diagonal i = j and so d_{ii} = i - i = 0.
  9. \begin{bmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \end{bmatrix}. Row 1 is 1 \cdot 1, 1 \cdot 2, 1 \cdot 3 and row 2 is 2 \cdot 1, 2 \cdot 2, 2 \cdot 3.
  10. \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}. It is 4 \times 4, with 1 where i = j and 0 elsewhere.
  11. \begin{bmatrix} 1 & 1 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 1 \end{bmatrix}. The positions with i \le j are the diagonal and everything to its right.
  12. The first is 2 \times 2: square and a zero matrix. The second is 3 \times 1: a column vector and a zero matrix. Neither is an identity matrix, since I_n has 1s on its diagonal.
  13. 1 \times 1: square, a row vector and a column vector all at once. It is not a zero matrix (its entry is -6) and not I_1 (whose entry is 1).
  14. 2 \times 2 and square, but not an identity matrix: its diagonal entries are 0, not 1. It is not a zero matrix either.
  15. 20 for I_5, and n^2 - n for I_n. I_5 has 25 entries and 5 of them are on the diagonal, so {25 - 5 = 20} are 0.
  16. 1 \times 18, 2 \times 9, 3 \times 6, 6 \times 3, 9 \times 2 and 18 \times 1. The dimension m \times n needs mn = 18, so m is a divisor of 18 and n = 18 / m.
  17. x = 4 and y = 5. Both are 2 \times 2; position (1, 1) gives 2x = 8 and position (2, 2) gives y - 1 = 4. The other two positions already agree.
  18. a = 4 and b = 3. The first column gives {a + b = 7} and {a - b = 1}. Adding them, 2a = 8; then b = 7 - 4 = 3.
  19. x = -4. Position (1, 1) gives x^2 = 16, so {x = 4} or {x = -4}, and position (2, 2) gives x + 4 = 0, so x = -4. Only -4 satisfies both.
  20. No value. The first position needs x = 5 and the second needs 3x = 12, so x = 4. No number is both.
  21. Exactly the main-diagonal positions, (1, 1), (2, 2) and (3, 3). a_{ij} is in row i, column j, and a_{ji} is in row j, column i. These are the same position only when i = j.
  22. Only when both are 1 \times 1 with the same entry. A row vector is 1 \times n and a column vector is m \times 1; equal matrices have the same dimension, so 1 = m and n = 1.
  23. Neither. I_2 is 2 \times 2 and I_3 is 3 \times 3, while this matrix is 2 \times 3, and matrices of different dimensions are never equal.
  24. A = B gives A and B the same dimension, and B = C gives B and C the same, so A and C have the same dimension. At each position, a_{ij} = b_{ij} and b_{ij} = c_{ij} are equalities of numbers, so a_{ij} = c_{ij}. Both conditions hold, so A = C.
  25. Many: one of each size m \times n. Two zero matrices of the same size agree entry by entry, since every entry is 0, and two of different sizes are never equal. So they are equal exactly when they have the same dimension.
kg1128 · updated 2026-09-30 · CC-BY-SA-4.0