2 - Systems of Linear Equations (older version)
Key Concepts & Overview
Analytical vs Numerical Methods
- Analytical methods: Work with arbitrary data, produce closed-form solutions exactly
- Numerical methods: Work only with concrete numbers, sequence of operations depends on actual values
- Focus: Computer-based solving (numerical) vs hand solving (analytical)
- Many problems can't be solved analytically or are too slow to be practical
Block Matrix Notation
Partitioning matrices into smaller submatrices

ถ้ามาจาก same horizontal line จะมี the same number of column
ถ้ามาจาก same vertical line จะมี the same number of rows
- Example: where dimensions are compatible
- Operations work like normal matrices: for addition
- Multiplication:
Linear System Fundamentals
Standard Form
- Problem: Find such that:
- Matrix form: where ,
Solution Existence
- If A is nonsingular: exists, unique solution
- If A is singular: Either no solutions or infinitely many solutions (depends on )
Triangular Systems
Lower Triangular Matrices
- Definition: for (entries above main diagonal are zero)
- Forward Substitution Formula:
- Note that by convention.
Theorem
A square upper or lower triangular matrix is nonsingular if and only if all of its diagonal entries are nonzeros.
Upper Triangular Matrices
- Definition: for (entries below main diagonal are zero)
- Back Substitution Formula:
Key Theorem
- A square triangular matrix is nonsingular iff all diagonal entries are nonzero
Algorithm Versions
- Version 1: Row-oriented (sequential inner loop)
- Version 2: Column-oriented (better concurrency, can parallelize inner loop)
- Running Time: Both versions are
Gaussian Elimination & LU Factorization
Basic Gaussian Elimination
เวลาเปลี่ยนก็ต้องมั่นใจว่าไม่ได้เปลี่ยน Solution
- Goal: Transform into upper triangular matrix
- Process: Eliminate entries below main diagonal, column by column
- Elimination Step:
- Terminology:
- = pivot
- = multiplier
จริง ๆ เราทำเองก็ได้ แต่ว่ามันเป็นสูตรเพื่อให้มั่นใจ (ถ้าทำตาม) เดี๋ยวมันก็จะได้เป็น Upper triangular matrix เองเลยล่ะ!!
LU Factorization Theorem
แล้วถ้าจะ Construct LU บ้างล่ะ ข้างบนเป็น UT ไปแล้วใช่มะ
- Result: where:
- = unit lower triangular (ones on diagonal, multipliers below)
- = upper triangular matrix from GE
- L Construction:
- Zeros above diagonal
- Ones on diagonal
- Multipliers used in elimination below diagonal
Three-Step Solution Procedure
- Factor:
- Forward substitution: Solve for
- Back substitution: Solve for
- Verification: ✓
Advantages of LU Factorization
- Multiple right-hand sides: Factor once, reuse for different vectors
- Efficiency: Same operations as direct GE, but more flexible
Gaussian Elimination with Partial Pivoting (GEPP)
Problem with Plain GE
- Pivot might be zero even when matrix is nonsingular
- Solution: Pivoting (row exchanges)
อย่าง Plain GE จะได้ LU
Does GEPP compute a matrix factorization?
- เฉลย alternating between swap and eliminating
Partial Pivoting Strategy
- Before each elimination: Swap rows to bring largest absolute value to pivot position
- Selection:
- Process: Exchange rows and
GEPP Factorization
- Result: or equivalently
- P: Permutation matrix encoding all row swaps
- Key theorem: GEPP encounters zero pivot iff is singular
Four-Step Solution with GEPP
- Factor: by GEPP
- Permute: Set
- Forward substitution: Solve for
- Back substitution: Solve for
Permutation Matrices
- Properties:
- Square matrix with entries 0 or 1
- Exactly one 1 per row and column
- permutes rows of
- permutes columns of
- (orthogonal)
Implementation Notes
- Running time: Still (pivoting adds total)
- Storage: Don't store explicitly, use vector of indices
- Accuracy: Using max absolute value gives lowest error in floating-point
Computing Matrix Inverses
Method Using GEPP
- Goal: Compute where
- Approach: Solve for
- Reasoning:
- Efficiency: Factor once, then solve systems
Important Best Practice
- Never compute explicitly!
- Instead: Solve for using GEPP
- Reason: More accurate and faster than computing inverse then multiplying
MATLAB Implementation
- Use
A \ bnotinv(A) * b - MATLAB automatically chooses optimal algorithm based on matrix structure
lu(A) ใน MATLAB จะเป็น GEPP เลยนะ not plain GE
Advanced Topics
Sherman-Morrison Formula
- Problem: Solve efficiently when is known
- Formula:
- Algorithm ( operations):
- Solve for
- Solve for
- Compute
Woodbury Formula
- Generalization:
- Application: Rank- modifications where are matrices
Existence of LU Factorization
- Not guaranteed: Some matrices have no LU factorization
- Example: has no LU factorization
- Solution: Use pivoting (GEPP always works for nonsingular matrices)
MATLAB Commands Summary
Basic Operations
- Solve system:
x = A \ b - LU factorization:
[L,U,P] = lu(A) - Matrix inverse:
Ai = inv(A)(avoid when possible)
Advanced Usage
- Vector form pivoting:
[L,U,pvec] = lu(A, 'vector') - Multiple systems: Factor once, reuse for different right-hand sides
- Documentation:
help lu,doc mldividefor more details
Complexity Analysis
Operation Counts
- LU factorization: operations
- Forward/back substitution: operations each
- Total for solving : operations
- Multiple right-hand sides: for factorization + per additional solve