6 - More on Solving Linear Systems

Updated 4 Oct 2026

ตอนนี้รู้แล้วว่าถ้าเจอ 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 A∈Rn×nA \in \mathbb{R}^{n \times n} is positive definite if:
    xTAx>0\boxed{x^T Ax > 0}
    for all nonzero x∈Rnx \in \mathbb{R}^n

  • A symmetric matrix A∈Rn×nA \in \mathbb{R}^{n \times n} is positive semidefinite if:
    xTAx≥0\boxed{x^T Ax \geq 0}
    for all x∈Rnx \in \mathbb{R}^n

  • 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: Ax=bAx = b
  • If the matrix AA is symmetric positive definite, its LU factorization can be arranged so that U=LTU = L^T

Theorem

Any symmetric positive definite matrix A∈Rn×nA \in \mathbb{R}^{n \times n} can be factored:
A=LLT\boxed{A = LL^T}
where LL 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: A=LLTA = LL^T
[a11a21a21a22]=[l110l21l22][l11l210l22]=[l112l11l21l11l21l212+l222]\begin{bmatrix} a_{11} & a_{21} \\ a_{21} & a_{22} \end{bmatrix} = \begin{bmatrix} l_{11} & 0 \\ l_{21} & l_{22} \end{bmatrix} \begin{bmatrix} l_{11} & l_{21} \\ 0 & l_{22} \end{bmatrix} = \begin{bmatrix} l_{11}^2 & l_{11}l_{21} \\ l_{11}l_{21} & l_{21}^2 + l_{22}^2 \end{bmatrix}

Solution steps:

  • l112=a11⇒l11=±a11l_{11}^2 = a_{11} \Rightarrow \boxed{l_{11} = \pm\sqrt{a_{11}}}

  • l11l21=a21⇒l21=a21/l11l_{11}l_{21} = a_{21} \Rightarrow \boxed{l_{21} = a_{21}/l_{11}}

  • l212+l222=a22⇒l22=±a22−l212l_{21}^2 + l_{22}^2 = a_{22} \Rightarrow \boxed{l_{22} = \pm\sqrt{a_{22} - l_{21}^2}}

  • By convention, we always choose the positive values for the diagonal entries of LL

  • The same idea can be extended to a more general nn-by-nn matrix

Exercise 1 Solution

Compute the Cholesky factorization of:
[9−15−1526]\begin{bmatrix} 9 & -15 \\ -15 & 26 \end{bmatrix}
Solution:

  • l11=a11=9=3l_{11} = \sqrt{a_{11}} = \sqrt{9} = 3
  • l21=a21/l11=−15/3=−5l_{21} = a_{21}/l_{11} = -15/3 = -5
  • l22=a22−l212=26−(−5)2=26−25=1l_{22} = \sqrt{a_{22} - l_{21}^2} = \sqrt{26 - (-5)^2} = \sqrt{26 - 25} = 1

Therefore:
L=[30−51]L = \begin{bmatrix} 3 & 0 \\ -5 & 1 \end{bmatrix}

And: [9−15−1526]=LLT\begin{bmatrix} 9 & -15 \\ -15 & 26 \end{bmatrix} = LL^T

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 AA is not positive definite)
  • No pivoting required for numerical stability (unlike GE)
  • Is only n3/3+O(n2)n^3/3 + O(n^2) operations. Cheaper than GE/GEPP by a factor of 2 (GE/GEPP are 2n3/3+O(n2)2n^3/3 + O(n^2) operations)

Theorem: In exact arithmetic, the Cholesky factorization algorithm runs to completion if and only if the matrix AA is symmetric positive definite.

Solving Linear System with Cholesky

To solve Ax=bAx = b when AA is symmetric positive definite:

  1. Factor A=LLTA = LL^T
  2. Solve Lw=bLw = b for ww (forward substitution)
  3. Solve LTx=wL^T x = w for xx (back substitution)

Verify:

  • Let xx be the output of the above procedure

  • See that: Ax=(LLT)x=L(LTx)=Lw=bAx = (LL^T)x = L(L^T x) = Lw = b

  • 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:
[100ϵ]x=[1ϵ]\begin{bmatrix} 1 & 0 \\ 0 & \epsilon \end{bmatrix} x = \begin{bmatrix} 1 \\ \epsilon \end{bmatrix}

  • The matrix has condition number (in p-norm) is 1/ϵ1/\epsilon, which is very ill-conditioned if ϵ\epsilon is very small
  • If we multiply the second row by 1/ϵ1/\epsilon, then the system becomes:
    [1001]x=[11]\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} x = \begin{bmatrix} 1 \\ 1 \end{bmatrix}
    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 x0x_0 to the system Ax=bAx = b.

  1. We compute the residual: r0=b−Ax0r_0 = b - Ax_0
  2. If r0r_0 is large (say, because the system is ill-conditioned or we used an iterative method), we can solve: As0=r0As_0 = r_0
  3. Take: x1=x0+s0x_1 = x_0 + s_0 as a new and "better" approximate solution

Verification

x1x_1 is a solution because:
Ax1=A(x0+s0)=Ax0+As0=(b−r0)+r0=bAx_1 = A(x_0 + s_0) = Ax_0 + As_0 = (b - r_0) + r_0 = b

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 AA (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 x0x_0

Solving a Tridiagonal Linear System

Problem Setup

Consider solving Ax=bAx = b where AA 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.