Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

itersolve

Iterative Methods


Description

Iterative solutions of systems of linear equations.

Usage

itersolve(A, b, x0 = NULL, nmax = 1000, tol = .Machine$double.eps^(0.5),
            method = c("Gauss-Seidel", "Jacobi", "Richardson"))

Arguments

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.

Details

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.

Value

Returns a list with components x the solution, iter the number of iterations, and method the name of the method applied.

Note

Richardson's method allows to specify a ‘preconditioner’; this has not been implemented yet.

References

Quarteroni, A., and F. Saleri (2006). Scientific Computing with MATLAB and Octave. Springer-Verlag, Berlin Heidelberg.

See Also

Examples

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

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.