Compute the inverse of the coefficient matrix of the system of equations below and use the inverse to solve the system.
4x + 10y = 12 2x + 6y = 4
The inverse of a matrix plays the same roles in matrix algebra as the reciprocal of a number and division does in ordinary arithmetic:
we can solve a matrix equation like Ax=b for the vector x by multiplying both sides by the inverse of the matrix A
Ax=b ⇒ A−1Ax=A−1b ⇒ x=A−1b
The following system of equation illustrate the basic properties of the inverse of a matrix.
library(matlib)
A <- matrix(c(4, 2, 10, 6), 2, 2)
b <- c(12,4)
showEqn(A, b)
## 4*x1 + 10*x2 = 12
## 2*x1 + 6*x2 = 4
A
## [,1] [,2]
## [1,] 4 10
## [2,] 2 6
c( R(A), R(cbind(A,b)) )
## [1] 2 2
# Finding the determinant of A
det(A)
## [1] 4
AInv <- inv(A)
AInv
## [,1] [,2]
## [1,] 1.5 -2.5
## [2,] -0.5 1.0
# Proving A inverse X A is Identity matrix
AInv %*% A
## [,1] [,2]
## [1,] 1 0
## [2,] 0 1
# I * X = AInv * b => X = AInv * b
X = AInv %*% b
X
## [,1]
## [1,] 8
## [2,] -2
Solve(A, b, fractions = TRUE)
## x1 = 8
## x2 = -2
plotEqn(A,b)
## 4*x[1] + 10*x[2] = 12
## 2*x[1] + 6*x[2] = 4
### This intersection of two lines proves that this consistant system of
equation has at least one solution.