Problem RREF.C33

Row-reduce the matrix without the aid of a calculator, indicating the row operations you are using at each step using the notation used in Definition RO:

#Create matrix in R
c33 <- matrix(c(1, 2, -1, 2, 4, -2, -1, -1, 3, -1, 4, 5), nrow = 3, ncol = 4)
#Display matrix
c33
##      [,1] [,2] [,3] [,4]
## [1,]    1    2   -1   -1
## [2,]    2    4   -1    4
## [3,]   -1   -2    3    5
#First row operation: -2 * R1 + R2 and then display
c33[2,] <- (-2 * c33[1,]) + c33[2,]
c33
##      [,1] [,2] [,3] [,4]
## [1,]    1    2   -1   -1
## [2,]    0    0    1    6
## [3,]   -1   -2    3    5
#Second row operation: R2 <-> R3 and then display
new2 <- c33[3,]
new3 <- c33[2,]
c33[2,] <- new2
c33[3,] <- new3
c33
##      [,1] [,2] [,3] [,4]
## [1,]    1    2   -1   -1
## [2,]   -1   -2    3    5
## [3,]    0    0    1    6
#Third row operation: R1 + R2 and then display
c33[2,] <- c33[1,] + c33[2,]
c33
##      [,1] [,2] [,3] [,4]
## [1,]    1    2   -1   -1
## [2,]    0    0    2    4
## [3,]    0    0    1    6
#Fourth row operation: -1 * R3 + R2 and then display
c33[2,] <- (-1 * c33[3,]) + c33[2,]
c33
##      [,1] [,2] [,3] [,4]
## [1,]    1    2   -1   -1
## [2,]    0    0    1   -2
## [3,]    0    0    1    6
#Fifth row operation: -1 * R2 + R3 and then display
c33[3,] <- (-1 * c33[2,]) + c33[3,]
c33
##      [,1] [,2] [,3] [,4]
## [1,]    1    2   -1   -1
## [2,]    0    0    1   -2
## [3,]    0    0    0    8
#Sixth and final row operation:  1/8 * R3 and then display
c33[3,] <- (1/8) * c33[3,]
#Matrix in Reduced Row-Echelon Form
c33
##      [,1] [,2] [,3] [,4]
## [1,]    1    2   -1   -1
## [2,]    0    0    1   -2
## [3,]    0    0    0    1