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 rectangular arrangement of numbers. An m×nm \times nm×n matrix has mmm rows and nnn columns:

  • mmm gives the number of rows.

  • nnn gives the number of columns.

  • The matrix contains mnmnmn entries in total.

A general m×nm \times nm×n matrix AAA can be written as

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​​​.

The subscript in aija_{ij}aij​ identifies an entry’s location: iii is its row number, and jjj is its column number. For example, a23a_{23}a23​ is the entry in row 222, column 333.


When a matrix can multiply a vector

For a matrix–vector product AxAxAx to be defined, the vector xxx must have the same number of components as AAA has columns. Thus, if AAA is m×nm \times nm×n, then xxx must have nnn components and can be written as

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

The product AxAxAx is then a vector with mmm components—one for each row of AAA:

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

The matching inner dimensions, both nnn, are required for the multiplication to be defined. The resulting vector’s number of entries matches the matrix’s number of rows.


Definition by rows: each output is a dot product

To calculate AxAxAx, take each row of AAA, multiply its entries by the corresponding entries of xxx, and add the products. The first output component is

a11x1+a12x2+⋯+a1nxn.a_{11}x_1 + a_{12}x_2 + \cdots + a_{1n}x_n.a11​x1​+a12​x2​+⋯+a1n​xn​.

The next output component is calculated from the second row, and the process continues through all mmm rows. In general,

Ax=[a11x1+a12x2+⋯+a1nxna21x1+a22x2+⋯+a2nxn⋮am1x1+am2x2+⋯+amnxn].Ax = \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​​​.

Each output component is a dot product: it is the sum of the products of corresponding entries in a matrix row and the vector xxx.

Writing rows using transposes

A vector is often written as a column. The transpose changes rows into columns and columns into rows. If the entries of row iii are collected into a column vector aia_iai​, then the row itself is aiTa_i^{\mathsf T}aiT​. Consequently, the iiith component of the product can be expressed as

bi=aiTx.b_i = a_i^{\mathsf T}x.bi​=aiT​x.

This notation describes matrix–vector multiplication as taking the dot product of each row of AAA with xxx.


Worked example

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 x = \begin{bmatrix} 2 \\ -3 \\ 4 \\ -1 \end{bmatrix}.A=[−31​07​3−1​29​],x=​2−34−1​​.

The matrix has four columns, so the vector must have four components; this product is therefore defined. Since the matrix has two rows, the result will have two components.

The first component comes from the first row:

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

The second component comes from the second row:

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

Therefore,

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

Definition by columns: a linear combination

Matrix–vector multiplication can also be understood using the columns of the matrix. Suppose an m×nm \times nm×n matrix is written as

A=[∣∣∣v1v2⋯vn∣∣∣],A = \begin{bmatrix} \vert & \vert & & \vert \\ v_1 & v_2 & \cdots & v_n \\ \vert & \vert & & \vert \end{bmatrix},A=​∣v1​∣​∣v2​∣​⋯​∣vn​∣​​,

where each vjv_jvj​ is a column vector with mmm entries. For

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

the product is

Ax=x1v1+x2v2+⋯+xnvn.Ax = x_1v_1 + x_2v_2 + \cdots + x_nv_n.Ax=x1​v1​+x2​v2​+⋯+xn​vn​.

Thus, the entries of xxx serve as weights for the columns of AAA. The product is a linear combination of those columns: each column is multiplied by its corresponding component of xxx, and the resulting vectors are added.

Example of the column interpretation

Consider

A=[31032470−1234],x=[x1x2x3x4].A = \begin{bmatrix} 3 & 1 & 0 & 3 \\ 2 & 4 & 7 & 0 \\ -1 & 2 & 3 & 4 \end{bmatrix}, \qquad 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 four columns are

v1=[32−1],v2=[142],v3=[073],v4=[304].v_1 = \begin{bmatrix} 3 \\ 2 \\ -1 \end{bmatrix}, \qquad v_2 = \begin{bmatrix} 1 \\ 4 \\ 2 \end{bmatrix}, \qquad v_3 = \begin{bmatrix} 0 \\ 7 \\ 3 \end{bmatrix}, \qquad v_4 = \begin{bmatrix} 3 \\ 0 \\ 4 \end{bmatrix}.v1​=​32−1​​,v2​=​142​​,v3​=​073​​,v4​=​304​​.

The product can be written as

Ax=x1[32−1]+x2[142]+x3[073]+x4[304].Ax = 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​​.

Each component of xxx determines how much its corresponding column contributes to the resulting vector.


Two complementary ways to understand AxAxAx

  • Row viewpoint: Each component of AxAxAx is the dot product of one row of AAA with xxx.

  • Column viewpoint: The entire product is a linear combination of the columns of AAA, weighted by the components of xxx.

Both viewpoints describe the same matrix–vector multiplication. The row viewpoint emphasizes how each output component is calculated; the column viewpoint emphasizes how the input vector selects and 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