An iterative method to solve the linear system A x = b starts with an initial approximation p0 to the solution x and generates a sequence of vectors \( \left\{ {\bf p}_k \right\}_{k\ge 0} \) that converges to x. Iterative methods involve a process that converts the system A x = b into an equivalent system of the form x = B x + w, for some fixed matrix B and vector b. After the initial vector p0 is selected, the sequence of approximate solutions is generated by computing \( {\bf x}^{(k+1)} = {\bf B}\,{\bf x}^{(k)} + {\bf b} , \) for each \( k =0,1,2,\ldots . \)
For large systems containing thousands of equations, iterative methods often have decisive advantages over direct methods in terms of speed and demands on computer memory. Sometimes, if the accuracy requirements are not stringent, a modest number of iterations will suffice to produce an acceptable solution. Also, iterative methods are often very efficient for sparse systems problems. In sparse problems, the nonzero elements of A are sometimes stored in a sparse-storage format. In other case, it is not necessary to store A at all; for example, in problems involving the numerical solution of partial differential equations as, in this case, each row of A might be generated as needed but not retained after use. Another important advantage of iterative methods is that they are usually stable, and they will actually dampen errors, due to roundoff or minor blunders, as the process continues.
We consider some iterative methods for solving linear and nonlinear vector equations. We start with an extension of fixed-point iteration that applies to systems of linear equations.Example. Consider the system of equations
i | x_i | y_i | z_i |
0 | 2 | 1 | 0 |
1 | 2.75 | 1.875 | 0.4 |
2 | 3.0875 | 1.8375 | 0.9 |
3 | 2.94375 | 1.94062 | 0.9525 |
4 | 2.98219 | 1.99625 | 0.965 |
5 | 3.00688 | 1.99133 | 0.994938 |
6 | 2.99693 | 1.99638 | 0.997906 |
7 | 2.99871 | 1.99998 | 0.997939 |
8 | 3.00051 | 1.99955 | 0.999736 |
9 | 2.99984 | 1.99977 | 0.999921 |
10 | 2.99991 | 2.00001 | 0.999878 |
This process is called Jacobi iteration and can be used to solve certain types of linear systems. it is named after the German mathematician Carl Gustav Jacob Jacobi (1804--1851), who made fundamental contributions to elliptic functions, dynamics, differential equations, and number theory. His first name is sometimes given as Karl and he was the first Jewish mathematician to be appointed professor at a German university.
Linear systems with as many as 100,000 or more variables often arise in the solutions of partial differential equations (Chapter 7). The coefficient matrices for these systems are sparse; that is, a large percentage of the entries of the coefficient matrix are zero. An iterative process provides an efficient method for solving these large systems.
Sometimes the Jacobi mathod does not work. Let us experiment with the following system of equations.
Example. Consider the system of equations
i | x_i | y_i | z_i |
0 | 2 | 1 | 0 |
1 | 4.5 | -1 | -6 |
2 | 15.5 | -36 | 2.5 |
3 | -19 | -15.5 | -12.5 |
4 | 21.25 | -21.5 | -144. |
5 | 281.25 | -759.5 | 45.25 |
6 | -466.25 | -333.25 | -130.75 |
7 | 98.875 | 281.75 | -3015.75 |
8 | 6176.38 | -15273.5 | 1039.88 |
9 | -9712.5 | -7150.38 | 316.875 |
10 | -4204.94 | 21012.4 | 62881.3 |
The last example shows that we need some criterion to determine whether the Jacobi iteration will converge. Hence, we make the following definition.
A square matrix A of dimensions \( n \times n \) is said to be strictly diagonally dominated provided that
Theorem (Jacobi iteration): Suppose that A is a strictly diagonally dominant matrix. Then A x = b has a unique solution x = p. Iteration using Jacobi formula
This formula can written in compact matrix form:
function x1 = jacobi1(a,b,x0,tol)
n = length(b);
x = zeros(n,1);
for j = 1 : n
x(j) = ((b(j) - a(j,[1:j-1,j+1:n]) * x0([1:j-1,j+1:n])) / a(j,j)); % the first iteration
end
x1 = x';
k = 1;
x_ny = zeros(n,1);
while norm(x1-x0,1) > tol
for j = 1 : n
x_ny(j) = ((b(j) - a(j,[1:j-1,j+1:n]) * x1([1:j-1,j+1:n])) / a(j,j));
end
x0 = x1;
x1 = x_ny';
k = k + 1;
end
k
x = x1';
Here is another matlab version to solve the linear system A x = b by starting with an initial guess \( {\bf x} = {\bf p}_0 \) and generating a sequence \( \left\{ {\bf p}_k \right\}_{k\ge 0} \) that converges to the solution. A sufficient condition for the method to be applicable is that A is strictly diagonally dominant.
function = jacobi(A,b,p,delta,max1)
% Input: A is an n x n nonsingular matrix
% b is an n x 1 matrix (= n-vector)
% p is an n x 1 matrix: the initial guess of column-vector
% delta is the tolerance for p
% max1 is the maximum number of iterations
% Output: x is an n x 1 matrix (= column vector); the Jacobi approximation
n = length(b);
for k=1:max1
for j=1:n
x(j)=(b(j)-A(j,[1:j-1,j+1:n])*p([1:j-1,j+1:n]))/A(j,j);
end
err=abs(norm(x'-p));
relerr=err/(norm(x) +eps);
p=x';
if(err < delta)|(relerr < delta)
break
end
end
x=x';
Example. The system of equations
k | x_k | y_k | z_k |
0 | 2 | 1 | 0 |
1 | 2.75 | 1.6875 | 0.825 |
2 | 2.8875 | 1.9625 | 0.9625 |
3 | 2.99063 | 1.98828 | 0.993438 |
4 | 2.99578 | 1.99859 | 0.998594 |
5 | 2.99965 | 1.99956 | 0.999754 |
6 | 2.99984 | 1.99995 | 0.999947 |
7 | 2.99999 | 1.99995 | 0.999947 |
8 | 2.99999 | 1.99998 | 0.999991 |
9 | 3. | 2. | 1. |
10 | 3. | 2. | 1. |
We now generalize the Gauss-Seidel iteration procedure. Suppose we are given the linear system
We present matlab code to solve the linear system A x = b by starting with the initial guess \( {\bf x} = {\bf p}_0 \) and generating a sequence \( \left\{ {\bf p}_k \right\}_{k\ge 0} \) that converges to the solution. A sufficient condition for the method to be applicble is that A is either strictly diagonal dominant or symmetric and positive definite.
function = gseidel(A,b,p,delta,max1)
% Input: A is an n x n nonsingular matrix
% b is an n x 1 matrix (= n-column vector)
% p is an n x 1 matrix: the initial guess of column-vector
% delta is the tolerance for p
% max1 is the maximum number of iterations
% Output: x is an n x 1 matrix (= column vector); the Gauss-Seidel approximation
n = length(b);
for k=1:max1
for j=1:n
if j==1
x(1)=(b(1)-A(1,2:n)*p(2:n))/A(1,1);
elseif j==n
x(n)=(b(n)-A(n,1:n-1)*x(1:n-1))' /A(n,n);
else
x(j)=(b(j)-A(j,1:j-1)*x(1:j-1) - A(j,j+1:n)*p(j+1:n))/A(j,j);
end
end
err=abs(norm(x'-p));
relerr=err/(norm(x) +eps);
p=x';
if(err < delta)|(relerr < delta)
break
end
end
x=x';
We can write the Gauss-Seidel equation as
Complete