Responsive Navbar with Google Search
Solve Linear Equations: Gauss-Seidel Method
Python runs in your browser. Heavy or infinite loops may freeze your browser tab. Use "Stop" if needed; for heavy jobs, run locally.
Program 1

Gauss-Seidel Method

Solve the following system of linear equations using the Gauss-Seidel method until convergence to a tolerance of 0.00001. Use initial guesses \( x = 0, y = 0, z = 0 \). Input the augmented matrix (coefficients and constants) in a single array.

Solve the following system of linear equations

\( 4x - y + z = 15 \)

\( -x + 4y - z = 10 \)

\( 2x - y + 3z = 10 \)

Output 1

Algorithm:

Initial Guess:

Start with an initial guess for the unknowns (in this case, \( x = y = z = 0 \)).

Iteratively Solve for Each Variable:

Use the current or updated values of the variables as soon as they are available.

From the system:

\( x^{(k+1)} = \frac{1}{4} (15 + y^{(k)} - z^{(k)}) \)

\( y^{(k+1)} = \frac{1}{4} (10 + x^{(k+1)} + z^{(k)}) \)

\( z^{(k+1)} = \frac{1}{3} (10 - 2x^{(k+1)} + y^{(k+1)}) \)

Convergence Check:

Stop when the difference between consecutive values of \( x \), \( y \), and \( z \) is less than a predefined tolerance (e.g., \( 10^{-5} \)).

Program 2

Gauss-Seidel Method

Gauss-Seidel Iterative Method Problem

Solve the following system of linear equations using the Gauss-Seidel method:

\[ \begin{cases} 10x_1 - x_2 + 2x_3 = 6 \\ -x_1 + 11x_2 - x_3 + 3x_4 = 25 \\ 2x_1 - x_2 + 10x_3 - x_4 = -11 \\ 3x_2 - x_3 + 8x_4 - 2x_5 = 15 \\ -2x_4 + 6x_5 = 10 \end{cases} \]

Use the following specifications for the iterative solution:

  • Initial guess: \(x_1 = x_2 = x_3 = x_4 = x_5 = 0\)
  • Convergence tolerance: \(10^{-5}\)
  • Maximum iterations: 1000

Compute the solution vector \(\mathbf{x} = [x_1, x_2, x_3, x_4, x_5]^T\) using the Gauss-Seidel iteration and verify it using a direct solver.

Algorithm:

  • A = Coefficient matrix
  • B = Right-hand side constants
  • We start with all zeros as initial guesses.
  • For each iteration:
    • Each unknown is updated using the latest available values.
    • The formula used is:

    \( x_i = \frac{B_i - \sum_{j \neq i} a_{ij} x_j}{a_{ii}} \)

  • The process repeats until the change is smaller than the tolerance.
  • Output 2
    Program 3

    Gauss-Seidel Method

    Gauss-Seidel Iterative Method Problem

    Solve the following system of linear equations using the Gauss-Seidel method:

    \[ \begin{cases} 10x_1 - x_2 + 2x_3 = 6 \\ -x_1 + 11x_2 - x_3 + 3x_4 = 25 \\ 2x_1 - x_2 + 10x_3 - x_4 = -11 \\ 3x_2 - x_3 + 8x_4 - 2x_5 = 15 \\ -2x_4 + 6x_5 = 10 \end{cases} \]

    Use the following specifications for the iterative solution:

    • Initial guess: \(x_1 = x_2 = x_3 = x_4 = x_5 = 0\)
    • Convergence tolerance: \(10^{-5}\)
    • Maximum iterations: 1000

    Compute the solution vector \(\mathbf{x} = [x_1, x_2, x_3, x_4, x_5]^T\) using the Gauss-Seidel iteration and verify it using a direct solver.

    Alternate Method using Numpy Array Slice.

    Output 3