Learn R Programming

Matrix (version 0.3-8)

solve.Matrix: Solve a System of Equations

Description

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

Usage

solve(a, b, tol = 0, transpose = FALSE)

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 the reciprocal condition estimate. If tol is negative, no condition estimation is done. Otherwise the reciprocal one norm condition estimate is computed and the solution is attempted only when it is great
transpose
a logical value. If TRUE, the system to be solved is defined by the transpose of a. The default is FALSE, for which the system to be solved is defined by a.

See Also

rcond.Matrix

Examples

Run this code
h8 <- hilbert(8); round(h8, 4)
solve(h8)
solve(h8, diag(8)) # similar result but not necessarily Hermitian
Hermitian.test(solve(h8))
Hermitian.test(solve(h8, diag(8)))

Run the code above in your browser using DataLab