Try it yourself:


lu(): LU Matrix Decomposition

lu() factors a matrix into lower- and upper-triangular components, commonly with a permutation. This decomposition is useful for solving linear systems, determinants, and repeated calculations using the same coefficient matrix.

Solving efficiently

Triangular systems can be solved by forward and backward substitution, often more efficiently than repeatedly finding an inverse. Compare this approach with lsolve() for linear systems and det() for determinant work.

Square matrices are the standard case, and singular or nearly singular matrices require care. Inspect dimensions with size(); use qr() or svd() when numerical conditioning is important.

All functions