Jacobi method

Jacobi method of solution of system of equations
1 Download
Updated 10 Apr 2025

View License

Jacobi method of solution of system of equations
We can express linear equations in matrix form A*X=B ...... (i)
where A is called Coefficient matrix and B Right hand side vector.
Now, decomposing the matrix A into its diagonal and unondiagonal component,
we get:
A = D + R, where
Further, the system of linear equations (i) can be expressed as:
(D+R)*X = B
or D*X + R*X = B
or X = inv(D)*B – inv(D)*R*X –(ii)
In Gauss-Seidel method, the equation (ii) is solved iteratively by solving the left hand value of x and then using previously found x on right hand side. Mathematically, the iteration process in Gauss-Seidel method can be expressed as:
X(n+1) = inv(D)*B – inv(D)*R*X(n) or inv(D)*(B – R*X(n) )
Note : The matrix should be diagonally dominant matrix.
Example : Solve using Jacobi method:
10x1 -x2+ 2x3 = 6
-x1 + 11x2 - x3 +3x4 = 25
2x1 - x2+ 10x3 -x4 = -11
3x2 - x3 + 8x4 = 15
Solution: The equation can be written as, A*X = B where
Decomposing A = D+R
Enter Coefficient Matrix A :[10 -1 2 0;-1 11 -1 3; 2 -1 10 -1;0 3 -1 8]
Enter RHS Matrix B :[6 25 -11 15]'
Enter no of iteration : 20
D =
10 0 0 0
0 11 0 0
0 0 10 0
0 0 0 8
R =
0 -1 2 0
-1 0 -1 3
2 -1 0 -1
0 3 -1 0
X =
Columns 1 through 6
0 0.6000 1.0473 0.9326 1.0152 0.9890
0 2.2727 1.7159 2.0533 1.9537 2.0114
0 -1.1000 -0.8052 -1.0493 -0.9681 -1.0103
0 1.8750 0.8852 1.1309 0.9738 1.0214
Columns 7 through 12
1.0032 0.9981 1.0006 0.9997 1.0001 0.9999
1.9922 2.0023 1.9987 2.0004 1.9998 2.0001
-0.9945 -1.0020 -0.9990 -1.0004 -0.9998 -1.0001
0.9944 1.0036 0.9989 1.0006 0.9998 1.0001
Columns 13 through 18
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
2.0000 2.0000 2.0000 2.0000 2.0000 2.0000
-1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
Columns 19 through 20
1.0000 1.0000
2.0000 2.0000
-1.0000 -1.0000
1.0000 1.0000
Here, we see that we get solution from 13th iteration onwards.

Cite As

Langel Thangmawia (2025). Jacobi method (https://www.mathworks.com/matlabcentral/fileexchange/180737-jacobi-method), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2024b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.1

Explaination and example added

1.0.0