Exercies for the chapter readings of week 1.

\[ x + y − z = −1 \\ x − y − z = −1\\ z =2 \]

Setting up the matrixies:

M <- matrix(c(1, 1, -1, 1, -1, -1, 0, 0, 1), ncol = 3, byrow = TRUE)
v <- matrix(c(-1, -1, 2),ncol = 1)
M
##      [,1] [,2] [,3]
## [1,]    1    1   -1
## [2,]    1   -1   -1
## [3,]    0    0    1
v
##      [,1]
## [1,]   -1
## [2,]   -1
## [3,]    2

Using the solve function:

sol <- solve(M,v)
sol
##      [,1]
## [1,]    1
## [2,]    0
## [3,]    2

Testing it.

M %*% sol
##      [,1]
## [1,]   -1
## [2,]   -1
## [3,]    2
t(M) * M 
##      [,1] [,2] [,3]
## [1,]    1    1    0
## [2,]    1    1    0
## [3,]    0    0    1
# That looks good
solve(M) %*% v # This way is a bit more by hand since we actually multiply the invers matrix by v. 
##      [,1]
## [1,]    1
## [2,]    0
## [3,]    2