Rev 47262 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/solve.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2007 R Core Development Team% Distributed under GPL 2 or later\name{solve}\title{Solve a System of Equations}\usage{solve(a, b, \dots)\method{solve}{default}(a, b, tol, LINPACK = FALSE, \dots)}\alias{solve}\alias{solve.default}\arguments{\item{a}{a square numeric or complex matrix containing the coefficients ofthe linear system.}\item{b}{a numeric or complex vector or matrix giving the right-handside(s) of the linear system. If missing, \code{b} is taken to bean identity matrix and \code{solve} will return the inverse of \code{a}.}\item{tol}{the tolerance for detecting linear dependencies in thecolumns of \code{a}. If \code{LINPACK} is \code{TRUE} the defaultis \code{1e-7}, otherwise it is \code{.Machine$double.eps}. Futureversions of R may use a tighter tolerance. Not presently used withcomplex matrices \code{a}.}\item{LINPACK}{logical. Should LINPACK be used (for compatibility with\R < 1.7.0)? Otherwise LAPACK is used.}\item{\dots}{further arguments passed to or from other methods}}\description{This generic function solves the equation \code{a \%*\% x = b} for \code{x},where \code{b} can be either a vector or a matrix.}\details{\code{a} or \code{b} can be complex, but this uses double complexarithmetic which might not be available on all platforms and LAPACKwill always be used.The row and column names of the result are taken from the column namesof \code{a} and of \code{b} respectively. If \code{b} is missing thecolumn names of the result are the row names of \code{a}. No check ismade that the column names of \code{a} and the row names of \code{b}are equal.For back-compatibility \code{a} can be a (real) QR decomposition,although \code{\link{qr.solve}} should be called in that case.\code{\link{qr.solve}} can handle non-square systems.}\references{Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\emph{The New S Language}.Wadsworth & Brooks/Cole.}\seealso{\code{\link{solve.qr}} for the \code{qr} method,\code{\link{chol2inv}} for inverting from the Choleski factor\code{\link{backsolve}}, \code{\link{qr.solve}}.}\examples{hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") }h8 <- hilbert(8); h8sh8 <- solve(h8)round(sh8 \%*\% h8, 3)A <- hilbert(4)A[] <- as.complex(A)## might not be supported on all platformstry(solve(A))}\keyword{algebra}