1. Home
  2. Explore
  3. Mathematics
  4. Matrix Dimensions and Entries

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Matrix Dimensions and Entries

Matrix–Vector Multiplication

Matrices and their dimensions

A matrix is a two-dimensional array of numbers. Its size is described by its number of rows and columns:

  • An m×nm \times nm×n matrix has mmm rows and nnn columns.

  • It therefore contains mnmnmn entries in total.

  • The entry in row iii and column jjj is often written aija_{ij}aij​.

A general m×nm \times nm×n matrix AAA has the form

A=[a11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮am1am2⋯amn].A = \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{bmatrix}.A=​a11​a21​⋮am1​​a12​a22​⋮am2​​⋯⋯⋱⋯​a1n​a2n​⋮amn​​​.

Rows run horizontally and columns run vertically. For instance, a23a_{23}a23​ denotes the entry in row 222, column 333.


When matrix–vector multiplication is defined

A matrix can multiply a vector only when the vector has as many components as the matrix has columns. If AAA is m×nm \times nm×n, then the vector must have nnn components and be written as an n×1n \times 1n×1 column vector:

x=[x1x2⋮xn].\mathbf{x} = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix}.x=​x1​x2​⋮xn​​​.

The product AxA\mathbf{x}Ax is then an m×1m \times 1m×1 vector:

(m×n)(n×1)=m×1.(m \times n)(n \times 1) = m \times 1.(m×n)(n×1)=m×1.

The inner dimensions—the number of columns of AAA and the number of entries in x\mathbf{x}x—must match. The output has one entry for each row of AAA, so it has mmm entries.

Matrix–vector multiplication is defined when the input vector’s length equals the matrix’s number of columns. The result’s length equals the matrix’s number of rows.


The row-by-row definition

Each entry of the output is formed by taking the dot product of a row of AAA with x\mathbf{x}x. Thus,

Ax=[a11x1+a12x2+⋯+a1nxna21x1+a22x2+⋯+a2nxn⋮am1x1+am2x2+⋯+amnxn].A\mathbf{x} = \begin{bmatrix} a_{11}x_1 + a_{12}x_2 + \cdots + a_{1n}x_n \\ a_{21}x_1 + a_{22}x_2 + \cdots + a_{2n}x_n \\ \vdots \\ a_{m1}x_1 + a_{m2}x_2 + \cdots + a_{mn}x_n \end{bmatrix}.Ax=​a11​x1​+a12​x2​+⋯+a1n​xn​a21​x1​+a22​x2​+⋯+a2n​xn​⋮am1​x1​+am2​x2​+⋯+amn​xn​​​.

For each row:

  1. Multiply the first entry of the row by x1x_1x1​, the second by x2x_2x2​, and continue matching entries.

  2. Add the products.

  3. Use the resulting sum as the corresponding entry of the output vector.

This operation is a convention that defines matrix–vector multiplication. Its usefulness comes partly from how naturally it connects to dot products and linear combinations.


Example: calculating the product by rows

Consider the matrix and vector

A=[−303217−19],x=[2−34−1].A = \begin{bmatrix} -3 & 0 & 3 & 2 \\ 1 & 7 & -1 & 9 \end{bmatrix}, \qquad \mathbf{x} = \begin{bmatrix} 2 \\ -3 \\ 4 \\ -1 \end{bmatrix}.A=[−31​07​3−1​29​],x=​2−34−1​​.

The matrix has 444 columns, and the vector has 444 components, so the product is defined. Since AAA has 222 rows, the result has 222 entries.

The first output entry is the dot product of the first row with x\mathbf{x}x:

(−3)(2)+(0)(−3)+(3)(4)+(2)(−1)=−6+0+12−2=4.(-3)(2) + (0)(-3) + (3)(4) + (2)(-1) = -6 + 0 + 12 - 2 = 4.(−3)(2)+(0)(−3)+(3)(4)+(2)(−1)=−6+0+12−2=4.

The second output entry is the dot product of the second row with x\mathbf{x}x:

(1)(2)+(7)(−3)+(−1)(4)+(9)(−1)=2−21−4−9=−32.(1)(2) + (7)(-3) + (-1)(4) + (9)(-1) = 2 - 21 - 4 - 9 = -32.(1)(2)+(7)(−3)+(−1)(4)+(9)(−1)=2−21−4−9=−32.

Therefore,

Ax=[4−32].A\mathbf{x} = \begin{bmatrix} 4 \\ -32 \end{bmatrix}.Ax=[4−32​].

Interpretation using row vectors and transposes

A row of a matrix can be treated as a row vector. If the rows of AAA are written as the transposes of column vectors a1,a2,…,am\mathbf{a}_1,\mathbf{a}_2,\ldots,\mathbf{a}_ma1​,a2​,…,am​, then

A=[a1Ta2T⋮amT].A = \begin{bmatrix} \mathbf{a}_1^{\mathsf T} \\ \mathbf{a}_2^{\mathsf T} \\ \vdots \\ \mathbf{a}_m^{\mathsf T} \end{bmatrix}.A=​a1T​a2T​⋮amT​​​.

The transpose switches rows and columns: a column vector becomes a row vector, and a row vector becomes a column vector. The output can then be written as

Ax=[a1Txa2Tx⋮amTx].A\mathbf{x} = \begin{bmatrix} \mathbf{a}_1^{\mathsf T}\mathbf{x} \\ \mathbf{a}_2^{\mathsf T}\mathbf{x} \\ \vdots \\ \mathbf{a}_m^{\mathsf T}\mathbf{x} \end{bmatrix}.Ax=​a1T​xa2T​x⋮amT​x​​.

Each expression aiTx\mathbf{a}_i^{\mathsf T}\mathbf{x}aiT​x is a dot product. This notation makes clear that matrix–vector multiplication can be viewed as taking one dot product per row.


Interpretation as a linear combination of columns

There is another useful way to understand AxA\mathbf{x}Ax. Suppose the columns of an m×nm \times nm×n matrix AAA are the vectors v1,v2,…,vn\mathbf{v}_1,\mathbf{v}_2,\ldots,\mathbf{v}_nv1​,v2​,…,vn​. Then the matrix can be written as

A=[v1v2⋯vn].A = \begin{bmatrix} \mathbf{v}_1 & \mathbf{v}_2 & \cdots & \mathbf{v}_n \end{bmatrix}.A=[v1​​v2​​⋯​vn​​].

Multiplying by x\mathbf{x}x produces

Ax=x1v1+x2v2+⋯+xnvn.A\mathbf{x} = x_1\mathbf{v}_1 + x_2\mathbf{v}_2 + \cdots + x_n\mathbf{v}_n.Ax=x1​v1​+x2​v2​+⋯+xn​vn​.

Thus, matrix–vector multiplication is a linear combination of the columns of the matrix. The entries of x\mathbf{x}x act as the weights on those columns.

Example using columns

Consider

A=[31032470−1234],x=[x1x2x3x4].A = \begin{bmatrix} 3 & 1 & 0 & 3 \\ 2 & 4 & 7 & 0 \\ -1 & 2 & 3 & 4 \end{bmatrix}, \qquad \mathbf{x} = \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ x_4 \end{bmatrix}.A=​32−1​142​073​304​​,x=​x1​x2​x3​x4​​​.

The columns of AAA are

v1=[32−1],v2=[142],v3=[073],v4=[304].\mathbf{v}_1 = \begin{bmatrix} 3 \\ 2 \\ -1 \end{bmatrix}, \quad \mathbf{v}_2 = \begin{bmatrix} 1 \\ 4 \\ 2 \end{bmatrix}, \quad \mathbf{v}_3 = \begin{bmatrix} 0 \\ 7 \\ 3 \end{bmatrix}, \quad \mathbf{v}_4 = \begin{bmatrix} 3 \\ 0 \\ 4 \end{bmatrix}.v1​=​32−1​​,v2​=​142​​,v3​=​073​​,v4​=​304​​.

Therefore,

Ax=x1[32−1]+x2[142]+x3[073]+x4[304].A\mathbf{x} = x_1 \begin{bmatrix} 3 \\ 2 \\ -1 \end{bmatrix} + x_2 \begin{bmatrix} 1 \\ 4 \\ 2 \end{bmatrix} + x_3 \begin{bmatrix} 0 \\ 7 \\ 3 \end{bmatrix} + x_4 \begin{bmatrix} 3 \\ 0 \\ 4 \end{bmatrix}.Ax=x1​​32−1​​+x2​​142​​+x3​​073​​+x4​​304​​.

The coefficients x1,x2,x3,x4x_1,x_2,x_3,x_4x1​,x2​,x3​,x4​ determine how much each column contributes to the resulting vector.


Two complementary ways to read the product

For an m×nm \times nm×n matrix AAA and an nnn-component vector x\mathbf{x}x:

  • By rows: Each output entry is the dot product of one row of AAA with x\mathbf{x}x. This produces mmm entries.

  • By columns: The result is a weighted sum of the nnn columns of AAA, with the components of x\mathbf{x}x serving as weights.

Both interpretations describe the same operation. The row perspective is useful for calculating output entries, while the column perspective helps explain how the input vector combines the matrix’s columns.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent