C10 (page 512)

In the vector space C3, compute the vector representation \(p_B(v)\) for the basis B and vector v below:

# B is a collection of three basis vectors
B <- cbind(c(2,-2,2), c(1,3,1), c(3,5,2))
B
##      [,1] [,2] [,3]
## [1,]    2    1    3
## [2,]   -2    3    5
## [3,]    2    1    2
# v is a column vector
v <- rbind(11, 5, 8)
v
##      [,1]
## [1,]   11
## [2,]    5
## [3,]    8
# to linearly transform v by B
v_trans <- B %*% v
v_trans
##      [,1]
## [1,]   51
## [2,]   33
## [3,]   43
# and just to double check, transforming v_trans by B^-1 should get us back to v
solve(B) %*% v_trans
##      [,1]
## [1,]   11
## [2,]    5
## [3,]    8