the Linear System of Equations (LSEs):
( I ) { E 1 : a 11 x 1 + a 12 x 2 + . . . + a 1 n x n = b 1 E 2 : a 21 x 1 + a 22 x 2 + . . . + a 2 n x n = b 2 . . . E n : a n 1 x 1 + a n 2 x 2 + . . . + a n n x n = b n (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. (I)⎩⎪⎪⎪⎪⎨⎪⎪⎪⎪⎧E1:E2:...En:a11x1+a12x2+...+a1nxn=b1a21x1+a22x2+...+a2nxn=b2an1x1+an2x2+...+annxn=bn
Multiplied operation - 数乘
Equation E i E_i Ei can be multiplied by any nonzero constant λ \lambda λ
( λ E i ) → E i (\lambda E_i)\rightarrow E_i (λEi)→Ei
Multiplied and added operation - 倍加
Equation E j E_j Ej can be multiplied by any nonzero constant λ \lambda λ, and added to Equation E i E_i Ei in place of E i E_i Ei, denoted by
( λ E j + E i ) → E i (\lambda E_j+E_i)\rightarrow E_i (λEj+Ei)→Ei
Transposition - 交换
Equation E i E_i Ei and E j E_j Ej can be transposed in order, denoted by
E i ↔ E j E_i \leftrightarrow E_j Ei↔Ej
A ~ = [ A , b ] = ( a 11 a 12 . . . a 1 n a 21 a 22 . . . a 2 n . . . . . . . . . . . . a n 1 a n 2 . . . a n n b 1 b 2 . . . b n ) \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 ) A~=[A,b]=⎝⎜⎜⎛a11a21...an1a12a22...an2............a1na2n...annb1b2...bn⎠⎟⎟⎞
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.
INPUT: N N N-dimension, A ( N , N ) , B ( N ) A(N,N), B(N) A(N,N),B(N)
OUTPUT: Solution x ( N ) x(N) x(N) or Message that LESs has no unique solution.
Step 1 1 1: For k = 1 , 2 , . . . , N − 1 k = 1,2,...,N-1 k=1,2,...,N−1, do step 2-4.
Step 2 2 2: Set p p p be the smallest integer with k ≤ p ≤ N k\leq p\leq N k≤p≤N and A p , k ≠ 0 A_{p,k}\not= 0 Ap,k=0. If no p p p can be found, output: “no unique solution exists”; stop.
Step 3 3 3: If p ≠ k p\not=k p=k, do transposition E p ↔ E k E_p\leftrightarrow E_k Ep↔Ek.
Step 4 4 4: For i = k + 1 , . . . , N i=k+1,...,N i=k+1,...,N
Step 5 5 5: If A ( N , N ) ≠ 0 A(N,N)\not=0 A(N,N)=0, set x ( N ) = B ( N ) A ( N , N ) x(N)=\displaystyle\frac{B(N)}{A(N,N)} x(N)=A(N,N)B(N); Else, output:“no unique solution exists.”
Step 6 6 6: For i = N − 1 , N − 2 , . . . , 1 i=N-1,N-2,...,1 i=N−1,N−2,...,1, set
X ( i ) = [ B ( i ) − ∑ j = i + 1 N A ( 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) X(i)=[B(i)−j=i+1∑NA(i,j)x(j)]/A(i,i)
Step 7 7 7: Output the solution x ( N ) x(N) x(N).
According to the process of Gaussian Elimination Method, We find that if a k k ( k − 1 ) a_{kk}^{(k-1)} akk(k−1) is too small, the roundoff error will be larger.
m i , k = A ( i , k ) A ( k , k ) X ( i ) = [ B ( i ) − ∑ j = i + 1 N A ( 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)\\ mi,k=A(k,k)A(i,k)X(i)=[B(i)−j=i+1∑NA(i,j)x(j)]/A(i,i)
Therefore, in order to reduce the roundoff error, we need to make the value of a k k ( k − 1 ) a_{kk}^{(k-1)} akk(k−1) larger.
This method is to make a k k ( k − 1 ) a_{kk}^{(k-1)} akk(k−1) equal to the maximal value in its column.
This method is to make a k k ( k − 1 ) a_{kk}^{(k-1)} akk(k−1) equal to the maximal value in its row.
This method is to make a k k ( k − 1 ) a_{kk}^{(k-1)} akk(k−1) equal to the maximal value in its remaining area.
s i = max 1 ≤ j ≤ n ∣ a i , j ∣ a k k s k = max k ≤ i ≤ n a i , 1 s i 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} si=1≤j≤nmax∣ai,j∣skakk=k≤i≤nmaxsiai,1
This method is to make a k k ( k − 1 ) s k \displaystyle\frac{a_{kk}^{(k-1)}}{s_{k}} skakk(k−1) equal to the maximal value in its remaining area.
A x = b A = L U L = ( 1 0 0 . . . 0 l 21 1 0 . . . 0 l 31 l 32 1 . . . 0 . . . . . . . . . . . . . . . l n 1 l n 2 l n 3 . . . 1 ) , R = ( u 11 u 12 u 13 . . . u 1 n 0 u 22 u 23 . . . u 2 n 0 0 u 33 . . . u 3 n . . . . . . . . . . . . . . . 0 0 0 . . . u n n ) 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) Ax=bA=LUL=⎝⎜⎜⎜⎜⎛1l21l31...ln101l32...ln2001...ln3...............000...1⎠⎟⎟⎟⎟⎞,R=⎝⎜⎜⎜⎜⎛u1100...0u12u220...0u13u23u33...0...............u1nu2nu3n...unn⎠⎟⎟⎟⎟⎞
We can use two-step process to solve L U x = b LUx=b LUx=b.
Theorem
If Gaussian elimination can be performed on the linear system A x = b Ax=b Ax=b without row interchanges, then the matrix A A A can be factored into the product of a lower-triangular L L L and an upper-triangular matrix U U U,
A = L U A=LU A=LU
where
L = ( 1 0 0 . . . 0 m 21 1 0 . . . 0 m 31 m 32 1 . . . 0 . . . . . . . . . . . . . . . m n 1 m n 2 m n 3 . . . 1 ) , R = ( a 11 1 a 12 1 a 13 1 . . . a 1 n 1 0 a 22 2 a 23 2 . . . a 2 n 2 0 0 a 33 3 . . . a 3 n 3 . . . . . . . . . . . . . . . 0 0 0 . . . a n n n ) 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) L=⎝⎜⎜⎜⎜⎛1m21m31...mn101m32...mn2001...mn3...............000...1⎠⎟⎟⎟⎟⎞,R=⎝⎜⎜⎜⎜⎛a11100...0a121a2220...0a131a232a333...0...............a1n1a2n2a3n3...annn⎠⎟⎟⎟⎟⎞
Proof
m j , 1 = a j , 1 a 1 , 1 M 1 = ( 1 0 0 . . . 0 − m 21 1 0 . . . 0 − m 31 0 1 . . . 0 . . . . . . . . . . . . . . . − m n 1 0 0 . . . 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) mj,1=a1,1aj,1M1=⎝⎜⎜⎜⎜⎛1−m21−m31...−mn1010...0001...0...............000...1⎠⎟⎟⎟⎟⎞
Thus,
A n = M n − 1 M n − 2 . . . M 1 A . A^n=M^{n-1}M^{n-2}...M^{1}A. An=Mn−1Mn−2...M1A.
Let U = A n U=A^n U=An, then
[ M 1 ] − 1 . . . [ M n − 2 ] − 1 [ M n − 1 ] − 1 U = A [ M 1 ] − 1 = ( 1 0 0 . . . 0 m 21 1 0 . . . 0 m 31 0 1 . . . 0 . . . . . . . . . . . . . . . m n 1 0 0 . . . 1 ) L = [ M 1 ] − 1 . . . [ M n − 2 ] − 1 [ M n − 1 ] − 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}\\ [M1]−1...[Mn−2]−1[Mn−1]−1U=A[M1]−1=⎝⎜⎜⎜⎜⎛1m21m31...mn1010...0001...0...............000...1⎠⎟⎟⎟⎟⎞L=[M1]−1...[Mn−2]−1[Mn−1]−1
L U = ( 1 0 0 . . . 0 l 21 1 0 . . . 0 l 31 l 32 1 . . . 0 . . . . . . . . . . . . . . . l n 1 l n 2 l n 3 . . . 1 ) ( u 11 u 12 u 13 . . . u 1 n 0 u 22 u 23 . . . u 2 n 0 0 u 33 . . . u 3 n . . . . . . . . . . . . . . . 0 0 0 . . . u n n ) L U = A = ( a 11 a 12 a 13 . . . a 1 n a 21 a 22 a 23 . . . a 2 n a 31 a 32 a 33 . . . a 3 n . . . . . . . . . . . . . . . a n 1 a n 2 a n 3 . . . a n n ) 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) LU=⎝⎜⎜⎜⎜⎛1l21l31...ln101l32...ln2001...ln3...............000...1⎠⎟⎟⎟⎟⎞⎝⎜⎜⎜⎜⎛u1100...0u12u220...0u13u23u33...0...............u1nu2nu3n...unn⎠⎟⎟⎟⎟⎞LU=A=⎝⎜⎜⎜⎜⎛a11a21a31...an1a12a22a32...an2a13a23a33...an3...............a1na2na3n...ann⎠⎟⎟⎟⎟⎞
Algorithm
The n ∗ n n*n n∗n matrix is said to be strictly diagonally dominant (严格对角占优) when
∣ a i i ∣ > ∑ j = 1 , j ≠ i n ∣ a i j ∣ |a_{ii}|>\sum\limits_{j=1,j\not=i}^{n} |a_{ij}| ∣aii∣>j=1,j=i∑n∣aij∣
holds for each i = 1 , 2 , 3 , . . . , n i=1,2,3,...,n i=1,2,3,...,n.
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 A A A is singular means there exists a column vector u u u that A x = 0 Ax=0 Ax=0.
A matrix A A A is positive definite if it is symmetric and if x T A x > 0 x^TAx > 0 xTAx>0 for every n n n-dimensional column vector x ≠ 0 x\not=0 x=0.
If A is an n ∗ n n*n n∗n positive definite matrix, then
For a n ∗ n n*n n∗n symmetric and positive definite matrix A A A with the form
A = ( a 11 a 12 a 13 . . . a 1 n a 12 a 22 a 23 . . . a 2 n a 13 a 23 a 33 . . . a 3 n . . . . . . . . . . . . . . . a 1 n a 2 n a 3 n . . . a n n ) 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) A=⎝⎜⎜⎜⎜⎛a11a12a13...a1na12a22a23...a2na13a23a33...a3n...............a1na2na3n...ann⎠⎟⎟⎟⎟⎞
where A T = A . A^T=A. AT=A. We can factorize this matrix to the form like L L T = A LL^T=A LLT=A, where L L L is a lower triangular matrix with form as follows
( l 11 0 0 ⋯ 0 l 21 l 22 0 ⋯ 0 l 31 l 32 l 33 ⋯ 0 ⋮ ⋮ ⋮ ⋱ ⋮ l n 1 l n 2 l n 3 ⋯ l n n ) \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) ⎝⎜⎜⎜⎜⎜⎛l11l21l31⋮ln10l22l32⋮ln200l33⋮ln3⋯⋯⋯⋱⋯000⋮lnn⎠⎟⎟⎟⎟⎟⎞
Thus, we need to determine the elements l i j l_{ij} lij, for i ∈ [ 1 , n ] i\in[1,n] i∈[1,n] and j ∈ [ 1 , n ] j\in[1,n] j∈[1,n].
A = ( a 11 a 12 a 13 . . . a 1 n a 12 a 22 a 23 . . . a 2 n a 13 a 23 a 33 . . . a 3 n . . . . . . . . . . . . . . . a 1 n a 2 n a 3 n . . . a n n ) = L L T 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 A=⎝⎜⎜⎜⎜⎛a11a12a13...a1na12a22a23...a2na13a23a33...a3n...............a1na2na3n...ann⎠⎟⎟⎟⎟⎞=LLT
Calculate the value one row by one row
To factor the positive definite n ∗ n n*n n∗n matrix A A A into L L T LL^T LLT, where L L L is lower triangular:
INPUT: the dimension n n n; entries a i j a_{ij} aij of A A A, for i ∈ [ 1 , n ] i\in [1,n] i∈[1,n] and j ∈ [ 1 , i ] j\in[1,i] j∈[1,i].
OUTPUT: the entries l i j l_{ij} lij of L L L, for i ∈ [ 1 , n ] i\in [1,n] i∈[1,n] and j ∈ [ 1 , i ] j\in[1,i] j∈[1,i].
Step 1 1 1: Set l 11 = a 11 l_{11} = \sqrt{a_{11}} l11=a11.
Step 2 2 2: For j ∈ [ 2 , n ] j\in[2,n] j∈[2,n], set l j 1 = a 1 j l 11 l_{j1}=\displaystyle\frac{a_{1j}}{l_{11}} lj1=l11a1j
Step 3 3 3: For i ∈ [ 2 , n − 1 ] i\in[2,n-1] i∈[2,n−1], do Steps 4 and 5.
Step 4 4 4: Set l i i = [ a i i − ∑ j = 1 i − 1 l i j 2 ] 1 2 l_{ii}=[a_{ii}-\sum_{j=1}^{i-1}l_{ij}^2]^{\frac{1}{2}} lii=[aii−∑j=1i−1lij2]21.
Step 5 5 5: For j ∈ [ i + 1 , n ] j\in[i+1,n] j∈[i+1,n], set l j i = a i j − ∑ k = 1 i − 1 l i k l j k l i i l_{ji}=\displaystyle\frac{a_{ij}-\sum_{k=1}^{i-1}l_{ik}l_{jk}}{l_{ii}} lji=liiaij−∑k=1i−1likljk
Step 6 6 6: Set l n n = [ a n n − ∑ k = 1 n − 1 l n k 2 ] 1 2 l_{nn}=[a_{nn}-\sum_{k=1}^{n-1}l_{nk}^2]^\frac{1}{2} lnn=[ann−∑k=1n−1lnk2]21
Step 7 7 7: OUTPUT l i j l_{ij} lij for j ∈ [ 1 , i ] j\in[1,i] j∈[1,i] and i ∈ [ 1 , n ] i\in[1,n] i∈[1,n]. STOP!
Example
Matrix A A A is a positive definite matrix, thus
A = L D L T . A = LDL^T. A=LDLT.
We can calculate the value of L L L and D D D one row by one row.
An n ∗ n n*n n∗n matrix A A A is called a band matrix (带状矩阵), if integers p p p and q q q, with 1 < p , q < n 1 1<p,q<n
A = L U A = LU A=LU
In order to solve the problem of A x = L U x = b Ax=LUx=b Ax=LUx=b, there are two steps to do.