Doing the C39 problem. Linear system: \[ \begin{align*} x + y - z &= -5 \\ x - y - z &= -3 \\ x + y - z &= 0 \end{align*} \]

Matrix representation: \[ A = \begin{pmatrix} 1 & 1 & -1 \\ 1 & -1 & -1 \\ 1 & 1 & -1 \end{pmatrix}, \quad b = \begin{pmatrix} -5 \\ -3 \\ 0 \end{pmatrix} \]

A <- rbind(c(1,1,-1),
           c(1,-1,-1),
           c(1,1,-1))

b <- c(-5, -3, 0)



solution <- try(solve(A, b), silent = TRUE)


# Checks if there is an error if the matrix is singular 
if (inherits(solution, "try-error")) {
  cat("The system is singular and cannot be solved.")
} else {
  print(solution)
}
## The system is singular and cannot be solved.

The