#Excercise C18 on page 161

If it exists, find the inverse of: A = [ 1, 3, 1 1, 2, 1 2, 2, 1]

Create and print the matrix A

A <- matrix(c(1,1,2,3,2,2,1,1,1), nrow = 3)
A
##      [,1] [,2] [,3]
## [1,]    1    3    1
## [2,]    1    2    1
## [3,]    2    2    1

Compute the determinant of A and print

detA <- det(A)
detA
## [1] 1

Determinant != 0 therefore this matrix does have an inverse. Compute the inverse of the matrix

aInv <- solve(A)
aInv
##      [,1] [,2] [,3]
## [1,]    0   -1    1
## [2,]    1   -1    0
## [3,]   -2    4   -1