Nama Mahasiswa: Nabil Ulwan Muhammad Caesar
NIM: ‘220605110127’
Kelas: B
Matkul: Linear Algebra
Dosen Pengampu: Prof. Dr. Suhartono, M.Kom
Jurusan: Teknik Informatika
Lembaga: Universitas Islam Negeri Maulana Malik Ibrahim Malang
Pada bagian ini kita secara resmi menentukan bentuk eselon dari matriks dan, dari bentuknya, tentukan apakah sistem tidak memiliki solusi, solusi unik, atau banyak tak terhingga solusi
Dengan urutan reduksi baris elementer, setiap matriks memiliki keunikan bentuk eselon dan bentuk eselon tereduksi. Dengan eselon tereduksi bentuk, kita dapat menjawab pertanyaan mendasar dari sistem persamaan linear, yaitu, apakah tidak ada solusi, solusi unik, atau banyak tak terhingga solusi dari sistem
library(matlib)
Inisialisasi matriks A dengan elemen (0, -1, 1, 0, 1, 1, 0, 1, 3, -4, 2, 0, -1, 0, 4, -4) dan ukuran 4x4, serta inisialisasi vektor b dengan elemen (1, 1, 5, -2).
A <- matrix(c(0, -1, 1, 0, 1, 1, 0, 1, 3, -4, 2, 0, -1, 0, 4, -4), 4, 4)
b <- c(1, 1, 5, -2)
Kemudian, dilakukan pemanggilan fungsi showEqn(A, b) untuk menampilkan persamaan matematika yang merepresentasikan sistem persamaan linear dengan matriks A dan vektor b.
showEqn(A, b)
## 0*x1 + 1*x2 + 3*x3 - 1*x4 = 1
## -1*x1 + 1*x2 - 4*x3 + 0*x4 = 1
## 1*x1 + 0*x2 + 2*x3 + 4*x4 = 5
## 0*x1 + 1*x2 + 0*x3 - 4*x4 = -2
Selanjutnya, dipanggil fungsi echelon(A, b, verbose=TRUE, fractions=TRUE) untuk mentransformasi matriks A dan vektor b menjadi bentuk eselon baris. Pada pemanggilan fungsi ini, parameter verbose di-set sebagai TRUE untuk menampilkan proses transformasi matriks, dan parameter fractions di-set sebagai TRUE untuk menampilkan hasil transformasi dalam bentuk pecahan.
echelon(A, b, verbose=TRUE, fractions=TRUE)
##
## Initial matrix:
## [,1] [,2] [,3] [,4] [,5]
## [1,] 0 1 3 -1 1
## [2,] -1 1 -4 0 1
## [3,] 1 0 2 4 5
## [4,] 0 1 0 -4 -2
##
## row: 1
##
## exchange rows 1 and 2
## [,1] [,2] [,3] [,4] [,5]
## [1,] -1 1 -4 0 1
## [2,] 0 1 3 -1 1
## [3,] 1 0 2 4 5
## [4,] 0 1 0 -4 -2
##
## multiply row 1 by -1
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 -1 4 0 -1
## [2,] 0 1 3 -1 1
## [3,] 1 0 2 4 5
## [4,] 0 1 0 -4 -2
##
## subtract row 1 from row 3
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 -1 4 0 -1
## [2,] 0 1 3 -1 1
## [3,] 0 1 -2 4 6
## [4,] 0 1 0 -4 -2
##
## row: 2
##
## multiply row 2 by 1 and add to row 1
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 7 -1 0
## [2,] 0 1 3 -1 1
## [3,] 0 1 -2 4 6
## [4,] 0 1 0 -4 -2
##
## subtract row 2 from row 3
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 7 -1 0
## [2,] 0 1 3 -1 1
## [3,] 0 0 -5 5 5
## [4,] 0 1 0 -4 -2
##
## subtract row 2 from row 4
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 7 -1 0
## [2,] 0 1 3 -1 1
## [3,] 0 0 -5 5 5
## [4,] 0 0 -3 -3 -3
##
## row: 3
##
## multiply row 3 by -1/5
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 7 -1 0
## [2,] 0 1 3 -1 1
## [3,] 0 0 1 -1 -1
## [4,] 0 0 -3 -3 -3
##
## multiply row 3 by 7 and subtract from row 1
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 0 6 7
## [2,] 0 1 3 -1 1
## [3,] 0 0 1 -1 -1
## [4,] 0 0 -3 -3 -3
##
## multiply row 3 by 3 and subtract from row 2
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 0 6 7
## [2,] 0 1 0 2 4
## [3,] 0 0 1 -1 -1
## [4,] 0 0 -3 -3 -3
##
## multiply row 3 by 3 and add to row 4
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 0 6 7
## [2,] 0 1 0 2 4
## [3,] 0 0 1 -1 -1
## [4,] 0 0 0 -6 -6
##
## row: 4
##
## multiply row 4 by -1/6
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 0 6 7
## [2,] 0 1 0 2 4
## [3,] 0 0 1 -1 -1
## [4,] 0 0 0 1 1
##
## multiply row 4 by 6 and subtract from row 1
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 0 0 1
## [2,] 0 1 0 2 4
## [3,] 0 0 1 -1 -1
## [4,] 0 0 0 1 1
##
## multiply row 4 by 2 and subtract from row 2
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 0 0 1
## [2,] 0 1 0 0 2
## [3,] 0 0 1 -1 -1
## [4,] 0 0 0 1 1
##
## multiply row 4 by 1 and add to row 3
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 0 0 1
## [2,] 0 1 0 0 2
## [3,] 0 0 1 0 0
## [4,] 0 0 0 1 1
Setelah itu, dipanggil kembali fungsi showEqn(A, b) untuk menampilkan persamaan matematika yang merepresentasikan sistem persamaan linear dalam bentuk eselon baris.
showEqn(A, b)
## 0*x1 + 1*x2 + 3*x3 - 1*x4 = 1
## -1*x1 + 1*x2 - 4*x3 + 0*x4 = 1
## 1*x1 + 0*x2 + 2*x3 + 4*x4 = 5
## 0*x1 + 1*x2 + 0*x3 - 4*x4 = -2
Pada akhirnya, fungsi showEqn(A, b) dipanggil kembali untuk menampilkan persamaan matematika yang merepresentasikan sistem persamaan linear setelah ditransformasi dalam bentuk eselon baris.
showEqn(A, b)
## 0*x1 + 1*x2 + 3*x3 - 1*x4 = 1
## -1*x1 + 1*x2 - 4*x3 + 0*x4 = 1
## 1*x1 + 0*x2 + 2*x3 + 4*x4 = 5
## 0*x1 + 1*x2 + 0*x3 - 4*x4 = -2