=====================================================
Nama Mahasiswa : Muhammad Faydh Maula Qisthi
NIM : 220605110143
Kelas : B
Mata Kuliah : Linear Algebra
Dosen Pengampuh : Prof.Dr.Suhartono,M.Kom
Jurusan : Teknik Informatika
Universitas : UIN Maulana Malik Ibrahim Malang
=====================================================
We are going to use the det() function in R. As usual, first we define the matrix A and a vector b:
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)
Then we define matrices Ai(b) for i = 1, 2, 3, 4:
# 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
Then we use the det() function to find the solution using Cramer’s rule:
x1 <- det(A1)/det(A)
x2 <- det(A2)/det(A)
x3 <- det(A3)/det(A)
x4 <- det(A4)/det(A)
Now we check the solution by using the solve() function. Then R returns:
solve(A,b)
## [1] 1 2 0 1