Minimum residual method
x = minres(A,b)
minres(A,b,tol)
minres(A,b,tol,maxit)
minres(A,b,tol,maxit,M)
minres(A,b,tol,maxit,M1,M2)
minres(A,b,tol,maxit,M1,M2,x0)
[x,flag] = minres(A,b,...)
[x,flag,relres] = minres(A,b,...)
[x,flag,relres,iter] = minres(A,b,...)
[x,flag,relres,iter,resvec] = minres(A,b,...)
[x,flag,relres,iter,resvec,resveccg]
= minres(A,b,...)
x = minres(A,b)
attempts
to find a minimum norm residual solution x
to the
system of linear equations A*x=b
. The n
byn
coefficient
matrix A
must be symmetric but need not be positive
definite. It should be large and sparse. The column vector b
must
have length n
. You can specify A
as
a function handle, afun
, such that afun(x)
returns A*x
.
Parameterizing Functions explains how to provide additional
parameters to the function afun
, as well as the
preconditioner function mfun
described below, if
necessary.
If minres
converges, a message to that effect
is displayed. If minres
fails to converge after
the maximum number of iterations or halts for any reason, a warning
message is printed displaying the relative residual norm(bA*x)/norm(b)
and
the iteration number at which the method stopped or failed.
minres(A,b,tol)
specifies
the tolerance of the method. If tol
is []
,
then minres
uses the default, 1e6
.
minres(A,b,tol,maxit)
specifies
the maximum number of iterations. If maxit
is []
,
then minres
uses the default, min(n,20)
.
minres(A,b,tol,maxit,M)
and minres(A,b,tol,maxit,M1,M2)
use
symmetric positive definite preconditioner M
or M
= M1*M2
and effectively solve the system inv(sqrt(M))*A*inv(sqrt(M))*y
= inv(sqrt(M))*b
for y
and then return x
= inv(sqrt(M))*y
. If M
is []
then minres
applies
no preconditioner. M
can be a function handle mfun
,
such that mfun(x)
returns M\x
.
minres(A,b,tol,maxit,M1,M2,x0)
specifies
the initial guess. If x0
is []
,
then minres
uses the default, an allzero vector.
[x,flag] = minres(A,b,...)
also
returns a convergence flag.
Flag  Convergence 





 Preconditioner 


 One of the scalar quantities calculated during 
Whenever 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] = minres(A,b,...)
also
returns the relative residual norm(bA*x)/norm(b)
.
If flag
is 0
, relres <= tol
.
[x,flag,relres,iter] = minres(A,b,...)
also
returns the iteration number at which x
was computed,
where 0 <= iter <= maxit
.
[x,flag,relres,iter,resvec] = minres(A,b,...)
also
returns a vector of estimates of the minres
residual
norms at each iteration, including norm(bA*x0)
.
[x,flag,relres,iter,resvec,resveccg]
= minres(A,b,...)
also returns a vector of estimates of
the Conjugate Gradients residual norms at each iteration.
n = 100; on = ones(n,1); A = spdiags([2*on 4*on 2*on],1:1,n,n); b = sum(A,2); tol = 1e10; maxit = 50; M1 = spdiags(4*on,0,n,n); x = minres(A,b,tol,maxit,M1); minres converged at iteration 49 to a solution with relative residual 4.7e014
This example replaces the matrix A
in the
previous example with a handle to a matrixvector product function afun
.
The example is contained in a file run_minres
that
Calls minres
with the function
handle @afun
as its first argument.
Contains afun
as a nested function,
so that all variables in run_minres
are available
to afun
.
The following shows the code for run_minres
:
function x1 = run_minres n = 100; on = ones(n,1); A = spdiags([2*on 4*on 2*on],1:1,n,n); b = sum(A,2); tol = 1e10; maxit = 50; M = spdiags(4*on,0,n,n); x1 = minres(@afun,b,tol,maxit,M); function y = afun(x) y = 4 * x; y(2:n) = y(2:n)  2 * x(1:n1); y(1:n1) = y(1:n1)  2 * x(2:n); end end
When you enter
x1=run_minres;
MATLAB^{®} software displays the message
minres converged at iteration 49 to a solution with relative residual 4.7e014
Use a symmetric indefinite matrix that fails with pcg
.
A = diag([20:1:1, 1:1:20]); b = sum(A,2); % The true solution is the vector of all ones. x = pcg(A,b); % Errors out at the first iteration.
displays the following message:
pcg stopped at iteration 1 without converging to the desired tolerance 1e006 because a scalar quantity became too small or too large to continue computing. The iterate returned (number 0) has relative residual 1
However, minres
can handle the indefinite
matrix A
.
x = minres(A,b,1e6,40); minres converged at iteration 39 to a solution with relative residual 1.3e007
[1] Barrett, R., M. Berry, T. F. Chan, et al., Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods, SIAM, Philadelphia, 1994.
[2] Paige, C. C. and M. A. Saunders, "Solution of Sparse Indefinite Systems of Linear Equations." SIAM J. Numer. Anal., Vol.12, 1975, pp. 617629.