Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to solve a linear system of the form Ax = b by Gauss-Seidel iter

ID: 3794680 • Letter: W

Question

Write a program to solve a linear system of the form Ax = b by Gauss-Seidel iteration. You should pass the matrix A, solution vector b, the initial guess vector x, the size of the system x, and the relative error tolerance in the solution. Overwrite the x vector with the solution. Make sure you have a bound on the number of iterations and return an informative message if the maximum number of iterations has been exceeded. Return the solution and the number of iterations it took to converge. Test your program on the system in exercise #7 above to verify the accuracy of your code. Run your program on the system of equations 9x_1 - 3x_2 = 6 -2x_1 + 8x_2 = -4 with starting vector x = (0 0)^T. Change the coefficient of in the first equation from 9 to 1 see what happens to your program.

Explanation / Answer

Gauss-Seidel

The Gauss-Seidel method is a technique for solving the n equations of the linear system of equations Ax=b one at a time in sequence, and uses previously computed results as soon as they are available,

There are two important characteristics of the Gauss-Seidel method should be noted. Firstly, the computations appear to be serial. Since each component of the new iterate depends upon all previously computed components, the updates cannot be done simultaneously as in the Jacobi method. Secondly, the new iterate x^((k)) depends upon the order in which the equations are examined. If this ordering is changed, the components of the new iterates (and not just their order) will also change.

Code(python 3.5):

from copy import copy, deepcopy

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote