Gauss-Seidel Method

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.

a11x1+a12x2++a1nxn=b1a21x1+a22x2++a2nxn=b2=an1x1+an2x2++annxn=bn\begin{matrix} a_{11}x_1 & + & a_{12}x_2 & + & \cdots & + & a_{1n}x_n & = & b_1 \\ a_{21}x_1 & + & a_{22}x_2 & + & \cdots & + & a_{2n}x_n & = & b_2 \\ \vdots & & \vdots & & & & \vdots & = & \vdots \\ a_{n1}x_1 & + & a_{n2}x_2 & + & \cdots & + & a_{nn}x_n & = & b_n \end{matrix}

Algorithm

  1. If the diagonal elements are non-zero, each equation is rewritten for the corresponding unknown:

    x1=b1a12x2a13x3a1nxna11x2=b2a21x1a23x3a2nxna22xn=bnan1x1an2x2ann1xn1ann\begin{aligned} x_1 = \frac{b_1 − a_{12}x_2 − a_{13}x_3 - \cdots − a_{1n}x_n}{a_{11}} \\ x_2 = \frac{b_2 − a_{21}x_1 − a_{23}x_3 - \cdots - a_{2n}x_n}{a_{22}} \\ \vdots \\ x_n = \frac{b_n − a_{n1}x_1 − a_{n2}x_2 − \cdots − a_{nn−1}x_{n−1}}{a_{nn}} \end{aligned}
  2. Take an initial guess for all the xix_i

  3. Use the rewritten equations to calculate the new estimates.

  4. Calculate the relative error for each xix_i, if it’s small enough, the iterations stop:

    epi=xinewxioldxinew×100|ep|_i= ∣\frac{x^{new}_i − x^{old}_i}{x^{new}_i}∣ \times 100

Calculator

Initial approximations