MATLAB Function Reference | Search  Help Desk |
bicgstab | Examples See Also |
BiConjugate Gradients Stabilized method
x = bicgstab(A,b) bicgstab(A,b,tol) bicgstab(A,b,tol,maxit) bicgstab(A,b,tol,maxit,M) bicgstab(A,b,tol,maxit,M1,M2) bicgstab(A,b,tol,maxit,M1,M2,x0) x = bicgstab(A,b,tol,maxit,M1,M2,x0) [x,flag] = bicgstab(A,b,tol,maxit,M1,M2,x0) [x,flag,relres] = bicgstab(A,b,tol,maxit,M1,M2,x0) [x,flag,relres,iter] = bicgstab(A,b,tol,maxit,M1,M2,x0) [x,flag,relres,iter,resvec] = bicgstab(A,b,tol,maxit,M1,M2,x0)
x = bicgstab(A,b)
attempts to solve the system of linear equations A*x = b
for x
. The coefficient matrix A
must be square and the right hand side (column) vector b
must have length n
, where A
is n
-by-n
. bicgstab
will start iterating from an initial estimate that by default is an all zero vector of length n
. Iterates are produced until the method either converges, fails, or has computed the maximum number of iterations. Convergence is achieved when an iterate x
has relative residual norm(b-A*x)/norm(b)
less than or equal to the tolerance of the method. The default tolerance is 1e-6
. The default maximum number of iterations is the minimum of n
and 20. No preconditioning is used.
bicgstab(A,b,tol)
specifies the tolerance of the method, tol
.
bicgstab(A,b,tol,maxit)
additionally specifies the maximum number of iterations, maxit
.
bicgstab(A,b,tol,maxit,M) and bicgstab(A,b,tol,maxit,M1,M2)
use left preconditioner M
or M = M1*M2
and effectively solve the system inv(M)*A*x = inv(M)*b
for x
. If M1
or M2
is given as the empty matrix ([]
), it is considered to be the identity matrix, equivalent to no preconditioning at all. Since systems of equations of the form M*y = r
are solved using backslash within bicgstab, it is wise to factor preconditioners into their LU factors first. For example, replace bicgstab(A,b,tol,maxit,M) with:
[M1,M2] = lu(M); bicgstab(A,b,tol,maxit,M1,M2).
bicgstab(A,b,tol,maxit,M1,M2,x0)
specifies the initial estimate x0.
If x0
is given as the empty matrix ([])
, the default all zero vector is used.
x = bicgstab(A,b,tol,maxit,M1,M2,x0)
returns a solution x
. Ifbicgstab
converged, a message to that effect is displayed. If bicgstab
failed to converge after the maximum number of iterations or halted for any reason, a warning message is printed displaying the relative residual norm(b-A*x)/norm(b)
and the iteration number at which the method stopped or failed.
[x,flag] = bicgstab(A,b,tol,maxit,M1,M2,x0)
returns a solution x
and a flag that describes the convergence of bicgstab
: flag
is not 0
, the solution x
returned is that with minimal norm residual computed over all the iterations. No messages are displayed if the flag
output is specified.
[x,flag,relres] = bicgstab(A,b,tol,maxit,M1,M2,x0)
also returns the relative residual norm(b-A*x)/norm(b)
. If flag
is 0
, then relres tol.
[x,flag,relres,iter] = bicgstab(A,b,tol,maxit,M1,M2,x0)
also returns the iteration number at which x
was computed. This always satisfies 0
iter
maxit
. iter
may be an integer or an integer + 0.5, since bicgstab
may converge half way through an iteration.
[x,flag,relres,iter,resvec] = bicgstab(A,b,tol,maxit,M1,M2,x0)
also returns a vector of the residual norms at each iteration, starting fromresvec(1) = norm(b-A*x0)
. If flag
is 0
, res
vec is of length 2*iter+1
, whether iter
is an integer or not. In this case, resvec(end)
tol*norm(b)
.
load west0479 A = west0479 b = sum(A,2) [x,flag] = bicgstab(A,b)
flag
is 1
since bicgstab
will not converge to the default tolerance 1e-6
within the default 20 iterations.
[L1,U1] = luinc(A,1e-5) [x1,flag1] = bicgstab(A,b,1e-6,20,L1,U1)
flag1
is 2 since the upper triangular U1
has a zero on its diagonal so bicgstab
fails in the first iteration when it tries to solve a system such as U1*y = r
with backslash.
[L2,U2] = luinc(A,1e-6) [x2,flag2,relres2,iter2,resvec2] = bicgstab(A,b,1e-15,10,L2,U2)
flag2
is 0
since bicgstab
will converge to the tolerance of 2.9e-16
(the value of relres2
) at the sixth iteration (the value of iter2
) when preconditioned by the incomplete LU factorization with a drop tolerance of 1e-6
. resvec2(1) = norm(b)
and resvec2(7) = norm(b-A*x2)
. You may follow the progress of bicgstab
by plotting the relative residuals at the half way point and end of each iteration starting from the intial estimate (iterate number 0) with semilogy(0:0.5:iter2,resvec2/norm(b),'-o')
bicg
BiConjugate Gradients method
cgs
Conjugate Gradients Squared method
gmres
Generalized Minimum Residual method (with restarts)
luinc
Incomplete LU matrix factorizations
pcg
Preconditioned Conjugate Gradients method
qmr
Quasi-Minimal Residual method
\
Matrix left division