Chapter SLE - Systems of Linear Equations


C34 - Find all solutions to the linear system:

x + y − z = −5
x − y − z = −3
x + y − z = 0

\[ \left(\begin{array}{cc} 1 & 1 & -1\\ 1 & -1 & -1\\ 1 & 1 & -1 \end{array}\right) \left(\begin{array}{cc} x\\ y\\ z \end{array}\right) = \left(\begin{array}{cc} -5\\ -3\\ 0 \end{array}\right) \]

A <- matrix(c(1, 1, -1, 1, -1, -1, 1, 1, -1), nrow = 3, ncol = 3, byrow = T)
b <- matrix(c(-5, -3, 0), nrow = 3, ncol = 1)

matrix_processor <- function(A, b){
  A <- cbind(A, b)
  A[2,] <- A[2,] - (A[2,1] / A[1,1]) * A[1,]
  A[3,] <- A[3,] - (A[3,1] / A[1,1]) * A[1,]
  A[3,] <- A[3,] - (A[3,2] / A[2,2]) * A[2,]
  A[2,] <- A[2,] - (A[2,3] / A[3,3]) * A[3,]
  A[1,] <- A[1,] - (A[1,2] / A[2,2]) * A[2,]
  A[1,] <- A[1,] - (A[1,3] / A[3,3]) * A[3,]
  
  x <- matrix(c(A[1,4] / A[1,1], A[2,4] / A[2,2], A[3,4] / A[3,3]), nrow = 3, ncol = 1)
  return(x)
}

matrix_processor(A, b)
##      [,1]
## [1,]  NaN
## [2,]  NaN
## [3,]  Inf

No Solution.