Aan de slagGa gratis aan de slag

Matrix Multiplication as a Transformation

Matrices can be viewed as a way to transform collections of vectors into other vectors.

These transformations can take many forms, but the simplest ones in two dimensions are stretches or shrinkages (in either coordinate), reflections (e.g. about the x-axis, y-axis, origin, the line y = x), and rotations (clockwise, counter-clockwise).

Multiplication of a vector by a matrix is accomplished using the %*% command.

Deze oefening maakt deel uit van de cursus

Linear Algebra for Data Science in R

Cursus bekijken

Oefeninstructies

  • Use matrix multiplication in R to show that multiplication by the matrix \(A\) with R output:
> A
     [,1] [,2]
[1,]    4    0
[2,]    0    1

stretches the x (first) component of the vector b <- c(1,1) by a factor of four.

  • Show that multiplication by the matrix \(B\) with R output:
> B
     [,1] [,2]
[1,]    1    0
[2,]    0    2/3

shrinks the y (second) component of the vector b <- c(1,1) by 33 percent.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Multiply A by b
A ___ b

# Multiply B by b
___ ___ b
Code bewerken en uitvoeren