EVOLUTION-MANAGER
Edit File: solve.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Solve a System of Equations</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for solve {base}"><tr><td>solve {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Solve a System of Equations</h2> <h3>Description</h3> <p>This generic function solves the equation <code>a %*% x = b</code> for <code>x</code>, where <code>b</code> can be either a vector or a matrix. </p> <h3>Usage</h3> <pre> solve(a, b, ...) ## Default S3 method: solve(a, b, tol, LINPACK = FALSE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>a</code></td> <td> <p>a square numeric or complex matrix containing the coefficients of the linear system. Logical matrices are coerced to numeric.</p> </td></tr> <tr valign="top"><td><code>b</code></td> <td> <p>a numeric or complex vector or matrix giving the right-hand side(s) of the linear system. If missing, <code>b</code> is taken to be an identity matrix and <code>solve</code> will return the inverse of <code>a</code>.</p> </td></tr> <tr valign="top"><td><code>tol</code></td> <td> <p>the tolerance for detecting linear dependencies in the columns of <code>a</code>. The default is <code>.Machine$double.eps</code>. Not currently used with complex matrices <code>a</code>.</p> </td></tr> <tr valign="top"><td><code>LINPACK</code></td> <td> <p>logical. Defunct and ignored.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments passed to or from other methods</p> </td></tr> </table> <h3>Details</h3> <p><code>a</code> or <code>b</code> can be complex, but this uses double complex arithmetic which might not be available on all platforms. </p> <p>The row and column names of the result are taken from the column names of <code>a</code> and of <code>b</code> respectively. If <code>b</code> is missing the column names of the result are the row names of <code>a</code>. No check is made that the column names of <code>a</code> and the row names of <code>b</code> are equal. </p> <p>For back-compatibility <code>a</code> can be a (real) QR decomposition, although <code><a href="qr.html">qr.solve</a></code> should be called in that case. <code><a href="qr.html">qr.solve</a></code> can handle non-square systems. </p> <p>Unsuccessful results from the underlying LAPACK code will result in an error giving a positive error code: these can only be interpreted by detailed study of the FORTRAN code. </p> <h3>Source</h3> <p>The default method is an interface to the LAPACK routines <code>DGESV</code> and <code>ZGESV</code>. </p> <p>LAPACK is from <a href="http://www.netlib.org/lapack">http://www.netlib.org/lapack</a>. </p> <h3>References</h3> <p>Anderson. E. and ten others (1999) <em>LAPACK Users' Guide</em>. Third Edition. SIAM.<br /> Available on-line at <a href="http://www.netlib.org/lapack/lug/lapack_lug.html">http://www.netlib.org/lapack/lug/lapack_lug.html</a>. </p> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="qr.html">solve.qr</a></code> for the <code>qr</code> method, <code><a href="chol2inv.html">chol2inv</a></code> for inverting from the Choleski factor <code><a href="backsolve.html">backsolve</a></code>, <code><a href="qr.html">qr.solve</a></code>. </p> <h3>Examples</h3> <pre> hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") } h8 <- hilbert(8); h8 sh8 <- solve(h8) round(sh8 %*% h8, 3) A <- hilbert(4) A[] <- as.complex(A) ## might not be supported on all platforms try(solve(A)) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>