Skip to main content
  1. Notes/
  2. Mathematics/
  3. Linear Algebra/

Matrix Multiplication as Composition

Matrix Multiplication as Composition
#

  • As we saw in the last chapter, when we do transformation we basically are looking for where the basis vectors land, because they can represent any matrix in the space.
  • Now, let’s say we do multiple transformation to a matrix, this is where we can use matrix multiplication.
  • If I do one linear transformation and then I do another, it is called the composition.
  • Example: Composition of a rotation and a shear:
    • Shear is a special transformation, where \( \hat{\imath} \) remains fixed, but \( \hat{\jmath} \) moves over coordinates (1,1): shear matrix So, we can represent it as the matrix: $$ \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} $$

      NOTE: First column is for where \( \hat{\imath} \) moves and 2nd column is for where \( \hat{\jmath} \) moves.

    • Rotation means rotating the vector 90 degrees. rotation then shear in action

    • So these are 2 linear transformations and this new linear transformation(final) is called composition of the two linear transformations that we applied and like any linear transformations it can be described with a matrix by following \( \hat{\imath} \) and \( \hat{\jmath} \).

    • Since the ultimate landing spot for this will always be (1,1) - shear matrix. So, that will be the first column. And as we can observe \( \hat{\jmath} \) will ultimately land at (-1,0), so this will be the 2nd column. $$ \begin{bmatrix} 1 & -1 \\ 1 & 0 \end{bmatrix} $$

    • Long way to do this(without visualization) is to first do rotation then multiply by shear matrix:

      $$ \underbrace{ \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} }_{\text{Shear}} \left( \underbrace{ \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} }_{\text{Rotation}} \begin{bmatrix} x \\ y \end{bmatrix} \right) = \underbrace{ \begin{bmatrix} 1 & -1 \\ 1 & 0 \end{bmatrix} }_{\text{Composition}} \begin{bmatrix} x \\ y \end{bmatrix} $$

      NOTE: This is for any generic vector (x,y)

    • So, here you can see the Composition is the matrix multiplication of the two matrices.

    • Also, note here we do Rotation then shear but we have written it right to left. You can think of it like we think of function. So, when we evaluate functions like this: $$ f(g(x)) $$ Here, also we do g first then f, so it is similar to that.

Matrix Multiplication Formula
#

  • Now, let’s see an example of how to do this using matrix multiplication.
  • Let’s say we do 2 transformations M1 then M2: $$ \overbrace{ \begin{bmatrix} a & b \\ c & d \end{bmatrix} }^{{M_2}} \overbrace{ \begin{bmatrix} e & f \\ g & h \end{bmatrix} }^{{M_1}} $$
  • To follow where \( \hat{\imath} \) goes. First we take the first column of M1, since this is where \( \hat{\imath} \) initially lands. Then multiply it by M2: $$ \begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} e \\ g \end{bmatrix} = e \begin{bmatrix} a \\ c \end{bmatrix} + g \begin{bmatrix} b \\ d \end{bmatrix} = \begin{bmatrix} ae + bg \\ ce + dg \end{bmatrix} $$
  • Similarly, for \( \hat{\jmath} \) we take the 2nd column of M1 and multiply it by M2: $$ \begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} f \\ h \end{bmatrix} = f \begin{bmatrix} a \\ c \end{bmatrix} + h \begin{bmatrix} b \\ d \end{bmatrix} = \begin{bmatrix} af + bh \\ cf + dh \end{bmatrix} $$
  • Putting these together, we get the matrix multiplication formula: $$ \begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} e & f \\ g & h \end{bmatrix} = \begin{bmatrix} ae + bg & af + bh \\ ce + dg & cf + dh \end{bmatrix} $$

Properties of Matrix Multiplication: Understood visually
#

  • Commutativity: Does it matter what order we put the matrices in when we multiply them? $$ M_{1} M_{2} \overset{???}{=} M_{2} M_{1} $$
  • We can see it visually as: For example:
    • If we do: First shear then rotation: shear then rotation
    • Or, First rotation then shear: rotation then shear
    • Here, we can clearly see that: $$ M_{1} M_{2} \neq M_{2} M_{1} $$ NOTE: How easy is it to do this visually.
  • Associativity: Does it matter how we group the matrices when we multiply them? $$ M_{1} (M_{2} M_{3}) \overset{???}= (M_{1} M_{2}) M_{3} $$
  • Notice how horrible it would be to do this numerically, but visually it is very easy: associativity
  • So, we can see that: $$ M_{1} (M_{2} M_{3}) = (M_{1} M_{2}) M_{3} $$

References
#