数值计算详细笔记(三):非线性方程组解法

6. Linear Systems Ax = b

6.1 Basic Concepts

6.1.1 LSEs

the Linear System of Equations (LSEs):
(I){E1:a11x1+a12x2+...+a1nxn=b1E2:a21x1+a22x2+...+a2nxn=b2...En:an1x1+an2x2+...+annxn=bn (I)\left\{ \begin{aligned} E_1: & a_{11}x_1+a_{12}x_2+...+a_{1n}x_n=b_1 \\ E_2: & a_{21}x_1+a_{22}x_2+...+a_{2n}x_n=b_2 \\ ... & \\ E_n: & a_{n1}x_1+a_{n2}x_2+...+a_{nn}x_n=b_n \end{aligned} \right.

6.1.2 Operations of LSEs

Multiplied operation - 数乘

Equation EiE_i can be multiplied by any nonzero constant λ\lambda
(λEi)Ei (\lambda E_i)\rightarrow E_i

Multiplied and added operation - 倍加

Equation EjE_j can be multiplied by any nonzero constant λ\lambda, and added to Equation EiE_i in place of EiE_i, denoted by
(λEj+Ei)Ei (\lambda E_j+E_i)\rightarrow E_i

Transposition - 交换

Equation EiE_i and EjE_j can be transposed in order, denoted by
EiEj E_i \leftrightarrow E_j

6.1.3 Augmented Matirx

A~=[A,b]=(a11a12...a1na21a22...a2n............an1an2...annb1b2...bn) \tilde{A}=[A,\textbf{b}]= \left ( \begin{array}{c:c} \begin{matrix} a_{11}&a_{12}&...&a_{1n}\\ a_{21}&a_{22}&...&a_{2n}\\ ... & ... & ... &... \\ a_{n1}&a_{n2}&...&a_{nn}\\ \end{matrix}& \begin{matrix} b_1\\ b_2\\ ...\\ b_n \end{matrix} \end{array} \right )

6.2 Gaussian Elimination Method

6.2.1 Overall Description

The key point of Gaussian Elimination Method is changing the original matrix into upper-triangular matrix, then using backward–substitution method to calculate the answer.

6.2.2 Algorithm

  • INPUT: NN-dimension, A(N,N),B(N)A(N,N), B(N)

  • OUTPUT: Solution x(N)x(N) or Message that LESs has no unique solution.

  • Step 11: For k=1,2,...,N1k = 1,2,...,N-1, do step 2-4.

  • Step 22: Set pp be the smallest integer with kpNk\leq p\leq N and Ap,k0A_{p,k}\not= 0. If no pp can be found, output: “no unique solution exists”; stop.

  • Step 33: If pkp\not=k, do transposition EpEkE_p\leftrightarrow E_k.

  • Step 44: For i=k+1,...,Ni=k+1,...,N

    1. Set mi,k=A(i,k)A(k,k)m_{i,k}=\displaystyle\frac{A(i,k)}{A(k,k)}
    2. Set B(i)=B(i)mi,kB(k)B(i)=B(i)-m_{i,k}B(k)
    3. For j=k+1,...,Nj=k+1,...,N, set A(i,j)=A(i,j)mi,kA(k,j)A(i,j)=A(i,j)-m_{i,k}A(k,j);
  • Step 55: If A(N,N)0A(N,N)\not=0, set x(N)=B(N)A(N,N)x(N)=\displaystyle\frac{B(N)}{A(N,N)}; Else, output:“no unique solution exists.”

  • Step 66: For i=N1,N2,...,1i=N-1,N-2,...,1, set
    X(i)=[B(i)j=i+1NA(i,j)x(j)]/A(i,i) X(i)=[B(i)-\sum\limits_{j=i+1}^{N}A(i,j)x(j)]/A(i,i)

  • Step 77: Output the solution x(N)x(N).

6.3 Pivoting Strategies

6.3.1 Background

According to the process of Gaussian Elimination Method, We find that if akk(k1)a_{kk}^{(k-1)} is too small, the roundoff error will be larger.
mi,k=A(i,k)A(k,k)X(i)=[B(i)j=i+1NA(i,j)x(j)]/A(i,i) m_{i,k}=\displaystyle\frac{A(i,k)}{A(k,k)}\\ X(i)=[B(i)-\sum\limits_{j=i+1}^{N}A(i,j)x(j)]/A(i,i)\\

Therefore, in order to reduce the roundoff error, we need to make the value of akk(k1)a_{kk}^{(k-1)} larger.

6.3.2 Maximal Column Pivoting Technique

数值计算详细笔记(三):非线性方程组解法

This method is to make akk(k1)a_{kk}^{(k-1)} equal to the maximal value in its column.

6.3.3 Maximal Row Pivoting Technique

数值计算详细笔记(三):非线性方程组解法

This method is to make akk(k1)a_{kk}^{(k-1)} equal to the maximal value in its row.

6.3.4 Partial Pivoting Technique

数值计算详细笔记(三):非线性方程组解法

This method is to make akk(k1)a_{kk}^{(k-1)} equal to the maximal value in its remaining area.

6.3.5 Scaled Partial Pivoting Technique

si=max1jnai,jakksk=maxkinai,1si s_i=\max_{1\leq j\leq n}|a_{i,j}| \\ \displaystyle\frac{a_{kk}}{s_k}=\max_{k\leq i\leq n}\displaystyle\frac{a_{i,1}}{s_i}

This method is to make akk(k1)sk\displaystyle\frac{a_{kk}^{(k-1)}}{s_{k}} equal to the maximal value in its remaining area.

6.4 LU Factorization

6.4.1 The advantage of LU Factorization

Ax=bA=LUL=(100...0l2110...0l31l321...0...............ln1ln2ln3...1),R=(u11u12u13...u1n0u22u23...u2n00u33...u3n...............000...unn) Ax=b\\ A=LU\\ L= \left( \begin{matrix} 1 & 0 & 0 & ... & 0 \\ l_{21} & 1 & 0 & ... & 0 \\ l_{31} & l_{32} & 1 & ... & 0 \\ ... & ... & ... & ... & ... \\ l_{n1} & l_{n2} & l_{n3} & ... & 1 \end{matrix} \right), R= \left( \begin{matrix} u_{11} & u_{12} & u_{13} & ... & u_{1n} \\ 0 & u_{22} & u_{23} & ... & u_{2n} \\ 0 & 0 & u_{33} & ... & u_{3n} \\ ... & ... & ... & ... & ... \\ 0 & 0 & 0 & ... & u_{nn} \end{matrix} \right)

We can use two-step process to solve LUx=bLUx=b.

  1. y=Ux,Ly=by=Ux,Ly=b
  2. Solve Ly=bLy=b determining yy with forward substitution method.
  3. Solve Ux=yUx=y determining xx with forward substitution method.

6.4.2 LU Factorization through Gaussian Elimination

Theorem

If Gaussian elimination can be performed on the linear system Ax=bAx=b without row interchanges, then the matrix AA can be factored into the product of a lower-triangular LL and an upper-triangular matrix UU,
A=LU A=LU
where
L=(100...0m2110...0m31m321...0...............mn1mn2mn3...1),R=(a111a121a131...a1n10a222a232...a2n200a333...a3n3...............000...annn) L= \left( \begin{matrix} 1 & 0 & 0 & ... & 0 \\ m_{21} & 1 & 0 & ... & 0 \\ m_{31} & m_{32} & 1 & ... & 0 \\ ... & ... & ... & ... & ... \\ m_{n1} & m_{n2} & m_{n3} & ... & 1 \end{matrix} \right), R= \left( \begin{matrix} a_{11}^1 & a_{12}^1 & a_{13}^1 & ... & a_{1n}^1 \\ 0 & a_{22}^2 & a_{23}^2 & ... & a_{2n}^2 \\ 0 & 0 & a_{33}^3 & ... & a_{3n}^3 \\ ... & ... & ... & ... & ... \\ 0 & 0 & 0 & ... & a_{nn}^n \end{matrix} \right)

Proof

mj,1=aj,1a1,1M1=(100...0m2110...0m3101...0...............mn100...1) m_{j,1}=\displaystyle\frac{a_{j,1}}{a_{1,1}}\\ M^1 = \left( \begin{matrix} 1 & 0 & 0 & ... & 0 \\ -m_{21} & 1 & 0 & ... & 0 \\ -m_{31} & 0 & 1 & ... & 0 \\ ... & ... & ... & ... & ... \\ -m_{n1} & 0 & 0 & ... & 1 \end{matrix} \right)
Thus,
An=Mn1Mn2...M1A. A^n=M^{n-1}M^{n-2}...M^{1}A.
Let U=AnU=A^n, then
[M1]1...[Mn2]1[Mn1]1U=A[M1]1=(100...0m2110...0m3101...0...............mn100...1)L=[M1]1...[Mn2]1[Mn1]1 [M^1]^{-1}...[M^{n-2}]^{-1}[M^{n-1}]^{-1}U=A \\ [M^1]^{-1} = \left( \begin{matrix} 1 & 0 & 0 & ... & 0 \\ m_{21} & 1 & 0 & ... & 0 \\ m_{31} & 0 & 1 & ... & 0 \\ ... & ... & ... & ... & ... \\ m_{n1} & 0 & 0 & ... & 1 \end{matrix} \right)\\ L = [M^1]^{-1}...[M^{n-2}]^{-1}[M^{n-1}]^{-1}\\

6.4.3 LU Factorization through Gaussian Elimination

LU=(100...0l2110...0l31l321...0...............ln1ln2ln3...1)(u11u12u13...u1n0u22u23...u2n00u33...u3n...............000...unn)LU=A=(a11a12a13...a1na21a22a23...a2na31a32a33...a3n...............an1an2an3...ann) LU= \left( \begin{matrix} 1 & 0 & 0 & ... & 0 \\ l_{21} & 1 & 0 & ... & 0 \\ l_{31} & l_{32} & 1 & ... & 0 \\ ... & ... & ... & ... & ... \\ l_{n1} & l_{n2} & l_{n3} & ... & 1 \end{matrix} \right) \left( \begin{matrix} u_{11} & u_{12} & u_{13} & ... & u_{1n} \\ 0 & u_{22} & u_{23} & ... & u_{2n} \\ 0 & 0 & u_{33} & ... & u_{3n} \\ ... & ... & ... & ... & ... \\ 0 & 0 & 0 & ... & u_{nn} \end{matrix} \right)\\ LU=A= \left( \begin{matrix} a_{11} & a_{12} & a_{13} & ... & a_{1n} \\ a_{21} & a_{22} & a_{23} & ... & a_{2n} \\ a_{31} & a_{32} & a_{33} & ... & a_{3n} \\ ... & ... & ... & ... & ... \\ a_{n1} & a_{n2} & a_{n3} & ... & a_{nn} \end{matrix} \right)

Algorithm

数值计算详细笔记(三):非线性方程组解法

数值计算详细笔记(三):非线性方程组解法

数值计算详细笔记(三):非线性方程组解法

6.5 Strictly Diagonally dominant Matrix

6.5.1 Definition

The nnn*n matrix is said to be strictly diagonally dominant (严格对角占优) when
aii>j=1,jinaij |a_{ii}|>\sum\limits_{j=1,j\not=i}^{n} |a_{ij}|
holds for each i=1,2,3,...,ni=1,2,3,...,n.

6.5.2 Property

  1. A strictly diagonally dominant matrix AA is nonsingular.
  2. Moreover, in this case, Gaussian elimination can be performed on any linear system of the form Ax=bAx=b to obtain its unique solution without row or column interchanges, and the computations are stable with respect to the growth of roundoff errors.

Proof for First Property

A matrix is singular means its determinant is zero.

A matrix’s determinant is zero means the n vectors in the matrix are linearly dependent.

Thus, matrix AA is singular means there exists a column vector uu that Ax=0Ax=0.

数值计算详细笔记(三):非线性方程组解法

6.6 Positive Definite Symmetric Matrix

6.6.1 Definition

A matrix AA is positive definite if it is symmetric and if xTAx>0x^TAx > 0 for every nn-dimensional column vector x0x\not=0.

6.6.2 Property

If A is an nnn*n positive definite matrix, then

  1. A is nonsingular;
  2. aii>0a_{ii}>0 for each i=1,2,...,ni=1,2,...,n;
  3. max1k,jnak,jmax1inai,i\max_{1\leq k,j\leq n}|a_{k,j}|\leq \max_{1\leq i\leq n}|a_{i,i}|;
  4. aij2<aiiajja_{ij}^2<a_{ii}a_{jj} for each iji\not=j.

6.6.3 Theorem

数值计算详细笔记(三):非线性方程组解法

数值计算详细笔记(三):非线性方程组解法

数值计算详细笔记(三):非线性方程组解法

6.7 LLTLL^T Factorization

6.7.1 Definition

For a nnn*n symmetric and positive definite matrix AA with the form
A=(a11a12a13...a1na12a22a23...a2na13a23a33...a3n...............a1na2na3n...ann) A= \left( \begin{matrix} a_{11} & a_{12} & a_{13} & ... & a_{1n} \\ a_{12} & a_{22} & a_{23} & ... & a_{2n} \\ a_{13} & a_{23} & a_{33} & ... & a_{3n} \\ ... & ... & ... & ... & ... \\ a_{1n} & a_{2n} & a_{3n} & ... & a_{nn} \end{matrix} \right)
where AT=A.A^T=A. We can factorize this matrix to the form like LLT=ALL^T=A, where LL is a lower triangular matrix with form as follows
(l11000l21l2200l31l32l330ln1ln2ln3lnn) \left( \begin{matrix} l_{11} & 0 & 0 & \cdots & 0 \\ l_{21} & l_{22} & 0 & \cdots & 0 \\ l_{31} & l_{32} & l_{33} & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ l_{n1} & l_{n2} & l_{n3} & \cdots & l_{nn} \end{matrix} \right)

Thus, we need to determine the elements lijl_{ij}, for i[1,n]i\in[1,n] and j[1,n]j\in[1,n].
A=(a11a12a13...a1na12a22a23...a2na13a23a33...a3n...............a1na2na3n...ann)=LLT A= \left( \begin{matrix} a_{11} & a_{12} & a_{13} & ... & a_{1n} \\ a_{12} & a_{22} & a_{23} & ... & a_{2n} \\ a_{13} & a_{23} & a_{33} & ... & a_{3n} \\ ... & ... & ... & ... & ... \\ a_{1n} & a_{2n} & a_{3n} & ... & a_{nn} \end{matrix} \right)=LL^T

6.7.2 Choleski’s Algorithm

Calculate the value one row by one row

To factor the positive definite nnn*n matrix AA into LLTLL^T, where LL is lower triangular:

  • INPUT: the dimension nn; entries aija_{ij} of AA, for i[1,n]i\in [1,n] and j[1,i]j\in[1,i].

  • OUTPUT: the entries lijl_{ij} of LL, for i[1,n]i\in [1,n] and j[1,i]j\in[1,i].

  • Step 11: Set l11=a11l_{11} = \sqrt{a_{11}}.

  • Step 22: For j[2,n]j\in[2,n], set lj1=a1jl11l_{j1}=\displaystyle\frac{a_{1j}}{l_{11}}

  • Step 33: For i[2,n1]i\in[2,n-1], do Steps 4 and 5.

  • Step 44: Set lii=[aiij=1i1lij2]12l_{ii}=[a_{ii}-\sum_{j=1}^{i-1}l_{ij}^2]^{\frac{1}{2}}.

  • Step 55: For j[i+1,n]j\in[i+1,n], set lji=aijk=1i1likljkliil_{ji}=\displaystyle\frac{a_{ij}-\sum_{k=1}^{i-1}l_{ik}l_{jk}}{l_{ii}}

  • Step 66: Set lnn=[annk=1n1lnk2]12l_{nn}=[a_{nn}-\sum_{k=1}^{n-1}l_{nk}^2]^\frac{1}{2}

  • Step 77: OUTPUT lijl_{ij} for j[1,i]j\in[1,i] and i[1,n]i\in[1,n]. STOP!

Example

数值计算详细笔记(三):非线性方程组解法

6.8 LDLTLDL^T Factorization

6.8.1 Definition

Matrix AA is a positive definite matrix, thus
A=LDLT. A = LDL^T.
数值计算详细笔记(三):非线性方程组解法

数值计算详细笔记(三):非线性方程组解法

We can calculate the value of LL and DD one row by one row.

6.8.2 Algorithm

数值计算详细笔记(三):非线性方程组解法

数值计算详细笔记(三):非线性方程组解法

6.9 Tri-diagonal Linear System

6.9.1 Definition

An nnn*n matrix AA is called a band matrix (带状矩阵), if integers pp and qq, with 1<p,q<n1<p, q<n, exist having the property that aij=0a_{ij}=0 whenever i+pji+p\leq j or j+qij+q\leq i. The bandwidth (带宽) of a band matrix is defined as w=p+q1w=p+q-1.

数值计算详细笔记(三):非线性方程组解法

6.9.2 LU Factorization

A=LU A = LU

数值计算详细笔记(三):非线性方程组解法
数值计算详细笔记(三):非线性方程组解法

In order to solve the problem of Ax=LUx=bAx=LUx=b, there are two steps to do.

  1. z=Uxz = Ux, and solve Lz=bLz=b
  2. solve Ux=zUx=z

6.9.3 Remarks

  1. Band matrices usually are sparse matrices, thus we need to substitute two-dimensional array to one-dimensional array to store the value of the matrices.
  2. Banded matrices appear in numerical calculation methods of partial differential equations and are common matrix forms.