This help topic is for R version 1.5.0. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/solve.html
solve {base}R Documentation

Solve a System of Equations

Description

This generic function solves the equation a %*% x = b for x, where b can be either a vector or a matrix.

Usage

## Default S3 method:
solve(a, b, tol = 1e-7, ...)

Arguments

a

a numeric matrix containing the coefficients of the linear system.

b

a numeric vector or matrix giving the right-hand side(s) of the linear system. If omitted, b is taken to be an identity matrix and solve will return the inverse of a.

tol

the tolerance for detecting linear dependencies in the columns of a.

...

further arguments passed to or from other methods

Details

As from R version 1.3.0, a or b can be complex, in which case LAPACK routine ZESV is used. This uses double complex arithmetic which might not beavailable on all platforms.

See Also

backsolve, qr.solve.

Examples

hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") }
h8 <- hilbert(8); h8
## Not run: solve(h8) # gives error: `singular'
sh8 <- solve(h8, tol = 1e-10)
round(sh8 %*% h8, 3)

A <- hilbert(4)
A[] <- as.complex(A)
## might not be supported on all platforms
try(solve(A))

[Package base version 1.5.0 ]