# LU

0th

Percentile

##### LU Decomposition

LU computes the LU decomposition of a matrix, $A$, such that $P A = L U$, where $L$ is a lower triangle matrix, $U$ is an upper triangle, and $P$ is a permutation matrix.

##### Usage
LU(A, b, tol = sqrt(.Machine\$double.eps), verbose = FALSE, ...)
##### Arguments
A

coefficient matrix

b

right-hand side vector. When supplied the returned object will also contain the solved $d$ and x elements

tol

tolerance for checking for 0 pivot

verbose

logical; if TRUE, print intermediate steps

...

additional arguments passed to showEqn

##### Details

The LU decomposition is used to solve the equation $A x = b$ by calculating $L(Ux - d) = 0$, where $Ld = b$. If row exchanges are necessary for $A$ then the permutation matrix $P$ will be required to exchange the rows in $A$; otherwise, $P$ will be an identity matrix and the LU equation will be simplified to $A = L U$.

##### Value

A list of matrix components of the solution, P, L and U. If b is supplied, the vectors $d$ and x are also returned.

• LU
##### Examples
# NOT RUN {
A <- matrix(c(2, 1, -1,
-3, -1, 2,
-2,  1, 2), 3, 3, byrow=TRUE)
b <- c(8, -11, -3)
(ret <- LU(A)) # P is an identity; no row swapping
with(ret, L %*% U) # check that A = L * U
LU(A, b)

LU(A, b, verbose=TRUE)
LU(A, b, verbose=TRUE, fractions=TRUE)

# permutations required in this example
A <- matrix(c(1,  1, -1,
2,  2,  4,
1, -1,  1), 3, 3, byrow=TRUE)
b <- c(1, 2, 9)
(ret <- LU(A, b))
with(ret, P %*% A)
with(ret, L %*% U)

# }

Documentation reproduced from package matlib, version 0.9.2, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.