Nama = Izza Syahri Muharram || Nim = 220605110073 || Mata kuliah = Linear Algebra || Dosen Pengampu = Prof. Dr. SUHARTONO, M.Kom || Teknik Informatika || Universitas Islam Negeri Malang.

Latihan

  1. Misalkan kita memiliki matriks 3 × 3 sehingga A = 2 4 1 0 1 0 3 0 −2 2 −1 3 5 : Hitung determinan dari A
# Define the matrix A
A <- matrix(c(2, 4, 1, 0, 1, 0, 3, 0, -2), nrow = 3, byrow = TRUE)

# Compute the determinant of A
det_A <- det(A)

# Print the determinant
print(det_A)
## [1] -7
  1. Misalkan kita memiliki matriks A 3x3 sehingga: A = 1 2 3 4 5 6 7 8 9 Hitung determinan A dan verifikasi properti berikut:

Mengalikan baris dengan skalar mengalikan determinan dengan skalar yang sama. Menukar dua baris mengubah tanda determinan. Menambahkan kelipatan skalar dari satu baris ke baris lain tidak mengubah determinan

# Define the matrix A
A <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), nrow = 3, byrow = TRUE)
print(A)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    4    5    6
## [3,]    7    8    9
# Determinant of A
det_A <- det(A)
print(paste("Determinant of A:", det_A))
## [1] "Determinant of A: 6.66133814775094e-16"
# Property 1: Multiplying a row by a scalar multiplies the determinant by the same scalar
k <- 2
A_modified1 <- A
A_modified1[2, ] <- A_modified1[2, ] * k
det_A_modified1 <- det(A_modified1)
print(paste("Determinant after multiplying row 2 by", k, ":", det_A_modified1))
## [1] "Determinant after multiplying row 2 by 2 : 0"
print(paste("Determinant of A multiplied by", k, ":", det_A * k))
## [1] "Determinant of A multiplied by 2 : 1.33226762955019e-15"
# Property 2: Swapping two rows changes the sign of the determinant
A_swapped <- A
A_swapped[c(1, 3), ] <- A_swapped[c(3, 1), ]
det_A_swapped <- det(A_swapped)
print(paste("Determinant after swapping rows 1 and 3:", det_A_swapped))
## [1] "Determinant after swapping rows 1 and 3: -6.66133814775094e-16"
print(paste("Negative determinant of A:", -det_A))
## [1] "Negative determinant of A: -6.66133814775094e-16"
# Property 3: Adding a scalar multiple of one row to another row does not change the determinant
A_modified2 <- A
A_modified2[3, ] <- A_modified2[3, ] + 2 * A_modified2[1, ]
det_A_modified2 <- det(A_modified2)
print(paste("Determinant after adding 2 times row 1 to row 3:", det_A_modified2))
## [1] "Determinant after adding 2 times row 1 to row 3: 0"
print(paste("Determinant of A:", det_A))
## [1] "Determinant of A: 6.66133814775094e-16"
  1. Solve the following system of equations using Cramer’s rule: 2x + 3y = 10 4x - y = 5
# Define the coefficients matrix A and the constants vector B
A <- matrix(c(2, 3, 4, -1), nrow = 2, byrow = TRUE)
B <- c(10, 5)

# Calculate the determinant of A
det_A <- det(A)

# Create a function to solve for a specific variable using Cramer's rule
solve_cramer <- function(A, B, index) {
  A_cramer <- A
  A_cramer[, index] <- B
  det_A_cramer <- det(A_cramer)
  solution <- det_A_cramer / det_A
  return(solution)
}

# Solve for x using Cramer's rule
x <- solve_cramer(A, B, 1)

# Solve for y using Cramer's rule
y <- solve_cramer(A, B, 2)

# Print the solutions
cat("The solution to the system of equations is:\n")
## The solution to the system of equations is:
cat("x =", x, "\n")
## x = 1.785714
cat("y =", y, "\n")
## y = 2.142857
  1. Misalkan kita memiliki tiga titik (x1; x2); (y1; y2); (z1; z2), yang mana tidak co-linear,. Kemudian, kami menganggap segitiga yang simpul adalah tiga titik ini. buat di r studio
# Define the coordinates of the three points
x1 <- 2
x2 <- 4
y1 <- 1
y2 <- 5
z1 <- -3
z2 <- 3

# Plot the points
plot(x = c(x1, y1, z1), y = c(x2, y2, z2), xlim = c(-5, 5), ylim = c(-5, 5), xlab = "X", ylab = "Y", asp = 1)

# Connect the points to form a triangle
lines(x = c(x1, y1), y = c(x2, y2))
lines(x = c(y1, z1), y = c(y2, z2))
lines(x = c(z1, x1), y = c(z2, x2))

# Add labels for the points
text(x = c(x1, y1, z1), y = c(x2, y2, z2), labels = c("A", "B", "C"), pos = 3)

daftar pustaka 1. Yoshida.Ruriko.2021.Linear Algebra and Its Applications With R.London. CRC Press