### Practical Applications
A <- matrix(c(4, 0, 0, 1, 1, 2, 5, 1, 3, 5, 1, 1, 0, 3, 0, 1), nrow=4, ncol=4, byrow=TRUE)
det(A)[1] -86
This formula is NOT correct! Check - Tetrahedron - Wikipedia
### Practical Applications
A <- matrix(c(4, 0, 0, 1, 1, 2, 5, 1, 3, 5, 1, 1, 0, 3, 0, 1), nrow=4, ncol=4, byrow=TRUE)
det(A)[1] -86
## Example 89
A <- matrix(c(0, 1, 3, -1, -1, 1, -4, 0, 1, 0, 2, 4, 0, 1, 0, -4), nrow = 4, ncol = 4, byrow = TRUE)
b <- c(1, 1, 5, -2)
# Define A1(b)
A1 <- A
A1[, 1] <- b
# Define A2(b)
A2 <- A
A2[ ,2] <- b
# Define A3(b)
A3 <- A
A3[ ,3] <- b
# Define A4(b)
A4 <- A
A4[ ,4] <- b
x1 <- det(A1)/det(A)
x2 <- det(A2)/det(A)
x3 <- det(A3)/det(A)
x4 <- det(A4)/det(A)
solve(A,b)[1] 1 2 0 1
### Practical Applications
A <- matrix(c(1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 1), nrow = 11, ncol = 18, byrow = TRUE)
b <- c(1298, 1948, 465, 605, 451, 338, 260, 183, 282, 127, 535)
C <- cbind(A, b)
library(pracma)
E <- rref(C)
E b
[1,] 1 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1483
[2,] 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 605
[3,] 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 451
[4,] 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 338
[5,] 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 260
[6,] 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 183
[7,] 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 282
[8,] 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 127
[9,] 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 535
[10,] 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1948
[11,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
E <- E[-11,]
G1 <- eye(8)
G2 <- matrix(rep(0, 80), 8, 10)
b2 <- c(266, 223, 140, 264, 137, 67, 130, 24)
G <- cbind(G1, G2, b2)
M <- rbind(E, G)
solve(M[, -19], M[, 19])
266 223 140 264 137 67 130 24 47 199 382 311 74 123 116 152 103 488
# Initialize the 18 x 18 array for storing the Ai(b) matrices
T <- array(dim=c(18,18,18))
# Create Ai(b) matrices for i = 1 to 18
for(i in 1:18){
T[,,i] <- M[, -19]
T[,i,i] <- M[, 19]
}
# Initialize the vector for the solution x,
# the zero vector with length 18
x <- rep(0, 18)
# Find the solution with Cramer's rule
for(i in 1:18){
x[i] <- det(T[,,i])/det(M[, -19])
}
x [1] 266 223 140 264 137 67 130 24 47 199 382 311 74 123 116 152 103 488
x <- c(-1, 1, 1, 3, 1+sqrt(2))
y <- c(1, -1, 3, 1, 1+sqrt(2))
## Initializing
M1 <- matrix(rep(0, 5*6), nrow = 5, ncol = 6)
## Make the last column of M1 have all 1.
M1[, 6] <- rep(1, 5)
## Creating the first column of M1
for(i in 1:5)
M1[i, 1] <- x[i]*x[i]
## Creating the second column of M1
for(i in 1:5)
M1[i, 2] <- x[i]*y[i]
## Creating the third column of M1
for(i in 1:5)
M1[i, 3] <- y[i]*y[i]
## Creating the fourth column of M1
for(i in 1:5)
M1[i, 4] <- x[i]
## Creating the fifth column of M1
for(i in 1:5)
M1[i, 5] <- y[i]
a <- det(M1[, -1])
#determinant of the matrix deleting the first column of M1
b <- -det(M1[, -2])
#determinant of the matrix deleting the second column of M1
c <- det(M1[, -3])
#determinant of the matrix deleting the third column of M1
d <- -det(M1[, -4])
#determinant of the matrix deleting the fourth column of M1
e <- det(M1[, -5])
#determinant of the matrix deleting the fifth column of M1
f <- -det(M1[, -6])
#determinant of the matrix deleting the sixth column of M1
library(conics)
v <- c(a, b, c, d, e, f)
conicPlot(v)