<< numerical_analysis

Linear Equations Solving

1. Linear Equation Solving by Elimination

We’ve kown that the equations with n-variables {a11x1+a12x2++a1nxn=b1a21x1+a22x2++a2nxn=b2an1x1+an2x2++annxn=bn

can be written in matrix form Ax=b [a11a12a1na21a22a2nan1an2ann][x1x2xn]=[b1b2bn]

where A is coefficient matrix, b is constant vector, and x is solution vector.

Cramer’s rule guarantees that for coefficient matrix A with detA0, the solution exists and is unique: xi=DiD,i=1,2,,n

where Di can be generated by replacing the i-th column of coefficient matrix A with constant vector b.

Although Cramer’s rule plays an important role in thoery of linear equations, the time complexity O(n!×n) of computing determinant makes it not acceptable to apply Cramer’s rule in large scale of linear systems.

# Gaussian Elimination

Gaussian elimination, instead, applies elementary row operation to augmented matrix [Ab]T. It converts the matrix into an upper triangular matrix, after these operations, the equation can be easily solved by substituting (bottom-up). The time complexity of this approach is O(n3).

The Gaussian elimination requires

Δk=|a11a12a1ka21a22a2kak1ak2akk|0

for any k<n. While the solution exists only requires detA0. This indicates that Gaussian elimination cannot be applied to some solvable functions with akk(k1)=0 during the elimination. Besides, the round-off error will increase for small akk(k1).

# Gaussian Elimination with Column Pivoting

To overcome the flaw of Gaussian elimination, the column pivoting operation for each iteration in elimination is proposed. Formally, for each k=1,2,,n1, we search for the element with maximal absolute value |am,k(k1)| within |ak,kk1|,|ak+1,kk1|,|an,kk1|, then we swap row k,m before elimination.

We can solve any linear equations with detA0 with column pivoting. Since the total time complexity of comparison is O(n2), the time complexity of Gaussian elimination with column pivoting is still O(n3).

# Gauss-Jordan Elimination

Gaussian elimination execute substitution process right after the matrix is converted to upper triangular matrix, while we can do further elimination to convert it into a diagonal matrix, which is called Gauss-Jordan elimination.

2. Linear Equation Solving by Matrix Decomposition

# Relation between Line Operation and Matrix Decomposition

An elementary line operation is equivalent to multiply a elementary matrix. The process of Gaussian elimination is equivalent to multiply a matrix T to A, results in a upper triangular matrix: TA=U

Multiply L=T1 on both sides: A=LU where L=T1=[1l211ln1ln21] can be proved to be a lower triangular matrix. The form A=LU indicates that we devide the matrix A into the multiplication of two matrixes L, U. where L and U are lower and upper triangular matrix respectively. Equivalently, we can also decompose A as A=UL.

Since you can move the coefficients from one matrix to another, there are infinite decompositions of form A=LU. If L is contrainted to be the unit lower triangular matrix, that unique decomposition is called Doolittle decomposition. If U is contrainted to be the unit upper triangle matrix, that unique decomposition is called Crout decomposition.

Besides, there are other forms of decomposition such as A=LDMT, where the L,M is lower triangular matrix (hence MT is upper triangular matrix), and D is diagonal matrix. Specially, if A is a positive definite matrix, we have M=L, A=LDLT, this is what we called LDLT decomposition or refined Cholesky decomposition. Let P=LD we have A=PPT, which is called Cholesky decomposition.

The matrix is decomposed into two or three triangular/diagonal matrixes after decomposition, which can be easily solved by substitution. Note that decomposition process is independent of b. Hence if there are multiple equations with same A but various b, this approach reduces the time complexity by cancelling the repetative processing of A.

# LU Decomposition

Compare elements to determine the matrix after Doolittle decomposition:

A=[a11a12a1na21a22a2nan1an2ann]=[1l211ln1ln21][u11u12u1nu22u2nunn]

a11=r=1nl1rur1=[100][u1100]=r=11l1rur1=u11

a1j=r=1nl1rurj=[100][u1ju2j0]=r=11l1rurj=u1j Hence aij=u1j, j=1,2,,n.

akj=r=1nlkrurj=[lk1lk2lk,k1100][u1jujj00]=r=1nlkrurj=r=1k1lkrurj+ukj

Now we have the algorithm for Doolittle decomposition:

Doolittle decomposition algorithm

Refer to https://github.com/revectores/revector for the C++ implementation of Doolittle decomposition.

Refer to https://github.com/revectores/LU-decomposition-impls for some parallelized Doolittle decomposition implemented in C.

Similarly, the algorithm of Crout decomposition:

Doolittle decomposition algorithm

Refer to https://github.com/revectores/revector for the C++ implementation of Crout decomposition.

# Decomposition of Positive Definite Matrix

As mentioned above, we have Cholesky decomposition A=LLT for positive definitive matrix

Cholesky_decomposition_algorithm

In practice we often decompose as form A=LDLT instaed to remove square root computation.

LDLT_decomposition_algorithm

Proof. To prove the existence of LDLT decomposition, we first apply Doolittle decomposition to matrix and extract the diagonal line of U: A=LU=[1l211ln1ln21][u11u12u1nu22u2nunn]=[1l211ln1ln21][u11u22unn][u11u12u1nu22u2nunn]

Since A is symmetric positive definite matrix, we have uii>0. We can prove L=U since A=LU=LDUT=AT=U(DLT) That is, A=LDLT=[1l211ln1ln21][u11u22unn][1l21ln11ln21]

# Condition Number of Matrix

For the non-singular matrix A, we define κp(A)=ApA1p as the condition number of matrix A. Due to the equivalence of different norms, the condition numbers with different norms are also equivalent.

How the error δx is influenced by small disturbance δA in coefficient matrix A is represented as δxxκAδAA1κAδAA How the error δx is influenced by small disturbance δb in constant vector b is represented as δxxκAδbb We call the matrix with large κA ill-conditioned, which states “the small disturbance causes a huge difference in solution”.

3. Linear Equation Solving by Iteration

Transform the equations AX=y into X=MX+g, for any X(0)Rn, construct the iteration X(k+1)=MX(k)+g if the iteration series {X(k)} converges, the limit of iteration series X is the solution of equations AX=y.

In practice, the iteration is terminated once we have X(k+1)X(k)p<ε for some pre-chosen error bound ε, and pick X(k+1) as the approximation of solution.

The convergence of iteration is determined by spectral radius of iteration matrix M. Specifically, the iteration converges if and only if the spectral radius ρ(M)<1.

Proof. If X is the solution of equation AX=y, then X=MX+g

XX(k+1)=M(XXk)=M2(XXk1)==Mk+1(XX(0))

limkMk=0 if and only if ρ(M)<1. Hence we define the matrix with spectral radius less than 1 convergent matrix.

That is, whether the linear equations converges depends on the property of iteration matrix, regardless of the solution α and X(0).

By definition, we have to compute all the eigenvalues to get the spectral radius of matrix. We may simplify this work by computing the norm Ap. Note that Apρ(A), if Ap<1, the iteration matrix must be convergent.

# Jacobi Iteration

{a11x1+a12x2++a1nxn=y1a21x1+a22x2++a2nxn=y2an1x1+an2x2++annxn=yn

{x1=1a11(a12x2a1nxn+y1)x2=1a22(a21x2a2nxn+y2)xn=1ann(an1x2annxn+yn)

The iteration form {x1(k+1)=1a11(a12x2(k)a1nxn(k)+y1)x2(k+1)=1a22(a21x2(k)a2nxn(k)+y2)xn(k+1)=1ann(an1x1kan,n1xn(k)+yn) The matrix form of Jacobi iteration is X(k+1)=BXk+g

where B=ID1A, g=D1y.

There is a shortcut to judge whether Jacobi iteration converges: if the coefficient matrix A meets one of following condition:

The Jacobi iteration must converge. This can be proved by showing the spectral radius of iteration matrix is less than 1.

==TODO: Add the proofs.==

# Gauss-Seidel Iteration

The Gauss-Seidel iteration use those new values computed in current iteration instead of last one: {x1(k+1)=1a11(a12x2(k)a1nxn(k)+y1)x2(k+1)=1a22(a21x2(k+1)a2nxn(k)+y2)xn(k+1)=1ann(an1x1(k+1)an,n1xn1(k+1)+yn) Denote D=[a11a22ann],L=[0a210an1an20],U=[0a12a1n0a2n0] We have AX=(D+L+U)X=(D+L)X+UX=y That is, (D+L)X=UX+y Hence X(k+1)=(D+L)1UX(k)+(D+L)1y Denote S=(D+L)1U,f=(D+L)1y, the Gauss-Seidel iteration can be expressed by Xk+1=SXk+f

# Successive Over-Relaxation

The SOR method is a variant of Gauss-Seidel method resulting in faster convergence: {x1(k+1)=(1ω)x1(k)+ω(b12x2k++b1nxn(k)+g1)x2(k+1)=(1ω)x2(k)+ω(b21x2k++b2nxn(k)+g2)x2(k+1)=(1ω)xn(k)+ω(bn1x2(k+1)++bn,n1xn1(k+1)+gn) where ω is relaxation factor.

The matrix form of SOR is X(k+1)=SωX(k)+f, where Sw=(I+ωD1L)1[(1ω)IωD1U]f=ω(I+ωD1L)Y

Proof. X(k+1)=(1ω)X(k)+ω(L~X(k+1)+U~X(k)+g)(IωL~)X(k+1)=((1ω)I+ωU~)X(k)+ωgX(k+1)=(IωL~)1((1ω)I+ωU~)X(k)+(IωL~)1ωg where L~=D1L,U~=D1U.

The necessary condition that SOR converges is 0<ω<2. Specially, if A is the positive determined matrix, 0<ω<2 is also the sufficient condition.

The iteration is called

The best ω (with fastest convergence speed) is hard to determine for specific equation.