MulaiMulai sekarang secara gratis

Matrix Multiplication - Order Matters

In the last lesson, we studied how matrices act on vectors (stretches, shrinkages, reflections, rotations, etc.) and transform vectors into new vectors.

The successive application of these matrices can act as complex transformations, but because matrix multiplication is not commutative, the order of these transformations matter.

  • The matrix with R output
> A
          [,1]       [,2]
[1,] 0.7071068 -0.7071068
[2,] 0.7071068  0.7071068

represents rotation of a 2-dimensional vector by 45 degrees counterclockwise.

  • The matrix
> B
     [,1] [,2]
[1,]    1    0
[2,]    0   -1

represents a reflection about the x (first) axis.

Latihan ini adalah bagian dari kursus

Linear Algebra for Data Science in R

Lihat Kursus

Petunjuk latihan

  • A, B and b are loaded for you. Compute the products \(AB\) and \(BA\) and show that these two actions are not commutative.
  • Apply both of these products by the vector b <- c(1,1) to further confirm.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Multiply A by B
A%*%___

# Multiply A on the right of B
___%*%A

# Multiply the product of A and B by the vector b
A%*%B%*%___

# Multiply A on the right of B, and then by the vector b
B%*%___%*%b
Edit dan Jalankan Kode