LU
Performs an LU decomposition of a matrix.
Syntax
-
[[P, ]L, U ≔ ]LU(A)
-
A
is a matrix
-
Description
If A
is a matrix, then LU(A)
performs an LU decomposition of A
, that is, it computes a lower triangular matrix L
, an upper triangular matrix U
, and a permutation matrix P
, such that A = P⋅L⋅U
.
The result of LU(A)
is an assignment list of length three, containing the P
, L
, and U
matrices; or an assignment list of length two, containing only the L
and U
matrices.
Examples
A ≔ ❨❨6, 2, 4, 5, 1❩, ❨2, 8, −3, 1, 2❩, ❨6, 3, 3, −1, 1❩, ❨7, 5, −2, 6, 9❩, ❨4, 5, 2, 1, 3❩❩
⎛ 6 2 4 5 1⎞ ⎜ 2 8 −3 1 2⎟ ⎜ 6 3 3 −1 1⎟ ⎜ 7 5 −2 6 9⎟ ⎝ 4 5 2 1 3⎠
(P, L, U) ≔ LU(A)
⎛0 0 0 1 0⎞ ⎜0 1 0 0 0⎟ ⎜1 0 0 0 0⎟ ⎜0 0 1 0 0⎟ ⎝0 0 0 0 1⎠ ⎛ 1 0 0 0 0⎞ ⎜ 0.285714285714 1 0 0 0⎟ ⎜ 0.857142857143 −0.347826086957 1 0 0⎟ ⎜ 0.857142857143 −0.195652173913 0.870535714286 1 0⎟ ⎝ 0.571428571429 0.326086956522 0.808035714286 0.31630353118 1⎠ ⎛ 7 5 −2 6 9⎞ ⎜ 0 6.57142857143 −2.42857142857 −0.714285714286 −0.571428571429⎟ ⎜ 0 0 4.86956521739 −0.391304347826 −6.91304347826⎟ ⎜ 0 0 0 −5.94196428571 −0.808035714286⎟ ⎝ 0 0 0 0 3.88504883546⎠
IsPermutation(P) ∧ IsLowerTriangular(L) ∧ IsUpperTriangular(U)
true
P⋅L⋅U
⎛ 6 3 3 −1 1⎞ ⎜ 2 8 −3 1 2⎟ ⎜ 7 5 −2 6 9⎟ ⎜ 6 2 4 5 1⎟ ⎝ 4 5 2 1 3⎠
See also
-
Matrix decompositions (list)