Question: Write a Gauss-Siedel function in python: def GaussSeidel(Aaug, x, xtol = 1e-6, maxiter = 50): Aaug: an augmented matrix contining [A | b ] having
Write a Gauss-Siedel function in python:
def GaussSeidel(Aaug, x, xtol = 1e-6, maxiter = 50):
Aaug: an augmented matrix contining [A | b ] having N rows and N+1 columns
x: a vector (array) contain the values of the initial guess
xtol: exit if the magnitude of (xnew-xold)
maxiter: exit if the number of iterations (new x vectors) equals this number
def main():
MyA = [[4, -1, -1, 3], [-2, 6, 1, 9], [-1, 1, 7, -6]] MyX = [0, 0, 0] answer = GaussSeidel(MyA, MyX, maxiter=6) print(" ", answer) answer = GaussSeidel(MyA, MyX, maxiter=15, xtol = 1e-15) print(answer) main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
