ELIAS EBNER

  • Home
  • Blog
  • Courses
  • About

Linear Algebra

  1. Vectors
    1. Scalars
    2. Vectors vs Sets
    3. Addition and Subtraction
    4. Scalar Multiplication
    5. Zero Vectors
    6. Linear Combinations
    7. Real Dot Product
    8. Length of a Vector
    9. Orthogonal Vectors
    10. Parallel Vectors
    11. Angle Between Vectors
    12. Unit Vectors
  2. Matrices
    1. Notation
    2. Indexing
    3. Submatrices
    4. Matrix-by-Vector Product
    5. Addition and Subtraction
    6. Scalar Multiplication
    7. Transpose
    8. Symmetries
    9. Matrix Multiplication
    10. Identity Matrix
    11. Non-Negative Integer Powers
    12. Reverse Order Law of Transposition
  3. Linear Systems
    1. Inverse Matrices
    2. Singular Matrices
    3. Linear Dependence
    4. Solutions
  4. Planes
    1. Vector Cross Product
  5. Gaussian Elimination
Linear Algebra ›Matrices ›Matrix-by-Vector Product

Multiplying a Vector by a Matrix

An important operation in the context of matrices is the product between a matrix and a vector. Take some matrix

A=[a11a12a13a21a22a23a31a32a33a41a42a43].A = \begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \\ a_{41} & a_{42} & a_{43} \\ \end{bmatrix}.A=​a11​a21​a31​a41​​a12​a22​a32​a42​​a13​a23​a33​a43​​​.

This matrix can be subdivided into its columns. For this, the idea of seeing a matrix as a vector of vectors is very useful. I introduced this idea in the introductory lesson about matrices.

Let us divide AAA into columns:

A=[a⃗1a⃗2a⃗3].A = \begin{bmatrix} \vec{a}_1 & \vec{a}_2 & \vec{a}_3 \end{bmatrix}.A=[a1​​a2​​a3​​].

Here, a⃗1\vec{a}_1a1​ is the first column of AAA, a⃗2\vec{a}_2a2​ is the second, and a⃗3\vec{a}_3a3​ is the third and final column. Therefore, we can say that

a⃗1=[a11a21a31a41],a⃗2=[a12a22a32a42],a⃗3=[a13a23a33a43].\vec{a}_1 = \begin{bmatrix} a_{11} \\ a_{21} \\ a_{31} \\ a_{41} \end{bmatrix}, \vec{a}_2 = \begin{bmatrix} a_{12} \\ a_{22} \\ a_{32} \\ a_{42} \end{bmatrix}, \vec{a}_3 = \begin{bmatrix} a_{13} \\ a_{23} \\ a_{33} \\ a_{43} \end{bmatrix}.a1​=​a11​a21​a31​a41​​​,a2​=​a12​a22​a32​a42​​​,a3​=​a13​a23​a33​a43​​​.

Keep this in mind.

We now have another vector x⃗\vec{x}x whose number of components is the same as the number of columns in our matrix (in our example, 333):

x⃗=[x1x2x3].\vec{x} = \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix}.x=​x1​x2​x3​​​.

We can now perform a multiplication between the matrix AAA and the vector x⃗\vec{x}x. The product is the linear combination of the columns of AAA, where the coefficients come from the corresponding element of x⃗\vec{x}x. In other words

Ax⃗=x1a⃗1+x2a⃗2+x3a⃗3=x1[a11a21a31a41]+x2[a12a22a32a42]+x3[a13a23a33a43]=[x1a11x1a21x1a31x1a41]+[x2a12x2a22x2a32x2a42]+[x3a13x3a23x3a33x3a43]=[x1a11+x2a12+x3a13x1a21+x2a22+x3a23x1a31+x2a32+x3a33x1a41+x2a42+x3a43]=b⃗.\begin{align*} A \vec{x} &= x_1 \vec{a}_1 + x_2 \vec{a}_2 + x_3 \vec{a}_3 \\ &= x_1 \begin{bmatrix} a_{11} \\ a_{21} \\ a_{31} \\ a_{41} \end{bmatrix} + x_2 \begin{bmatrix} a_{12} \\ a_{22} \\ a_{32} \\ a_{42} \end{bmatrix} + x_3 \begin{bmatrix} a_{13} \\ a_{23} \\ a_{33} \\ a_{43} \end{bmatrix} \\ &= \begin{bmatrix} x_1 a_{11} \\ x_1 a_{21} \\ x_1 a_{31} \\ x_1 a_{41} \end{bmatrix} + \begin{bmatrix} x_2 a_{12} \\ x_2 a_{22} \\ x_2 a_{32} \\ x_2 a_{42} \end{bmatrix} + \begin{bmatrix} x_3 a_{13} \\ x_3 a_{23} \\ x_3 a_{33} \\ x_3 a_{43} \end{bmatrix} \\ &= \begin{bmatrix} x_1 a_{11} + x_2 a_{12} + x_3 a_{13} \\ x_1 a_{21} + x_2 a_{22} + x_3 a_{23} \\ x_1 a_{31} + x_2 a_{32} + x_3 a_{33} \\ x_1 a_{41} + x_2 a_{42} + x_3 a_{43} \\ \end{bmatrix} = \vec{b}. \end{align*}Ax​=x1​a1​+x2​a2​+x3​a3​=x1​​a11​a21​a31​a41​​​+x2​​a12​a22​a32​a42​​​+x3​​a13​a23​a33​a43​​​=​x1​a11​x1​a21​x1​a31​x1​a41​​​+​x2​a12​x2​a22​x2​a32​x2​a42​​​+​x3​a13​x3​a23​x3​a33​x3​a43​​​=​x1​a11​+x2​a12​+x3​a13​x1​a21​+x2​a22​+x3​a23​x1​a31​+x2​a32​+x3​a33​x1​a41​+x2​a42​+x3​a43​​​=b.​

As you can see, the product of a matrix and a vector is another vector. I chose the letters AAA, x⃗\vec{x}x, and b⃗\vec{b}b very deliberately, since these letters are conventionally used in this context (this operation will be very important for future lessons).

Dimensions of the Operands and the Result

As you can infer from the example above, the matrix used was a 4×34 \times 34×3 matrix. The vector we used in the multiplication had 333 components.

This is very important: the product of a matrix and a vector is only defined for matrix-vector pairs where the number of components in the vector is the same as the number of columns in the matrix. This, for instance, means that you cannot multiply a vector with 555 components with a matrix of size 5×35 \times 35×3, because that matrix would only have 333 columns.

More formally, if AAA is an m×nm \times nm×n matrix, for the operation Ax⃗A\vec{x}Ax to be defined, x⃗\vec{x}x must have nnn components.

The resulting vector b⃗\vec{b}b has the same number of components as the number of rows in the matrix involved in the operation. For an m×nm \times nm×n matrix, the resulting vector b⃗\vec{b}b will have mmm components.

Example

Allow me to demonstrate through the following numerical example. Take the matrix

A=[102−1312104−21],A = \begin{bmatrix} 1 & 0 & 2 \\ -1 & 3 & 1 \\ 2 & 1 & 0 \\ 4 & -2 & 1 \end{bmatrix},A=​1−124​031−2​2101​​,

and the vector

x⃗=[2−13].\vec{x} = \begin{bmatrix} 2 \\ -1 \\ 3 \end{bmatrix}.x=​2−13​​.

We compute Ax⃗A\vec{x}Ax:

Ax⃗=[102−1312104−21][2−13]=2[1−124]+(−1)[031−2]+3[2101]=[2−248]+[0−3−12]+[6303]=[8−2313].\begin{align*} A\vec{x} &= \begin{bmatrix} 1 & 0 & 2 \\ -1 & 3 & 1 \\ 2 & 1 & 0 \\ 4 & -2 & 1 \end{bmatrix} \begin{bmatrix} 2 \\ -1 \\ 3 \end{bmatrix} \\ &= 2 \begin{bmatrix} 1 \\ -1 \\ 2 \\ 4 \end{bmatrix} + (-1) \begin{bmatrix} 0 \\ 3 \\ 1 \\ -2 \end{bmatrix} + 3 \begin{bmatrix} 2 \\ 1 \\ 0 \\ 1 \end{bmatrix} \\ &= \begin{bmatrix} 2 \\ -2 \\ 4 \\ 8 \end{bmatrix} + \begin{bmatrix} 0 \\ -3 \\ -1 \\ 2 \end{bmatrix} + \begin{bmatrix} 6 \\ 3 \\ 0 \\ 3 \end{bmatrix} \\ &= \begin{bmatrix} 8 \\ -2 \\ 3 \\ 13 \end{bmatrix}. \end{align*}Ax​=​1−124​031−2​2101​​​2−13​​=2​1−124​​+(−1)​031−2​​+3​2101​​=​2−248​​+​0−3−12​​+​6303​​=​8−2313​​.​

Thus,

b⃗=[8−2313].\vec{b} = \begin{bmatrix} 8 \\ -2 \\ 3 \\ 13 \end{bmatrix}.b=​8−2313​​.
Previous
Submatrices
Next
Matrix Addition and Subtraction
This website does not collect personal data, does not use cookies, and does not perform any tracking.