The code below solves the question c31 on pages 18-19 in “A First Course in Linear Algebra” by Robert A. Beezer
The system of equations are as follows:
3x + 2y = 1
x - y = 2
4x + 2y = 2
Solution is: [1,-1] for x, y
A <- array(c(3,1,4,2,-1,2), dim=c(3,2))
b <- c(1,2,2)
print(A)
## [,1] [,2]
## [1,] 3 2
## [2,] 1 -1
## [3,] 4 2
print(b)
## [1] 1 2 2
# print(solve(A) %*% c(1,2,2))
print(qr.solve(A,b))
## [1] 1 -1