The Jacobi Method for linear system of equations

Description

MATLAB and Python code for Jacobi method :

 

Given the linear system of equations:

From the above equation, follows that:

blank

The Jacobi method is an iterative method, which starts from an initial guess for the solution

blank

Then, the solution in iteration k is used to find an approximation for the system solution in iteration k + 1. This is done as follows:

blank

Generally, the solution in iteration

blank

can be written in the form:

blank

 

The Jacobi iteration stops when,

blank

for some arbitrary blank

 


Example 2.1 Write the first three iterations of the Jacobi method, for the linear system:

blank

starting from the zeros vector

blank

 

Solution:

We write:

blank

1. First iteration k = 0:

blank

2. Second iteration k = 1:

blank

3. Third iteration k = 2:

blank


Example 2.2 The Jacobi method will be applied for solving the linear system:

blank

blank

MATLAB code :

function x = JacobiSolve(A, b, Eps)
n = length(b) ;
x0 = zeros(3, 1) ;
x = ones(size(x0)) ;
while norm(x-x0, inf) >= Eps
x0 = x ;
for i = 1 : n
x(i) = b(i) ;
for j = 1 : n
if j ~= i
x(i) = x(i) - A(i, j)*x0(j) ;
end
end
x(i) = x(i) / A(i, i) ;
end
end



Python code :

blank

 

 

Reviews

There are no reviews yet.

Be the first to review “The Jacobi Method for linear system of equations”
Categories: ,