rbind(c(1,2,3))
## [,1] [,2] [,3]
## [1,] 1 2 3
a <- rbind(c(1,2,3))
cbind(9,7,6)
## [,1] [,2] [,3]
## [1,] 9 7 6
c <- cbind(9,7,6)
Yes, you can take the transpose of \(\vec{a}\). The row vector would become a column vector. If you take the transpose twice, \(\vec{a}\) would go back to a row vector.
t(a)
## [,1]
## [1,] 1
## [2,] 2
## [3,] 3
t(t(a))
## [,1] [,2] [,3]
## [1,] 1 2 3
7*a
## [,1] [,2] [,3]
## [1,] 7 14 21
rbind(c(4,5,6))
## [,1] [,2] [,3]
## [1,] 4 5 6
b <- rbind(c(4,5,6))
a + b
## [,1] [,2] [,3]
## [1,] 5 7 9
x_{1} - x_{2} = 2 2x_{1} + 2x_{2} = 1
A <- matrix(c(1, -1, 2, 2), nrow = 2, ncol = 2, byrow = TRUE)
b <- c(2, 1)
library(matlib)
## Warning in rgl.init(initValue, onlyNULL): RGL: unable to open X11 display
## Warning: 'rgl_init' failed, running with rgl.useNULL = TRUE
showEqn(A, b)
## 1*x1 - 1*x2 = 2
## 2*x1 + 2*x2 = 1
c(R(A), R(cbind(A, b)))
## [1] 2 2
all.equal(R(A), R(cbind(A, b)))
## [1] TRUE
plotEqn(A, b)
## x1 - 1*x2 = 2
## 2*x1 + 2*x2 = 1
solve(A, b)
## [1] 1.25 -0.75
library(MASS)
fractions(solve(A, b))
## [1] 5/4 -3/4
2x_{1} + x_{2} - x_{3} = 8 3x_{1} + x_{2} - 2x_{3} = 11 2x_{1} - x_{2} - 2x_{3} = 3
D <- matrix(c(2, 1, -1, 3, 1, -2, 2, -1, -2), nrow = 3, ncol = 3, byrow = TRUE)
d <- c(8, 11, 3)
solve(D, d)
## [1] 2 3 -1
solve(D)
## [,1] [,2] [,3]
## [1,] 4 -3 1
## [2,] -2 2 -1
## [3,] 5 -4 1
solve(D, d)
## [1] 2 3 -1
Yes, I am getting the same results as from the website.
plotEqn3d(D, d)
inv(D)
## [,1] [,2] [,3]
## [1,] 4 -3 1
## [2,] -2 2 -1
## [3,] 5 -4 1
(1/(inv(D)))
## [,1] [,2] [,3]
## [1,] 0.25 -0.3333333 1
## [2,] -0.50 0.5000000 -1
## [3,] 0.20 -0.2500000 1
DI <- cbind(D, diag(3))
DI
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 2 1 -1 1 0 0
## [2,] 3 1 -2 0 1 0
## [3,] 2 -1 -2 0 0 1
library(matlib)
echelon(DI, verbose=TRUE, fractions=TRUE)
##
## Initial matrix:
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 2 1 -1 1 0 0
## [2,] 3 1 -2 0 1 0
## [3,] 2 -1 -2 0 0 1
##
## row: 1
##
## exchange rows 1 and 2
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 3 1 -2 0 1 0
## [2,] 2 1 -1 1 0 0
## [3,] 2 -1 -2 0 0 1
##
## multiply row 1 by 1/3
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 1/3 -2/3 0 1/3 0
## [2,] 2 1 -1 1 0 0
## [3,] 2 -1 -2 0 0 1
##
## multiply row 1 by 2 and subtract from row 2
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 1/3 -2/3 0 1/3 0
## [2,] 0 1/3 1/3 1 -2/3 0
## [3,] 2 -1 -2 0 0 1
##
## multiply row 1 by 2 and subtract from row 3
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 1/3 -2/3 0 1/3 0
## [2,] 0 1/3 1/3 1 -2/3 0
## [3,] 0 -5/3 -2/3 0 -2/3 1
##
## row: 2
##
## exchange rows 2 and 3
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 1/3 -2/3 0 1/3 0
## [2,] 0 -5/3 -2/3 0 -2/3 1
## [3,] 0 1/3 1/3 1 -2/3 0
##
## multiply row 2 by -3/5
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 1/3 -2/3 0 1/3 0
## [2,] 0 1 2/5 0 2/5 -3/5
## [3,] 0 1/3 1/3 1 -2/3 0
##
## multiply row 2 by 1/3 and subtract from row 1
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 0 -4/5 0 1/5 1/5
## [2,] 0 1 2/5 0 2/5 -3/5
## [3,] 0 1/3 1/3 1 -2/3 0
##
## multiply row 2 by 1/3 and subtract from row 3
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 0 -4/5 0 1/5 1/5
## [2,] 0 1 2/5 0 2/5 -3/5
## [3,] 0 0 1/5 1 -4/5 1/5
##
## row: 3
##
## multiply row 3 by 5
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 0 -4/5 0 1/5 1/5
## [2,] 0 1 2/5 0 2/5 -3/5
## [3,] 0 0 1 5 -4 1
##
## multiply row 3 by 4/5 and add to row 1
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 0 0 4 -3 1
## [2,] 0 1 2/5 0 2/5 -3/5
## [3,] 0 0 1 5 -4 1
##
## multiply row 3 by 2/5 and subtract from row 2
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 0 0 4 -3 1
## [2,] 0 1 0 -2 2 -1
## [3,] 0 0 1 5 -4 1
D%*%inv(D)
## [,1] [,2] [,3]
## [1,] 1 0 0
## [2,] 0 1 0
## [3,] 0 0 1
inv(D)%*%D
## [,1] [,2] [,3]
## [1,] 1 0 0
## [2,] 0 1 0
## [3,] 0 0 1