Options

[section1] Matrices, dot products and matrix multiplication - tanzer.trail1.post2

Prev: Numbers and vectors


Here is a 2-by-3 matrix:

\[ \begin{bmatrix} 1 & 2 & 3 \\ -10 & 0 & 7 \end{bmatrix} \]

Tagged:

Comments

  • 1.
    edited February 15

    Here is the transpose of that matrix:

    \[ \begin{bmatrix} 1 & -10 \\ 2 & 0 \\ 3 & 7 \end{bmatrix} \]

    Comment Source:Here is the _transpose_ of that matrix: \\[ \begin{bmatrix} 1 & -10 \\\\ 2 & 0 \\\\ 3 & 7 \end{bmatrix} \\]
  • 2.
    edited February 15

    The transpose turned a 2-by-3 matrix into a 3-by-2 matrix.

    The transpose turns rows into columns and columns into rows.

    You can picture it as a reflection of the matrix across a 45-degree axis going from top-left to bottom-right.

    Comment Source:The transpose turned a 2-by-3 matrix into a 3-by-2 matrix. The transpose turns rows into columns and columns into rows. You can picture it as a reflection of the matrix across a 45-degree axis going from top-left to bottom-right.
  • 3.
    edited February 15

    If \(M\) is a matrix, then its transpose is written \(M^T\).

    For example:

    \[ \begin{bmatrix} 1 & 2 & 3 \\ -10 & 0 & 7 \end{bmatrix}^T = \begin{bmatrix} 1 & -10 \\ 2 & 0 \\ 3 & 7 \end{bmatrix} \]

    Comment Source:If \\(M\\) is a matrix, then its transpose is written \\(M^T\\). For example: \\[ \begin{bmatrix} 1 & 2 & 3 \\\\ -10 & 0 & 7 \end{bmatrix}^T = \begin{bmatrix} 1 & -10 \\\\ 2 & 0 \\\\ 3 & 7 \end{bmatrix} \\]
  • 4.
    edited February 15

    Taking the transpose of the transpose gives you back the original matrix:

    \[{(M^T)}^T = M\]

    A row-vector is a matrix with just one row.

    A column-vector is a matrix with just one column.

    Comment Source:Taking the transpose of the transpose gives you back the original matrix: \\[{(M^T)}^T = M\\] A _row-vector_ is a matrix with just one row. A _column-vector_ is a matrix with just one column.
  • 5.
    edited February 15

    The transpose of a row vector is a column vector:

    \[ \begin{bmatrix} 1 & 2 & 3 \end{bmatrix}^T = \begin{bmatrix} 1 \\ 2 \\ 3
    \end{bmatrix} \]

    Comment Source:The transpose of a row vector is a column vector: \\[ \begin{bmatrix} 1 & 2 & 3 \end{bmatrix}^T = \begin{bmatrix} 1 \\\\ 2 \\\\ 3 \end{bmatrix} \\]
  • 6.

    And the transpose of a column vector is a row vector:

    \[ \begin{bmatrix} 1 \\ 2 \\ 3
    \end{bmatrix}^T = \begin{bmatrix} 1 & 2 & 3 \end{bmatrix} \]

    Comment Source:And the transpose of a column vector is a row vector: \\[ \begin{bmatrix} 1 \\\\ 2 \\\\ 3 \end{bmatrix}^T = \begin{bmatrix} 1 & 2 & 3 \end{bmatrix} \\]
  • 7.
    edited February 15

    The dot product is an operation that takes two vectors in and outputs a single number (a scalar).

    Here is how it works:

    \[ \begin{bmatrix} 1 & 2 \end{bmatrix} \cdot \begin{bmatrix} 10 & 20 \end{bmatrix} = 1 \cdot 10 + 2 \cdot 20 = 50 \]

    Comment Source:The _dot product_ is an operation that takes two vectors in and outputs a single number (a scalar). Here is how it works: \\[ \begin{bmatrix} 1 & 2 \end{bmatrix} \cdot \begin{bmatrix} 10 & 20 \end{bmatrix} = 1 \cdot 10 + 2 \cdot 20 = 50 \\]
  • 8.
    edited February 15

    It will prove convenient to express the dot product in a form where its left input is a row vector, and its right input is a column vector.

    So we would write:

    \[ \begin{bmatrix} 1 & 2 \end{bmatrix} \cdot \begin{bmatrix} 10 \\ 20 \end{bmatrix} = 1 \cdot 10 + 2 \cdot 20 =50 \]

    Comment Source:It will prove convenient to express the dot product in a form where its left input is a row vector, and its right input is a column vector. So we would write: \\[ \begin{bmatrix} 1 & 2 \end{bmatrix} \cdot \begin{bmatrix} 10 \\\\ 20 \end{bmatrix} = 1 \cdot 10 + 2 \cdot 20 =50 \\]
  • 9.
    edited February 15

    Matrix multiplication is an operation that takes two matrices for inputs, and outputs a product matrix.

    We may write \(A \times B = C\), where the variables now stand for matrices.

    If \(A\) is a row vector of length n, and \(B\) is column vector of length n, then the matrix multiplication \(A \cdot B\) is precisely defined to the dot product \(A \cdot B\) of \(A\) and \(B\).

    The notation coincides; matrix multiplication is a strict generalization of the dot product, to the case of general matrices.

    Comment Source:_Matrix multiplication_ is an operation that takes two matrices for inputs, and outputs a product matrix. We may write \\(A \times B = C\\), where the variables now stand for matrices. If \\(A\\) is a row vector of length n, and \\(B\\) is column vector of length n, then the matrix multiplication \\(A \cdot B\\) is precisely defined to the dot product \\(A \cdot B\\) of \\(A\\) and \\(B\\). The notation coincides; matrix multiplication is a strict generalization of the dot product, to the case of general matrices.
  • 10.

    Now there is a compatibility condition on the matrix product \(A \cdot B\), which causes this product to be defined only of the shapes of \(A\) and \(B\) are compatible.

    Rather than just telling you the condition, here I'll explain how derive it from your understanding of the dot product.

    Comment Source:Now there is a compatibility condition on the matrix product \\(A \cdot B\\), which causes this product to be defined only of the shapes of \\(A\\) and \\(B\\) are compatible. Rather than just telling you the condition, here I'll explain how derive it from your understanding of the dot product.
  • 11.

    Suppose \(A\) is row vector, and \(B\) is a column vector, and we wish to form their dot product \(A \cdot B\).

    Now clearly this will only work if the number of columns in \(A\) equals the number of rows in \(B\).

    And that is the general compatibility requirement for \(A\) and \(B\), in order for the product of \(A\) and \(B\) to be defined:

    \[ncols(A) = nrows(B)\]

    Comment Source:Suppose \\(A\\) is row vector, and \\(B\\) is a column vector, and we wish to form their dot product \\(A \cdot B\\). Now clearly this will only work if the number of columns in \\(A\\) equals the number of rows in \\(B\\). And _that_ is the general compatibility requirement for \\(A\\) and \\(B\\), in order for the product of \\(A\\) and \\(B\\) to be defined: \\[ncols(A) = nrows(B)\\]
  • 12.
    edited February 15

    Now we'll define matrix multiplication, in general, by bootstrapping from the concept of dot products.

    Comment Source:Now we'll define matrix multiplication, in general, by bootstrapping from the concept of dot products.
  • 13.
    edited February 15

    Say we want to multiply \(A\) and \(B\), and that \(ncols(A) = nrows(B) = k\).

    Suppose that \(A\) has m rows, and \(B) has n columns.

    So \(A\) is m-by-k, and \(B\) is k-by-n.

    The key will be to picture \(A\) as a matrix of row-vectors, and \(B\) as a matrix of column vectors.

    Comment Source:Say we want to multiply \\(A\\) and \\(B\\), and that \\(ncols(A) = nrows(B) = k\\). Suppose that \\(A\\) has m rows, and \\(B) has n columns. So \\(A\\) is m-by-k, and \\(B\\) is k-by-n. The key will be to picture \\(A\\) as a matrix of row-vectors, and \\(B\\) as a matrix of column vectors.
  • 14.
    edited February 15

    The key is to picture \(A\) as a matrix of row-vectors and \(B\) as a matrix of column vectors.

    Here are the rows of A:

    \[ A = \begin{bmatrix} \text{---} & a_1 & \text{---} \\ \text{---} & a_2 & \text{---} \\ & \vdots & \\ \text{---} & a_m & \text{---} \end{bmatrix} \]

    Here are the columns of B:

    \[ B = \begin{bmatrix} \vert & \vert & & \vert \\ b_1 & b_2 & ... & b_n \\ \vert & \vert & & \vert \end{bmatrix} \]

    Comment Source:The key is to picture \\(A\\) as a matrix of row-vectors and \\(B\\) as a matrix of column vectors. Here are the rows of A: \\[ A = \begin{bmatrix} \text{---} & a_1 & \text{---} \\\\ \text{---} & a_2 & \text{---} \\\\ & \vdots & \\\\ \text{---} & a_m & \text{---} \end{bmatrix} \\] Here are the columns of B: \\[ B = \begin{bmatrix} \vert & \vert & & \vert \\\\ b_1 & b_2 & ... & b_n \\\\ \vert & \vert & & \vert \end{bmatrix} \\]
  • 15.
    edited February 15

    Then the product matrix \(A \cdot B\) consists of all possible dot products of a row from \(A\) with a column from \(B\):

    \[ A \cdot B = \begin{bmatrix} \text{---} & a_1 & \text{---} \\ \text{---} & a_2 & \text{---} \\ & \vdots & \\ \text{---} & a_m & \text{---} \end{bmatrix} \cdot \begin{bmatrix} \vert & \vert & & \vert \\ b_1 & b_2 & ... & b_n \\ \vert & \vert & & \vert \end{bmatrix} = \begin{bmatrix} a_1 \cdot b_1 & a_1 \cdot b_2 & \text{---} & a_1 \cdot b_n \\ a_2 \cdot b_1 & a_2 \cdot b_2 & \text{---} & a_2 \cdot b_n \\ a_m \cdot b_1 & a_m \cdot b_2 & \text{---} & a_m \cdot b_n \end{bmatrix} \]

    Comment Source:Then the product matrix \\(A \cdot B\\) consists of all possible dot products of a row from \\(A\\) with a column from \\(B\\): \\[ A \cdot B = \begin{bmatrix} \text{---} & a_1 & \text{---} \\\\ \text{---} & a_2 & \text{---} \\\\ & \vdots & \\\\ \text{---} & a_m & \text{---} \end{bmatrix} \cdot \begin{bmatrix} \vert & \vert & & \vert \\\\ b_1 & b_2 & ... & b_n \\\\ \vert & \vert & & \vert \end{bmatrix} = \begin{bmatrix} a_1 \cdot b_1 & a_1 \cdot b_2 & \text{---} & a_1 \cdot b_n \\\\ a_2 \cdot b_1 & a_2 \cdot b_2 & \text{---} & a_2 \cdot b_n \\\\ a_m \cdot b_1 & a_m \cdot b_2 & \text{---} & a_m \cdot b_n \end{bmatrix} \\]
  • 16.

    Let's work through an example.

    Comment Source:Let's work through an example.
  • 17.
    edited February 15

    Suppose \(A\) is 3-by-2:

    \[ \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bmatrix} \]

    And \(B\) is 2-by-4:

    \[ \begin{bmatrix} 10 & 20 & 30 & 40 \\ 50 & 60 & 70 & 80 \end{bmatrix} \]

    Comment Source:Suppose \\(A\\) is 3-by-2: \\[ \begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\\\ 5 & 6 \end{bmatrix} \\] And \\(B\\) is 2-by-4: \\[ \begin{bmatrix} 10 & 20 & 30 & 40 \\\\ 50 & 60 & 70 & 80 \end{bmatrix} \\]
  • 18.
    edited February 15

    We can form the product \(A \cdot B\), because:

    \[ncols(A) = nrows(B) = 2\]

    Comment Source:We can form the product \\(A \cdot B\\), because: \\[ncols(A) = nrows(B) = 2\\]
  • 19.
    edited February 15

    Here is \(A\) in row format:

    \[ A = \begin{bmatrix} \begin{bmatrix} 1 & 2 \end{bmatrix} \\ \begin{bmatrix} 3 & 4 \end{bmatrix} \\ \begin{bmatrix} 5 & 6 \end{bmatrix} \end{bmatrix} \]

    And \(B\) in column format:

    \[ B = \begin{bmatrix} \begin{bmatrix} 10 \\ 50 \end{bmatrix} && \begin{bmatrix} 20 \\ 60 \end{bmatrix} && \begin{bmatrix} 30 \\ 70 \end{bmatrix} && \begin{bmatrix} 40 \\ 80 \end{bmatrix} \end{bmatrix} \]

    Comment Source:Here is \\(A\\) in row format: \\[ A = \begin{bmatrix} \begin{bmatrix} 1 & 2 \end{bmatrix} \\\\ \begin{bmatrix} 3 & 4 \end{bmatrix} \\\\ \begin{bmatrix} 5 & 6 \end{bmatrix} \end{bmatrix} \\] And \\(B\\) in column format: \\[ B = \begin{bmatrix} \begin{bmatrix} 10 \\\\ 50 \end{bmatrix} && \begin{bmatrix} 20 \\\\ 60 \end{bmatrix} && \begin{bmatrix} 30 \\\\ 70 \end{bmatrix} && \begin{bmatrix} 40 \\\\ 80 \end{bmatrix} \end{bmatrix} \\]
  • 20.
    edited February 15

    So we have row vectors \(a_1 = \begin{bmatrix} 1 & 2 \end{bmatrix}\), \(a_2 = \begin{bmatrix} 3 & 4 \end{bmatrix}\), \(a_3 = \begin{bmatrix} 5 & 6 \end{bmatrix}\),

    and column vectors \(b_1 = \begin{bmatrix} 10 \\ 50 \end{bmatrix} \), \(b_2 = \begin{bmatrix} 20 \\ 60 \end{bmatrix} \), \(b_3 = \begin{bmatrix} 30 \\ 70 \end{bmatrix} \), \(b_4 = \begin{bmatrix} 30 \\ 80 \end{bmatrix} \).

    So the product matrix \(A \cdot B\) is the 3-by-4 matrix of dot products \(a_i \cdot b_j\).

    Comment Source:So we have row vectors \\(a_1 = \begin{bmatrix} 1 & 2 \end{bmatrix}\\), \\(a_2 = \begin{bmatrix} 3 & 4 \end{bmatrix}\\), \\(a_3 = \begin{bmatrix} 5 & 6 \end{bmatrix}\\), and column vectors \\(b_1 = \begin{bmatrix} 10 \\\\ 50 \end{bmatrix} \\), \\(b_2 = \begin{bmatrix} 20 \\\\ 60 \end{bmatrix} \\), \\(b_3 = \begin{bmatrix} 30 \\\\ 70 \end{bmatrix} \\), \\(b_4 = \begin{bmatrix} 30 \\\\ 80 \end{bmatrix} \\). So the product matrix \\(A \cdot B\\) is the 3-by-4 matrix of dot products \\(a_i \cdot b_j\\).
  • 21.
    edited February 15

    \[ A \cdot B = \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bmatrix} \cdot \begin{bmatrix} 10 & 20 & 30 & 40 \\ 50 & 60 & 70 & 80 \end{bmatrix} = \begin{bmatrix} 110 & 140 & 170 & 200 \\ 230 & 300 & 370 & 440 \\ 350 & 460 & 570 & 680 \end{bmatrix} = \begin{bmatrix} a_1 \cdot b_1 & a_1 \cdot b_2 & a_1 \cdot b_3 & a_1 \cdot b_4 \\ a_2 \cdot b_1 & a_2 \cdot b_2 & a_2 \cdot b_3 & a_2 \cdot b_4 \\ a_3 \cdot b_1 & a_3 \cdot b_2 & a_3 \cdot b_3 & a_3 \cdot b_4 \end{bmatrix} \]

    Comment Source:\\[ A \cdot B = \begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\\\ 5 & 6 \end{bmatrix} \cdot \begin{bmatrix} 10 & 20 & 30 & 40 \\\\ 50 & 60 & 70 & 80 \end{bmatrix} = \begin{bmatrix} 110 & 140 & 170 & 200 \\\\ 230 & 300 & 370 & 440 \\\\ 350 & 460 & 570 & 680 \end{bmatrix} = \begin{bmatrix} a_1 \cdot b_1 & a_1 \cdot b_2 & a_1 \cdot b_3 & a_1 \cdot b_4 \\\\ a_2 \cdot b_1 & a_2 \cdot b_2 & a_2 \cdot b_3 & a_2 \cdot b_4 \\\\ a_3 \cdot b_1 & a_3 \cdot b_2 & a_3 \cdot b_3 & a_3 \cdot b_4 \end{bmatrix} \\]
  • 22.
    edited February 16
    Comment Source:Fin * * * [Prev: Numbers and vectors](https://forum.azimuthproject.org/discussion/2475/section1-linear-algebra-numbers-and-vectors-tanzer-trail1-post1)
Sign In or Register to comment.