LU Decomposition Calculator

Factor a matrix into PA = LU with partial pivoting.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Enter a square matrix to split it into a lower triangular L, an upper triangular U and a row-swap matrix P with PA = LU. For [4 3; 6 3] the pivot is 6, so rows are swapped first.

How to use

1
Step 1
Type a square matrix.
2
Step 2
Choose lu.
3
Step 3
Press Calculate to see P, L and U.

How it works

Gaussian elimination records its multipliers in L and leaves the reduced matrix as U. Partial pivoting swaps in the row with the largest entry first, for numerical stability, and the swaps are stored in P. LU makes solving Ax = b and finding determinants quick.

PA = LU      det(A) = ± product of the diagonal of U

Worked example

A 2×2 with a pivot swap

Input
[4 3; 6 3]
Output
P = [0 1; 1 0], L = [1 0; 0.666667 1], U = [6 3; 0 1]
Walkthrough
Swap the rows to put 6 on top, then multiplier 4/6 = 0.666667. Check LU: row 2 of L·U is [0.666667×6, 0.666667×3 + 1] = [4, 3], which is the original first row.

Limitations

  • Entries must be real numbers; complex entries are refused.
  • Square matrices only.
  • Results use the pivoting order shown in P, so L and U can differ from a hand calculation done without row swaps.

Questions

What is the LU decomposition of [4 3; 6 3]?
L = [1 0; 0.666667 1], U = [6 3; 0 1], P = [0 1; 1 0].
What is the U matrix for [2 1 1; 4 3 3; 8 7 9]?
[8 7 9; 0 −0.75 −1.25; 0 0 −0.666667].
What is the P matrix for?
It records the row swaps made while pivoting, so that PA = LU.

Features

  • Partial pivoting
  • Shows P, L and U
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • Derivative as a concept

    Khan Academy

    When general calculators hand off to calculus tools.

    Watch on YouTube
  • Introduction to scientific notation

    Khan Academy

    Scientific notation for calculator and number tools.

    Watch on YouTube
  • Pi

    Math is Fun

    What π means when calculators return pi-based results.

  • Pre-algebra

    Khan Academy

    Number sense practice that supports general calculator use.