Nama : Fairuz Ardhan Haunan

NIM : 220605110038

Kelas : Linear Algebra A

Dosen Pengampu : Prof. Dr. Suhartono, M.Kom.

Jurusan : Teknik Informatika

Universitas : UIN Maulana Malik Ibrahim Malang

library(matlib)

Baris pertama memuat paket “matlib”, yang menyediakan berbagai fungsi untuk komputasi matriks.

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)

Baris kedua mendefinisikan matriks 4x4 A dengan nilai (0, -1, 1, 0, 1, 1, 0, 1, 3, -4, 2, 0, -1, 0, 4, -4) dan vektor b dengan nilai (1, 1, 5, -2).

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

Baris ketiga menggunakan fungsi showEqn() dari paket “matlib” untuk menampilkan sistem persamaan linear yang direpresentasikan oleh matriks A dan vektor b. Output menunjukkan persamaan dalam bentuk Ax = b, di mana A adalah matriks dan b adalah vektor.

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

Baris keempat menggunakan fungsi echelon() dari paket “matlib” untuk menghitung bentuk baris echelon dari A dan b, dengan opsi verbose=TRUE untuk menampilkan setiap langkah komputasi, dan opsi fractions=TRUE untuk menampilkan hasil dalam bentuk pecahan daripada desimal. Bentuk baris echelon adalah matriks yang disederhanakan sehingga memungkinkan Anda untuk lebih mudah menyelesaikan sistem persamaan linear. Output fungsi menampilkan bentuk baris echelon dari A dan b dan beberapa informasi tambahan tentang komputasi tersebut.