Write an R function to solve the following systems of equations using the Jacobi
ID: 3745211 • Letter: W
Question
Write an R function to solve the following systems of equations using the Jacobi iterative method discussed in class. The code should check to ensure the system will converge and if not, it should report a warning message. - 3. A1 = [3110; 15-1 2; 1031; 0 1 1 41: A2[2.511 0 1 4.11 2;102.11; 0 112.1] =[2 1 10:13.5-1 2; 102.1 1; 0 1 1 2.11: Write an R function to solve the above systems of equations using the Gauss-Seidel iterative method discussed in class. The code should check to ensure the system will converge and if not, it should report an error message.+ 4. A1 = [3 1 10; 15-1 2; 1031; 0114]; A2 = [2.5 1 10:14.1-1 2; 102.11; 0 1 1 2.11:+' -[2 1 10:13.5-1 2; 1 0 2.1 1; 0112.11:Explanation / Answer
itersolve(A, b, x0 = NULL, nmax = 1000, tol = .Machine$double.eps^(0.5), method = c("Gauss-Seidel", "Jacobi", "Richardson"))
N <- 10 A <- Diag(rep(3,N)) + Diag(rep(-2, N-1), k=-1) + Diag(rep(-1, N-1), k=1) b <- A %*% rep(1, N) x0 <- rep(0, N) itersolve(A, b, tol = 1e-8, method = "Gauss-Seidel") # [1] 1 1 1 1 1 1 1 1 1 1 # [1] 87 itersolve(A, b, x0 = 1:10, tol = 1e-8, method = "Jacobi") # [1] 1 1 1 1 1 1 1 1 1 1 # [1] 177