LU Decomposition Algorithm Visualizer
Run the LU Decomposition Visualizer Fullscreen
Edit the MicroSim in the p5.js Editor
About This MicroSim
This visualization demonstrates the LU Decomposition algorithm step-by-step, showing how Gaussian elimination transforms a matrix A into the product of:
- L - a lower triangular matrix containing the multipliers
- U - an upper triangular matrix (the row echelon form)
Key Features
- Step-by-step execution: Watch each elimination step in detail
- Multiplier tracking: See how multipliers are stored in L
- Pivot highlighting: Current pivot shown in yellow
- Row highlighting: Row being eliminated shown in red
- Verification: Confirm that L × U = A after completion
- Multiple sizes: Try with 3×3 or 4×4 matrices
How to Use
- Click Next Step to advance through the algorithm
- Use Auto Run to automatically step through
- Adjust the Speed slider to control animation pace
- Click Reset to start over
- After completion, click Verify L×U=A to confirm
The Algorithm
For each column k (from 1 to n-1):
- Select pivot: Use element A[k,k] as the pivot
- For each row below pivot (rows k+1 to n):
- Calculate multiplier:
l[i,k] = A[i,k] / A[k,k] - Store multiplier in L
- Subtract:
Row i = Row i - multiplier × Row k
- Calculate multiplier:
- Continue until A becomes upper triangular (U)
Learning Objectives
After using this MicroSim, students will be able to:
- Explain how LU decomposition relates to Gaussian elimination
- Identify where multipliers are stored in the L matrix
- Understand why L is lower triangular with 1s on the diagonal
- Verify that A = LU holds after the decomposition
Lesson Plan
Warm-up (3 minutes)
Ask students to recall Gaussian elimination and what information is "lost" during the process.
Demonstration (7 minutes)
Walk through the 3×3 example together:
- First pivot: A[1,1] = 2
- Eliminate A[2,1]: multiplier = 4/2 = 2
- Eliminate A[3,1]: multiplier = 8/2 = 4
- Continue with second pivot
Key Insight
Emphasize that LU decomposition "saves" the multipliers that would otherwise be discarded in Gaussian elimination.
Practice (10 minutes)
Have students:
- Predict the next multiplier before clicking
- Try the 4×4 matrix
- Verify the decomposition
Discussion Questions
- Why is L lower triangular?
- Why are the diagonal elements of L all equal to 1?
- What would happen if a pivot were zero?
References
- Chapter 7: Matrix Decompositions - LU Decomposition section
- Strang, G. "Introduction to Linear Algebra" - Chapter on Elimination
- MIT OCW: LU Decomposition