# Matlab Gauss Seidel Code for Solving Linear System of Equations

by admin in Linear System of Equations , Math, Statistics, and Optimization , MATLAB Family on April 11, 2019This code solves system of linear equations with n variable using Gauss-Seidel method. The results are the Roots value with the accuracy (residual) for each and the total number of iterations. A chart for the roots value convergence will be presented at the end of the calculation. You just need to write your Coefficient Matrix A and Right-Hand-Side column B. There is ability to change the number of iterations, reference accuracy, and the initial value.

**Gauss–Seidel method** (**Liebmann method** or the **method of successive displacement)**, is an iterative method used to solve a linear system of equations. It is named after the German mathematicians Carl Friedrich Gauss and Philipp Ludwig von Seidel, and is similar to the Jacobi method. Though it can be applied to any matrix with non-zero elements on the diagonals, convergence is only guaranteed if the matrix is either diagonally dominant, or symmetric and positive definite.

#### Method Description:

The Gauss–Seidel method is an iterative technique for solving a square system of *n* linear equations with unknown **x**:

It is defined by the iteration

where **x^k** is the ** kth** approximation or iteration of

**x, x^(k+1)**is the next or

**iteration of**

*k*+ 1**x**, and the matrix

**is decomposed into a lower triangular component**

*A***L***, and a strictly upper triangular component

**:**

*U*In more detail, write out ** A**,

**x**and

**b**in their components:

Then the decomposition of ** A** into its lower triangular component and its strictly upper triangular component is given by:

The system of linear equations may be rewritten as:

The Gauss–Seidel method now solves the left hand side of this expression for **x**, using previous value for **x** on the right hand side. Analytically, this may be written as:

However, by taking advantage of the triangular form of **L***, the elements of **x**^{(k+1)} can be computed sequentially using forward substitution:

^{}

The procedure is generally continued until the changes made by an iteration are below some tolerance, such as a sufficiently small residual.

Share Now!