I chose to work on exercise C33 to get re-acquainted with R and R markdown.
Find all solutions to the linear system:
x + y - z = -1
x - y - z = -1
z = 2
Solution-
Set into a matrix rows and columns the coeffient values of the variables on the left side of the simultaneous equations.
Call this matrix A.
Set into another matrix the answercolumn on the right side of the right side of the simultaneous equations.
Call this matrix B.
We know that the solution set (x,y,z) can be derived using matrix multipication A * (x,y,z)= B, or (x,y,z) = A-1 B.
A = matrix(c(1, 1, 0, 1, -1, 0, -1, -1, 1), nrow=3, ncol=3)
B = matrix(c(-1, -1, 2), nrow=3, ncol=1)
A
## [,1] [,2] [,3]
## [1,] 1 1 -1
## [2,] 1 -1 -1
## [3,] 0 0 1
B
## [,1]
## [1,] -1
## [2,] -1
## [3,] 2
solve(A,B) #r function to find (x,y,z) solution set.
## [,1]
## [1,] 1
## [2,] 0
## [3,] 2