MATLAB HW HELP:
Consider the following linear system of equations AX=B:
[8 1 3; 2 0 5; 1 7 3]*[x_1; x_2; x_3] = [1; 4; -1]
(a) Solve the system using Gauss Seidel method (solve by hand). At
each step, calculate the
relative norm of the residuals (||r^(k)|| / ||B||) and stop
when it reaches a tolerance of 0.1.
a) Modify the Gauss-Seidel function you completed in Lab 6
Assignment, such that the
function will first checks if the diagonal entries are zero. If
needed, the function will
swap the row that has a zero diagonal element with the next
suitable row in A such that a
matrix with non-zero diagonal elements is obtained. The function
needs to record the
swapping process by creating a permutation matrix, P. Subsequently,
your function will
start to solve the system using Gauss-Seidel. In addition to the
maximum number of
iterations, your function will also get tolerance as input:
- Inputs of your function: A, B, initial guess for X, tolerance,
maximum number of
iterations
- Output of your function: numerical solution for X
b) Use your function from Part (a) to solve the above system. Set
the tolerance for relative
norm of residuals to 0.01. Report the following:
- In a PDF file report the number of iterations needed to reach
this accuracy, and
output of your code for solution X.
- Your MATLAB code in .m or .mlx format
Problem 1) Consider the following linear system of equations AX=B: 18 2 1 1 0 7 31 [X1 x2 = 3) (X3. 4 || B (a) Solve the system using Gauss Seidel method (solve by hand). At each step, calculate the relative norm of the residuals (Locom) and stop when it reaches a tolerance of 0.1. a) Modify the Gauss-Seidel function you completed in Lab 6 Assignment, such that the function will first checks if the diagonal entries are zero. If needed, the function will swap the row that has a zero diagonal element with the next suitable row in A such that a matrix with non-zero diagonal elements is obtained. The function needs to record the swapping process by creating a permutation matrix, P. Subsequently, your function will start to solve the system using Gauss-Seidel. In addition to the maximum number of iterations, your function will also get tolerance as input: Inputs of your nction: A, B, initial guess for X, tolerance, maximum number of iterations Output of your function: numerical solution for X b) Use your function from Part (a) to solve the above system. Set the tolerance for relative norm of residuals to 0.01. Report the following: In a PDF file report the number of iterations needed to reach this accuracy, and output of your code for solution X. Your MATLAB code in .m or .mlx format
MATLAB HW HELP: Consider the following linear system of equations AX=B: [8 1 3; 2 0 5; 1 7 3]*[x_1; x_2; x_3] = [1; 4; -
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am