SlideShare a Scribd company logo
1 of 7
Solving System of Equations
using
Jacobi Iterative
Method
Luckshay Batra
luckybatra17@gmail.com
About the Method
The Jacobi method is a iterative method of solving the square system of linear equations. This methods
makes two assumptions (i) the system given by
has a unique solution and (ii) the coefficient matrix A has no zeros on its main diagonal, namely, a11, a22, a33
are non-zeros.
Basic Idea of the Method : In Jacobi we solve these equations for x1, x2, x3. We solve Ist equation for x1, IInd
equation for x2, ans so on to obtain the rewritten equations as :
Then make an initial guess of the solution . Substitute these values into
the right hand side the of the rewritten equations to obtain the first approximation
This accomplishes one iteration.
In the same way, the second approximation is computed by substituting the
first approximation’s x-values into the right hand side of the rewritten equations.
By repeated iterations, we form a sequence of approximations
For each generate the components generate the components of from by
for i=1,2,3,...
1
Jacobi Method in Matrix Form : Consider to solve nXn size system of linear equations Ax=b with
We split Ainto
Dx=(L+U)x+bAx=b is transformed into (D-L-U)x=b,
Assume D-1 exists and
x(k+1)=D-1(L+U)x(k)+D-1b
2
or x(k+1)=Hx(k)+c
Then, x=D-1(L+U)x+D-1b
And the matrix form of Jacobi iterative method is
where H=D-1(L+U) and c=D-1b. k=1,2,3,...
Limitation of the Method
Inflexible : For many matrices they don't converge. In general these methods are applicable only for
special matrices something like “strong diagonal" or matrices with non-zero diagonal entries. Even if
they converge, they find only one solution. Usually they perform badly for degenerate matrices (we just
learned them for regular square matrices, but again, there are generalizations).
Large Set-Up Time : The Jacobi method cannot immediately begin producing results. Before it can begin
its iteration, a matrix −D−1(L+U) must be computed. For large input matrices, this may not be a trivial
operation, as it takes O(n2) time to perform this matrix multiplication. The result is a significant lag before
any results can be output.
3
Algorithm
Step 1 : Input the coefficient matrix “A”, vector “b”, tolerance level “tol”, initial approximation “x”,
number of iterations “n”.
Step 2 :
Step 3 :
Decompose the coefficient matrix into Diagonal Matrix “D”, Lower Triangular Matrix “L” and
Upper Triangular Matrix “U”.
Calculate the values of H= −D−1(L+U) and c= D−1b.
Step 4 : For k = 1, k ≤ n, do steps 5,6,7.
Step 5 : x(k+1)=H*x(k)+cCalculate and B=max|x(k+1) - x(k)|
Step 6 :
Step 7 :
If B<tol, then
Output : “Method Successful.”
Output : “ Condition max|x(k+1) - x(k)| < tol was met after k iterations.”
Output : Solution of system of equations after k iterations.
End.
Else, calculate the next iteration k=k+1.
Step 8 : If B>tol or k>n
Output : “Maximum number of iterations reached without satisfying tolerance condition.”
Output : Value of x for k iterations performed.
4
Matlab Code
Function Code :
function jacobi(A, b,tol,x,n)
D=diag(diag(A));
L=tril(-A,-1);
U=triu(-A,1);
H=inv(D)*(L+U);
c=inv(D)*b;
k=1;
while k<=n
x(:,k+1)=H*x(:,k)+c;
B=max(abs(x(:,k+1)-x(:,k)));
if B<tol
disp('Jacobi Method was successful')
disp('Condition max|x^(k+1)-x^(k)|<tol was met after k iterations'); disp(k);
disp('x = ');disp(x(:,k+1));
break
end
k = k+1;
end
if B>tol||k>n
disp('Maximum number of iterations reached without satisfying tolerance condition:')
disp(x');
end
Program Code :
disp('Jacobi Method for Solving System of Linear Equations')
A=input('Enter the coefficient matrix A : ');
b=input('Enter the right hand side vector b : ');
tol=input('Enter tolerance level : ');
x=input('Enter initial approximation : ');
n=input('No. of iterations : ');
jacobi(A,b,tol,x,n)
Examples
1. Consider the system of equations
0.2x1 + 0.1x2 +x3 +x4 = 1
0.1x1 + 4x2 -x3 +x4- x5= 2 x1
- x2 + 60x3-2x5= 3
x1+ x2 + 8x4 +4x5=4
-x2 -2 x3 +4x4+700x5=5
with initial guess x(0)=[0000 0] T . Tolerance =0.00005
Solution in Matlab
2 4 700]
>> jacobimethodfinalinputsolve
Jacobi Method for Solving System of Linear Equations
Enter the coefficient matrix A : [0.2 0.1 1 1 0 ; 0.1 4 -1 1 -1 ; 1 -1 60 0 -2 ; 1 1 0 8 4 ; 0 -1 -
Enter the right hand side vector b : [ 1 ; 2 ; 3 ; 4 ; 5 ]
Enter tolerance level : 0.00005
Enter initial approximation : [ 0 ; 0 ; 0 ; 0 ; 0]
No. of iterations : 91
Jacobi Method was successful
Condition max|x^(k+1)-x^(k)|<tol was met after k iterations
91
x =
7.8597
0.4229
-0.0736
-0.5406
0.0106
2. Consider the system of equations
2x1 - x2 = 7
-x1 + 2x2 - x3 = 1
-x2 + 2x3 =3
with initial guess x(0)=[0 0 0] T . Tolerance = 1x10-4
Solution in Matlab
>> jacobimethodfinalinputsolve
Jacobi Method for Solving System of Linear Equations
Enter the coefficient matrix A : [2 -1 0 ; -1 2 -1 ; 0 -1 2]
Enter the right hand side vector b : [7 ; 1 ; 3]
Enter tolerance level : 0.0001
Enter initial approximation : [0 ; 0 ; 0]
No. of iterations : 100
Jacobi Method was successful
Condition max|x^(k+1)-x^(k)|<tol was met after k iterations
31
x =
6.4999
5.9998
4.4999
5
3. Consider the system of equations
2.55509x1 + 0.85822x2 + 0.92679x3 + 0.23732x4 + 0.17628x5 = 0.66360
0.38558x1 + 2.55646x2 + 0.40726x3 + 0.88843x4 + 0.89019x5 = 0.04431
0.44825x1 + 0.37596x2 + 2.21124x3 + 0.61538x4 + 0.61754x5 = 0.00939
0.53346x1 + 0.29330x2 + 0.23489x3 + 2.51195x4 + 0.57504x5 = 0.48425
0.33918x1 + 0.58728x2 + 0.93330x3 + 0.45368x4 + 2.98108x5 = 0.66024
with initial guess x(0)=[0.21771 0.08108 0.65971 0.68427 0.72107] T . Tolerance = 4x10-3
Solution in Matlab
>> jacobimethodfinalinputsolve
Jacobi Method for Solving System of Linear Equations
Enter the coefficient matrix A : [ 2.55509 0.85822 0.92679 0.23732 0.17628 ;
0.38558 2.55646 0.40726 0.88843 0.89019 ; 0.44825 0.37596 2.21124 0.61538 0.61754 ;
0.53346 0.29330 0.23489 2.51195 0.57504 ; 0.33918 0.58728 0.93330 0.45368 2.98108 ]
Enter the right hand side vector b : [0.66360 ; 0.04431; 0.00939; 0.48425; 0.66024]
Enter tolerance level : 0.00001
Enter initial approximation : [0.21771; 0.08108; 0.65971; 0.68427; 0.72107]
No. of iterations : 80
Jacobi Method was successful
Condition max|x^(k+1)-x^(k)|<tol was met after k iterations
67
x =
0.3252
-0.1265
-0.1331
0.0968
0.2363
6

More Related Content

What's hot

Finite Difference method in Strucutral Dynamics
Finite Difference method in Strucutral DynamicsFinite Difference method in Strucutral Dynamics
Finite Difference method in Strucutral DynamicsSarvesh Sureshrao Chikte
 
Interpolation In Numerical Methods.
 Interpolation In Numerical Methods. Interpolation In Numerical Methods.
Interpolation In Numerical Methods.Abu Kaisar
 
Newton divided difference interpolation
Newton divided difference interpolationNewton divided difference interpolation
Newton divided difference interpolationVISHAL DONGA
 
Numerical Methods: curve fitting and interpolation
Numerical Methods: curve fitting and interpolationNumerical Methods: curve fitting and interpolation
Numerical Methods: curve fitting and interpolationNikolai Priezjev
 
Numerical differentiation
Numerical differentiationNumerical differentiation
Numerical differentiationandrushow
 
Newtons Divided Difference Formulation
Newtons Divided Difference FormulationNewtons Divided Difference Formulation
Newtons Divided Difference FormulationSohaib H. Khan
 
Jacobi iteration method
Jacobi iteration methodJacobi iteration method
Jacobi iteration methodMONIRUL ISLAM
 
Matrices and System of Linear Equations ppt
Matrices and System of Linear Equations pptMatrices and System of Linear Equations ppt
Matrices and System of Linear Equations pptDrazzer_Dhruv
 
Differential equations of first order
Differential equations of first orderDifferential equations of first order
Differential equations of first orderUzair Saiyed
 
algebric solutions by newton raphson method and secant method
algebric solutions by newton raphson method and secant methodalgebric solutions by newton raphson method and secant method
algebric solutions by newton raphson method and secant methodNagma Modi
 
Spline Interpolation
Spline InterpolationSpline Interpolation
Spline InterpolationaiQUANT
 
Linear transformations and matrices
Linear transformations and matricesLinear transformations and matrices
Linear transformations and matricesEasyStudy3
 

What's hot (20)

Finite Difference method in Strucutral Dynamics
Finite Difference method in Strucutral DynamicsFinite Difference method in Strucutral Dynamics
Finite Difference method in Strucutral Dynamics
 
Runge Kutta Method
Runge Kutta MethodRunge Kutta Method
Runge Kutta Method
 
Euler and runge kutta method
Euler and runge kutta methodEuler and runge kutta method
Euler and runge kutta method
 
Interpolation In Numerical Methods.
 Interpolation In Numerical Methods. Interpolation In Numerical Methods.
Interpolation In Numerical Methods.
 
Newton divided difference interpolation
Newton divided difference interpolationNewton divided difference interpolation
Newton divided difference interpolation
 
Numerical Methods: curve fitting and interpolation
Numerical Methods: curve fitting and interpolationNumerical Methods: curve fitting and interpolation
Numerical Methods: curve fitting and interpolation
 
Trapezoidal rule
Trapezoidal ruleTrapezoidal rule
Trapezoidal rule
 
Newton Raphson
Newton RaphsonNewton Raphson
Newton Raphson
 
Trapezoidal rule
Trapezoidal rule Trapezoidal rule
Trapezoidal rule
 
Numerical differentiation
Numerical differentiationNumerical differentiation
Numerical differentiation
 
newton raphson method
newton raphson methodnewton raphson method
newton raphson method
 
Newtons Divided Difference Formulation
Newtons Divided Difference FormulationNewtons Divided Difference Formulation
Newtons Divided Difference Formulation
 
Jacobi iteration method
Jacobi iteration methodJacobi iteration method
Jacobi iteration method
 
Matrices and System of Linear Equations ppt
Matrices and System of Linear Equations pptMatrices and System of Linear Equations ppt
Matrices and System of Linear Equations ppt
 
Differential equations of first order
Differential equations of first orderDifferential equations of first order
Differential equations of first order
 
algebric solutions by newton raphson method and secant method
algebric solutions by newton raphson method and secant methodalgebric solutions by newton raphson method and secant method
algebric solutions by newton raphson method and secant method
 
Numerical method
Numerical methodNumerical method
Numerical method
 
Spline Interpolation
Spline InterpolationSpline Interpolation
Spline Interpolation
 
Euler's and picard's
Euler's and picard'sEuler's and picard's
Euler's and picard's
 
Linear transformations and matrices
Linear transformations and matricesLinear transformations and matrices
Linear transformations and matrices
 

Similar to Jacobi iterative method

Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab
 
Metodos jacobi y gauss seidel
Metodos jacobi y gauss seidelMetodos jacobi y gauss seidel
Metodos jacobi y gauss seidelCesar Mendoza
 
Metodos jacobi y gauss seidel
Metodos jacobi y gauss seidelMetodos jacobi y gauss seidel
Metodos jacobi y gauss seidelCesar Mendoza
 
Pydata Katya Vasilaky
Pydata Katya VasilakyPydata Katya Vasilaky
Pydata Katya Vasilakyknv4
 
Ch9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdfCh9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdfRahulUkhande
 
Gauss jordan and Guass elimination method
Gauss jordan and Guass elimination methodGauss jordan and Guass elimination method
Gauss jordan and Guass elimination methodMeet Nayak
 
4 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-24 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-2Malika khalil
 
Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Sparsh Singh
 
Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Sparsh Singh
 
Iterative methods
Iterative methodsIterative methods
Iterative methodsKt Silva
 

Similar to Jacobi iterative method (20)

Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2
 
Metodos jacobi y gauss seidel
Metodos jacobi y gauss seidelMetodos jacobi y gauss seidel
Metodos jacobi y gauss seidel
 
Metodos jacobi y gauss seidel
Metodos jacobi y gauss seidelMetodos jacobi y gauss seidel
Metodos jacobi y gauss seidel
 
Unit 4 jwfiles
Unit 4 jwfilesUnit 4 jwfiles
Unit 4 jwfiles
 
algorithm Unit 4
algorithm Unit 4 algorithm Unit 4
algorithm Unit 4
 
Pydata Katya Vasilaky
Pydata Katya VasilakyPydata Katya Vasilaky
Pydata Katya Vasilaky
 
Ch9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdfCh9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdf
 
Assignment 1
Assignment 1Assignment 1
Assignment 1
 
Gauss jordan and Guass elimination method
Gauss jordan and Guass elimination methodGauss jordan and Guass elimination method
Gauss jordan and Guass elimination method
 
Es272 ch4a
Es272 ch4aEs272 ch4a
Es272 ch4a
 
ge.ppt
ge.pptge.ppt
ge.ppt
 
4 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-24 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-2
 
Parallel algorithm in linear algebra
Parallel algorithm in linear algebraParallel algorithm in linear algebra
Parallel algorithm in linear algebra
 
AJMS_389_22.pdf
AJMS_389_22.pdfAJMS_389_22.pdf
AJMS_389_22.pdf
 
Problems 2
Problems 2Problems 2
Problems 2
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)
 
Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)
 
Iterative methods
Iterative methodsIterative methods
Iterative methods
 
Term paper
Term paperTerm paper
Term paper
 

More from Luckshay Batra

Values and ethics in mathematics
Values and ethics in mathematicsValues and ethics in mathematics
Values and ethics in mathematicsLuckshay Batra
 
Motivation in Education
Motivation in EducationMotivation in Education
Motivation in EducationLuckshay Batra
 
R Programming language model test paper
R Programming language model test paperR Programming language model test paper
R Programming language model test paperLuckshay Batra
 
Mathematica model test paper
Mathematica model test paperMathematica model test paper
Mathematica model test paperLuckshay Batra
 
Matlab-Data types and operators
Matlab-Data types and operatorsMatlab-Data types and operators
Matlab-Data types and operatorsLuckshay Batra
 
Application of laplace wave equation in music
Application of laplace wave equation in musicApplication of laplace wave equation in music
Application of laplace wave equation in musicLuckshay Batra
 

More from Luckshay Batra (12)

Values and ethics in mathematics
Values and ethics in mathematicsValues and ethics in mathematics
Values and ethics in mathematics
 
Motivation in Education
Motivation in EducationMotivation in Education
Motivation in Education
 
R Programming language model test paper
R Programming language model test paperR Programming language model test paper
R Programming language model test paper
 
Mathematica model test paper
Mathematica model test paperMathematica model test paper
Mathematica model test paper
 
Matlab-Data types and operators
Matlab-Data types and operatorsMatlab-Data types and operators
Matlab-Data types and operators
 
Black scholes model
Black scholes modelBlack scholes model
Black scholes model
 
Network flows
Network flowsNetwork flows
Network flows
 
Sas
SasSas
Sas
 
Markov chain
Markov chainMarkov chain
Markov chain
 
Cyclic group in music
Cyclic group in musicCyclic group in music
Cyclic group in music
 
Big m method
Big m methodBig m method
Big m method
 
Application of laplace wave equation in music
Application of laplace wave equation in musicApplication of laplace wave equation in music
Application of laplace wave equation in music
 

Recently uploaded

ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 

Jacobi iterative method

  • 1. Solving System of Equations using Jacobi Iterative Method Luckshay Batra luckybatra17@gmail.com
  • 2. About the Method The Jacobi method is a iterative method of solving the square system of linear equations. This methods makes two assumptions (i) the system given by has a unique solution and (ii) the coefficient matrix A has no zeros on its main diagonal, namely, a11, a22, a33 are non-zeros. Basic Idea of the Method : In Jacobi we solve these equations for x1, x2, x3. We solve Ist equation for x1, IInd equation for x2, ans so on to obtain the rewritten equations as : Then make an initial guess of the solution . Substitute these values into the right hand side the of the rewritten equations to obtain the first approximation This accomplishes one iteration. In the same way, the second approximation is computed by substituting the first approximation’s x-values into the right hand side of the rewritten equations. By repeated iterations, we form a sequence of approximations For each generate the components generate the components of from by for i=1,2,3,... 1
  • 3. Jacobi Method in Matrix Form : Consider to solve nXn size system of linear equations Ax=b with We split Ainto Dx=(L+U)x+bAx=b is transformed into (D-L-U)x=b, Assume D-1 exists and x(k+1)=D-1(L+U)x(k)+D-1b 2 or x(k+1)=Hx(k)+c Then, x=D-1(L+U)x+D-1b And the matrix form of Jacobi iterative method is where H=D-1(L+U) and c=D-1b. k=1,2,3,... Limitation of the Method Inflexible : For many matrices they don't converge. In general these methods are applicable only for special matrices something like “strong diagonal" or matrices with non-zero diagonal entries. Even if they converge, they find only one solution. Usually they perform badly for degenerate matrices (we just learned them for regular square matrices, but again, there are generalizations). Large Set-Up Time : The Jacobi method cannot immediately begin producing results. Before it can begin its iteration, a matrix −D−1(L+U) must be computed. For large input matrices, this may not be a trivial operation, as it takes O(n2) time to perform this matrix multiplication. The result is a significant lag before any results can be output.
  • 4. 3 Algorithm Step 1 : Input the coefficient matrix “A”, vector “b”, tolerance level “tol”, initial approximation “x”, number of iterations “n”. Step 2 : Step 3 : Decompose the coefficient matrix into Diagonal Matrix “D”, Lower Triangular Matrix “L” and Upper Triangular Matrix “U”. Calculate the values of H= −D−1(L+U) and c= D−1b. Step 4 : For k = 1, k ≤ n, do steps 5,6,7. Step 5 : x(k+1)=H*x(k)+cCalculate and B=max|x(k+1) - x(k)| Step 6 : Step 7 : If B<tol, then Output : “Method Successful.” Output : “ Condition max|x(k+1) - x(k)| < tol was met after k iterations.” Output : Solution of system of equations after k iterations. End. Else, calculate the next iteration k=k+1. Step 8 : If B>tol or k>n Output : “Maximum number of iterations reached without satisfying tolerance condition.” Output : Value of x for k iterations performed.
  • 5. 4 Matlab Code Function Code : function jacobi(A, b,tol,x,n) D=diag(diag(A)); L=tril(-A,-1); U=triu(-A,1); H=inv(D)*(L+U); c=inv(D)*b; k=1; while k<=n x(:,k+1)=H*x(:,k)+c; B=max(abs(x(:,k+1)-x(:,k))); if B<tol disp('Jacobi Method was successful') disp('Condition max|x^(k+1)-x^(k)|<tol was met after k iterations'); disp(k); disp('x = ');disp(x(:,k+1)); break end k = k+1; end if B>tol||k>n disp('Maximum number of iterations reached without satisfying tolerance condition:') disp(x'); end Program Code : disp('Jacobi Method for Solving System of Linear Equations') A=input('Enter the coefficient matrix A : '); b=input('Enter the right hand side vector b : '); tol=input('Enter tolerance level : '); x=input('Enter initial approximation : '); n=input('No. of iterations : '); jacobi(A,b,tol,x,n)
  • 6. Examples 1. Consider the system of equations 0.2x1 + 0.1x2 +x3 +x4 = 1 0.1x1 + 4x2 -x3 +x4- x5= 2 x1 - x2 + 60x3-2x5= 3 x1+ x2 + 8x4 +4x5=4 -x2 -2 x3 +4x4+700x5=5 with initial guess x(0)=[0000 0] T . Tolerance =0.00005 Solution in Matlab 2 4 700] >> jacobimethodfinalinputsolve Jacobi Method for Solving System of Linear Equations Enter the coefficient matrix A : [0.2 0.1 1 1 0 ; 0.1 4 -1 1 -1 ; 1 -1 60 0 -2 ; 1 1 0 8 4 ; 0 -1 - Enter the right hand side vector b : [ 1 ; 2 ; 3 ; 4 ; 5 ] Enter tolerance level : 0.00005 Enter initial approximation : [ 0 ; 0 ; 0 ; 0 ; 0] No. of iterations : 91 Jacobi Method was successful Condition max|x^(k+1)-x^(k)|<tol was met after k iterations 91 x = 7.8597 0.4229 -0.0736 -0.5406 0.0106 2. Consider the system of equations 2x1 - x2 = 7 -x1 + 2x2 - x3 = 1 -x2 + 2x3 =3 with initial guess x(0)=[0 0 0] T . Tolerance = 1x10-4 Solution in Matlab >> jacobimethodfinalinputsolve Jacobi Method for Solving System of Linear Equations Enter the coefficient matrix A : [2 -1 0 ; -1 2 -1 ; 0 -1 2] Enter the right hand side vector b : [7 ; 1 ; 3] Enter tolerance level : 0.0001 Enter initial approximation : [0 ; 0 ; 0] No. of iterations : 100 Jacobi Method was successful Condition max|x^(k+1)-x^(k)|<tol was met after k iterations 31 x = 6.4999 5.9998 4.4999 5
  • 7. 3. Consider the system of equations 2.55509x1 + 0.85822x2 + 0.92679x3 + 0.23732x4 + 0.17628x5 = 0.66360 0.38558x1 + 2.55646x2 + 0.40726x3 + 0.88843x4 + 0.89019x5 = 0.04431 0.44825x1 + 0.37596x2 + 2.21124x3 + 0.61538x4 + 0.61754x5 = 0.00939 0.53346x1 + 0.29330x2 + 0.23489x3 + 2.51195x4 + 0.57504x5 = 0.48425 0.33918x1 + 0.58728x2 + 0.93330x3 + 0.45368x4 + 2.98108x5 = 0.66024 with initial guess x(0)=[0.21771 0.08108 0.65971 0.68427 0.72107] T . Tolerance = 4x10-3 Solution in Matlab >> jacobimethodfinalinputsolve Jacobi Method for Solving System of Linear Equations Enter the coefficient matrix A : [ 2.55509 0.85822 0.92679 0.23732 0.17628 ; 0.38558 2.55646 0.40726 0.88843 0.89019 ; 0.44825 0.37596 2.21124 0.61538 0.61754 ; 0.53346 0.29330 0.23489 2.51195 0.57504 ; 0.33918 0.58728 0.93330 0.45368 2.98108 ] Enter the right hand side vector b : [0.66360 ; 0.04431; 0.00939; 0.48425; 0.66024] Enter tolerance level : 0.00001 Enter initial approximation : [0.21771; 0.08108; 0.65971; 0.68427; 0.72107] No. of iterations : 80 Jacobi Method was successful Condition max|x^(k+1)-x^(k)|<tol was met after k iterations 67 x = 0.3252 -0.1265 -0.1331 0.0968 0.2363 6