Substitute z = 2 in equation 1 and 2. We can re-write those equations as
We can re-write equation 2 as
Let’s substitute this value in equation 1
x + (x-1) = 1
2x = 2
x = 1
We know that y = x-1
so we can conclude that y = 0
With this we get following values of x, y and z
x = 1 y = 0 z = 2
equation = matrix(c(1, 1, 0, 1, -1, 0, -1, -1, 1), nrow=3, ncol=3)
result = matrix(c(-1, -1, 2), nrow=3, ncol=1)
coef = solve(equation, result)
print(paste("x =", coef[1], "y =", coef[2], "z =", coef[3]))
## [1] "x = 1 y = 0 z = 2"