Iterative Methods
Iterative solutions of systems of linear equations.
itersolve(A, b, x0 = NULL, nmax = 1000, tol = .Machine$double.eps^(0.5), method = c("Gauss-Seidel", "Jacobi", "Richardson"))
A |
numerical matrix, square and non-singular. |
b |
numerical vector or column vector. |
x0 |
starting solution for iteration; defaults to null vector. |
nmax |
maximum number of iterations. |
tol |
relative tolerance. |
method |
iterative method, Gauss-Seidel, Jacobi, or Richardson. |
Iterative methods are based on splitting the matrix A=(P-A)-A
with a so-called ‘preconditioner’ matrix P. The methods differ in how
to choose this preconditioner.
Returns a list with components x
the solution, iter
the
number of iterations, and method
the name of the method applied.
Richardson's method allows to specify a ‘preconditioner’; this has not been implemented yet.
Quarteroni, A., and F. Saleri (2006). Scientific Computing with MATLAB and Octave. Springer-Verlag, Berlin Heidelberg.
N <- 10 A <- Diag(rep(3,N)) + Diag(rep(-2, N-1), k=-1) + Diag(rep(-1, N-1), k=1) b <- A %*% rep(1, N) x0 <- rep(0, N) itersolve(A, b, tol = 1e-8, method = "Gauss-Seidel") # [1] 1 1 1 1 1 1 1 1 1 1 # [1] 87 itersolve(A, b, x0 = 1:10, tol = 1e-8, method = "Jacobi") # [1] 1 1 1 1 1 1 1 1 1 1 # [1] 177
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.