ตอนนี้รู้แล้วว่าถ้าเจอ Linear System ที่เป็น Lower Triangular ให้ใช้ Forward Substitution
ถ้าเป็น Upper Triangular ควรใช้ Backward Substitution
แล้วถ้า General Case ก็สามารถใช้ GEPP + 4 steps procedure
มันมี special case ของ matrix ที่เราสามารถทำได้ดีกว่าใช้ GEPP อีก
Positive Definite and Positive Semidefinite Matrices
Definitions
-
A symmetric matrix is positive definite if:
for all nonzero -
A symmetric matrix is positive semidefinite if:
for all -
Note: Both are usually defined for only symmetric matrices (as unsymmetric positive definite/semidefinite matrices are not that useful in practice)
Positive Definite / Positive Semidefinite นี่เป็น special case ของ matrix ที่ “สวย” และ “แก้สมการได้ง่ายกว่าใช้ Gaussian Elimination (GEPP)” เพราะเรามี Cholesky decomposition โดยเฉพาะ
Cholesky Factorization
Overview
- Solving linear system:
- If the matrix is symmetric positive definite, its LU factorization can be arranged so that
Theorem
Any symmetric positive definite matrix can be factored:
where is lower triangular (not necessarily unit lower triangular).
- This factorization is known as Cholesky factorization
- Cholesky factorization can be computed from GE, but there is a more efficient way
Computing Cholesky Factorization on a 2×2 Matrix
Given:
Solution steps:
-
-
-
-
By convention, we always choose the positive values for the diagonal entries of
-
The same idea can be extended to a more general -by- matrix
Exercise 1 Solution
Compute the Cholesky factorization of:
Solution:
Therefore:
And:
Cholesky Factorization Algorithm
for k = 1 to n
a_kk = sqrt(a_kk)
for i = k + 1 to n
a_ik = a_ik / a_kk
end
for j = k + 1 to n
for i = k + 1 to n
a_ij = a_ij - a_ik * a_jk
end
end
end
Good Points of Cholesky Factorization
- The algorithm is well-defined. The square roots required are all of positive numbers (unless is not positive definite)
- No pivoting required for numerical stability (unlike GE)
- Is only operations. Cheaper than GE/GEPP by a factor of 2 (GE/GEPP are operations)
Theorem: In exact arithmetic, the Cholesky factorization algorithm runs to completion if and only if the matrix is symmetric positive definite.
Solving Linear System with Cholesky
To solve when is symmetric positive definite:
- Factor
- Solve for (forward substitution)
- Solve for (back substitution)
Verify:
-
Let be the output of the above procedure
-
See that:
-
This algorithm is backward stable for solving symmetric positive definite linear system
Cholesky Factorization in MATLAB
>> R = chol(A); % Return R = L^T (so A = R^T*R)
>> L = chol(A,'lower'); % Return L (A = L*L^T)Improving Accuracy of Linear Systems
Example Problem
Consider the linear system:
- The matrix has condition number (in p-norm) is , which is very ill-conditioned if is very small
- If we multiply the second row by , then the system becomes:
which is perfectly well-conditioned
Iterative Refinement
Iterative Refinement is another means of potentially improving the accuracy of a computed solution.
Process
Suppose we have computed an approximate solution to the system .
- We compute the residual:
- If is large (say, because the system is ill-conditioned or we used an iterative method), we can solve:
- Take: as a new and "better" approximate solution
Verification
is a solution because:
Process Continuation and Limitations
- This process can be repeated successively to reduce the residual as needed
- However, iterative refinement requires double the storage as we need to store both (to compute the residual) and its factors (to solve the subsequent systems)
- Moreover, if the residual is already small, the residual must usually be computed with higher precision than that used in computing
Solving a Tridiagonal Linear System
Problem Setup
Consider solving where is a tridiagonal matrix:
b_1 & c_1 & 0 & \cdots & 0 \\ a_2 & b_2 & c_2 & \ddots & \vdots \\ 0 & \ddots & \ddots & \ddots & 0 \\ \vdots & \ddots & a_{n-1} & b_{n-1} & c_{n-1} \\ 0 & \cdots & 0 & a_n & b_n \end{bmatrix}$$ - Assume pivoting is not required for stability, which is often the case for tridiagonal systems arising in practice (e.g., the matrix is diagonally dominant or positive definite) ### LU Factorization Structure The LU factorization of $A$ are given by: $$L = \begin{bmatrix} 1 & 0 & \cdots & \cdots & 0 \\ m_2 & 1 & \ddots & \ddots & \vdots \\ 0 & \ddots & \ddots & \ddots & \vdots \\ \vdots & \ddots & m_{n-1} & 1 & 0 \\ 0 & \cdots & 0 & m_n & 1 \end{bmatrix}$$ $$U = \begin{bmatrix} d_1 & c_1 & 0 & \cdots & 0 \\ 0 & d_2 & c_2 & \ddots & \vdots \\ \vdots & \ddots & \ddots & \ddots & 0 \\ \vdots & \ddots & \ddots & d_{n-1} & c_{n-1} \\ 0 & \cdots & \cdots & 0 & d_n \end{bmatrix}$$ ### Tridiagonal LU Factorization Algorithm ``` d_1 = b_1 for i = 2 to n m_i = a_i / d_{i-1} d_i = b_i - m_i * c_{i-1} end ``` **Note**: This algorithm is only $O(n)$ complexity.