solve | R Documentation |
Solve system of symbolic equations or solve a polynomial equation. Depending on types of arguments, it supports different modes. See Details and Examples.
solve(a, b, ...)
## S4 method for signature 'DenseMatrix'
solve(a, b, ...)
## S4 method for signature 'VecBasic'
solve(a, b, ...)
## S4 method for signature 'Basic'
solve(a, b, ...)
a , b |
Objects, see details. |
... |
Not used. |
solve
is a generic function dispatched on the class of the first argument.
If a
is a (square) DenseMatrix, it solves the equation
a %*% x = b
for x
. (similar to solve.default()
)
If a
is a DenseMatrix and b
is missing, b
is
taken to be an identity matrix and solve
will return the
inverse of a
. (similar to solve.default()
)
If a
is a VecBasic, it solves the system of linear equations
represented by a
with regards to symbols represented in b
.
If a
is a Basic, it solves the polynomial equation represented by
a with regards to the symbol represented in b
.
A VecBasic
or DenseMatrix
S4 object.
## Inverse of a symbolic matrix
mat <- Matrix(c("A", "B", "C", "D"), 2)
solve(mat)
## Solve a %*% x == b
a <- Matrix(c("a11", "a21", "a12", "a22"), 2) # a is a 2x2 matrix
b <- Vector("b1", "b2") # b is a length 2 vector
solve(a, b) # Solution of x (2x1 matrix)
## Solve the system of linear equations represented by a with regards to
## symbols in b
a <- Vector(~ -2*x + y - 4, # A system of linear equations
~ 3*x + y - 9)
b <- Vector(~x, ~y) # Symbols to solve (x and y)
solve(a, b) # Solution of x and y
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.