Description
The Gauss-Seidel method is an iterative method to solve systems of linear equations. The iterative methods have the advantage over elimination method of less round-off errors.
a11x1a21x1⋮an1x1+++a12x2a22x2⋮an2x2+++⋯⋯⋯+++a1nxna2nxn⋮annxn====b1b2⋮bn Algorithm
If the diagonal elements are non-zero, each equation is rewritten for the corresponding unknown:
x1=a11b1−a12x2−a13x3−⋯−a1nxnx2=a22b2−a21x1−a23x3−⋯−a2nxn⋮xn=annbn−an1x1−an2x2−⋯−ann−1xn−1 Take an initial guess for all the xi
Use the rewritten equations to calculate the new estimates.
Calculate the relative error for each xi, if it’s small enough, the iterations stop:
∣ep∣i=∣xinewxinew−xiold∣×100