Previous Up Next

5.61.8  Solving a linear system using the Gauss-Seidel iteration method: gauss_seidel_linsolve

The gauss_seidel_linsolve command takes two mandatory arguments and two optional arguments. The mandatory arguments are the matrix of coefficients of a system and the right hand side of the system as a list. The optional arguments are a positive number indicating the error tolerance (by default epsilon) and an integer indicating the maximum number of iterations (by default maxiter).
jacobi_linsolve uses the Gauss-Seidel iteration method to solve and return the solution of the system.
Input:

A:=[[100,2],[2,100]];
gauss_seidel_linsolve(A,[0,1],1e-12);

Output:

[-0.000200080032013,0.0100040016006]

Additionally, gauss_seidel_linsolve can take an optional first argument (by default 1) of ω used for a general form of the Gauss-Seidel method (the successive overrelaxation method).
Input:

gauss_seidel_linsolve (1.5, A, [0,1], 1e-12);

Output:

[-0.000200080032218,0.0100040016006]

Previous Up Next