Direct Methods for Linear Systems
Learn to solve linear systems using direct methods. From Gaussian elimination to LU decomposition, understand the algorithms, their stability, and when to use them.
- Implement Gaussian elimination with back substitution
- Understand and apply pivoting strategies
- Compute LU decomposition and use it for multiple right-hand sides
- Apply Cholesky factorization for symmetric positive definite matrices
- Analyze condition numbers and their effect on solution accuracy
- Exploit special matrix structures for efficiency
1. Gaussian Elimination
Gaussian elimination transforms a linear system into upper triangular form, which is then solved by back substitution.
Algorithm Gaussian Elimination
Input: Matrix , vector
Forward Elimination: For :
- For : compute multiplier
- Update row : for
- Update
Back Substitution: For :
Theorem 6.1: Operation Count
Gaussian elimination requires:
- Forward elimination: operations
- Back substitution: operations
Example: Gaussian Elimination
Solve the system:
After forward elimination:
2. Pivoting Strategies
When the pivot is zero or very small, we need to reorder rows (and possibly columns) to maintain numerical stability.
Definition 6.1: Partial Pivoting
At step , find the row with , then swap rows and .
This ensures for all multipliers.
Definition 6.2: Complete Pivoting
Search both rows and columns: find and swap both rows and columns. More stable but rarely needed in practice.
Remark:
Scaled partial pivoting: Considers relative element sizes by comparing where is the row scale factor.
Note:
Partial pivoting is almost always sufficient and is the default in production software. The growth factor (maximum element during elimination divided by maximum in original matrix) is typically small with partial pivoting.
3. LU Decomposition
Definition 6.3: LU Factorization
Express as where:
- is lower triangular (with 1s on diagonal for Doolittle)
- is upper triangular
Theorem 6.2: Existence of LU
If all leading principal minors of are nonzero, then has a unique LU factorization with unit diagonal on .
Algorithm Solving with LU
To solve given :
- Forward substitution: Solve for
- Back substitution: Solve for
Each solve is , efficient for multiple right-hand sides.
Definition 6.4: LU with Pivoting
With partial pivoting, we get where is a permutation matrix.
To solve:
Example: LU Decomposition
4. Special Matrix Structures
Definition 6.5: Cholesky Factorization
For symmetric positive definite : where is lower triangular with positive diagonal.
Remark:
Cholesky factorization requires only operations (half of LU) and is numerically stable without pivoting for SPD matrices.
Definition 6.6: Tridiagonal Systems
For tridiagonal matrix with diagonals , theThomas algorithm solves in :
Algorithm Thomas Algorithm
Forward sweep: For :
Back substitution: , then for :
5. Error Analysis and Condition Numbers
Definition 6.7: Matrix Norms
Common matrix norms:
- (max column sum)
- (max row sum)
- (spectral norm)
- (Frobenius norm)
Definition 6.8: Condition Number
For the 2-norm: (ratio of largest to smallest singular value).
Theorem 6.3: Error Bound
If and , then:
Example: Ill-Conditioned System
The Hilbert matrix is extremely ill-conditioned:
Solving systems with such matrices loses many digits of accuracy.
Remark:
Rule of thumb: If and you work in-digit precision, expect about correct digits in the solution.
Practice Quiz
Frequently Asked Questions
When should I use LU vs. Gaussian elimination?
Single right-hand side: Both are equivalent in cost.
Multiple right-hand sides: Use LU. Factor once (), then solve each system in .
Why is pivoting necessary?
Without pivoting, a zero or near-zero pivot causes division by zero or severe error amplification.
Partial pivoting keeps multipliers bounded (), limiting error growth. It's essential for numerical stability.
When should I use Cholesky vs. LU?
Cholesky: When is symmetric positive definite. It's twice as fast, more stable, and needs no pivoting.
LU: For general (non-symmetric or indefinite) matrices.
How do I know if my matrix is ill-conditioned?
Compute using your linear algebra library. If (about for double precision), the matrix is effectively singular. For , be cautious about the accuracy of results.
What if the matrix is sparse?
Use sparse matrix data structures and algorithms (sparse LU with fill-reducing orderings). Libraries like UMFPACK, SuperLU, or SuiteSparse are designed for this. Direct methods may still produce significant fill-in; iterative methods (next chapter) may be better.