UCES
Course: Methods and Analysis in UCES
Prerequisites:
Objectives:
General Information: This is an introduction to the Gaussian elimination algorithm. Not all the details of row operations and pivoting are discussed. In the next section ill-conditioned problems will be described.
Contact Person: R. E. White, NCSU, white@math.ncsu.edu
Revision Date: 7-28-94
Copyright ©1994, R. E. White. All rights reserved.
In the application to circuits the algebraic system had a matrix which was not initially upper triangular. We converted it to a system which had an upper triangular matrix by adding and subtracting appropriate rows or equations in the system. We want to make this a systematic procedure so that it can be applied to larger algebraic systems using computers.
A first step is to reduce the notational burden. Note that the position of all the xi was always the same. So, henceforth, we will simply delete them. The entries in the n by n matrix A and the entries in the n by 1 column vector d may be combined into the n by n+1 augmented matrix
For example, the augmented matrix in the circuit problem is
Each row of the augmented matrix represents an equation in the algebraic system.
The next step was to add or subtract multiples of rows to get all zeros in the lower triangular part of the matrix. There are three basic row operations:
We used a combination of (ii) and (iii). Each row operation is equivalent to a multiplication by an elementary matrix.
Example. Consider the above problem.
First, subtract 1/2 of row 1 from row 3 to get a zero in the (3,1) position:
Second, add 2/3 of row 2 to row 3 to get a zero in the (3,2) position:
It is customary to write this as
Each elementary row operation can be reversed, and this has the form of a matrix inverse of each elementary matrix:
Note that A = LU where
| (E1-1E2-1)(EA) | = (E1-1E2-1)((E2E1)A) |
| = ((E1-1E2-1)(E2E1))A | |
| = (E1-1(E2-1(E2E1)))A | |
| = (E1-1((E2-1E2)E1))A | |
| = (E1-1E1)A | |
| = A. |
The product L = E1E2 is a lower triangular matrix and
Definition. An n by n matrix, A, has an inverse n by n matrix, A-1 , if and only if
Basic Properties. Let A be an n by n matrix which has an inverse.
We will later discuss these properties in more detail. Note, given an inverse matrix one can solve the associated linear system. Conversely, if one can solve the linear problems in property 4 via Gaussian elimination, then one can find the inverse matrix. Also one can use the elementary matrices to find the LU factorizations and the inverses of L and U; now, apply property 3 to find the inverse of A.
Steady state solutions have models which are also derived from Fourier's heat
law. The difference now is that the change, with respect to time, in the heat
content is zero. Also the temperature is a function of just space so that
![]() |
| Figure: Heat Diffusion in a Thin Wire |
The heat diffusing in the right face (when (ui+1 - ui)/h > 0) is
The heat diffusing out the left face (when (ui - ui-1)/h > 0) is
Therefore, the heat from diffusion is
The heat from the source is
By combining these we have the following approximation of the change in the heat content for the small volume Ah:
Now, divide by Ah dt , let ß = K/h2, and we have the following n-1 unknowns and n-1 equations.
Finite Difference Equations for Heat Transfer.
| (1) | |
| where | |
| (2) | |
Equation (2) is the temperature at the left and right ends set equal to zero.
The finite difference model may be written in matrix form where the matrix is a tridiagonal matrix. For example, if n = 4, then we are dividing the wire into four equal parts and there will be 3 unknowns with the end temperatures set equal to zero.
Tridiagonal Algebraic System: n = 4.
Suppose the length of the wire is 1 so that h = 1/4, and the thermal
conductivity is .001. Then
Forward Sweep (put into upper triangular form):
Add 1/2(row 1) to (row 2),
Add 2/3(row 2) to (row 3),
Backward Sweep (solve the triangular system):
Tridiagonal matrices often factor into lower and upper triangular matrices with two diagonals. Later we will learn how to take advantage of this nice structure.
The general Gaussian elimination method requires the augmented matrix, forward sweep to convert the problem to upper triangular form, and the backward sweep to solve this upper triangular system. The row operations needed to form the upper triangular system must be done in a systematic way:
This is depicted in the following figure where the (i,j) component is about to be set to zero.
![]() |
| Figure: Gaussian Elimination |
Gaussian Elimination Algorithm.
define the augmented matrix [A d]
for j = 1,n-1
for i = j+1,n (forward sweep)
add multiple of (row j) to (row i) to get a zero in the (i,j) position
endloop
endloop
for i = n,1 (backward sweep)
solve for xi using row i
endloop.
The above description is not very complete. In the forward sweep more details and special considerations with regard to roundoff errors are essential. The backward sweep is just the upper triangular solve step, and two versions of this were studied in the previous section.
Maple has a number of intrinsic procedures which are useful for illustration of Gaussian elimination. These include linsolve, augment, gausselim, backsub, pivot, addrow and others.
First, we use linsolve which is a combination of the forward and backward sweeps.
Maple Code and Intrinsic Procedures.
Input Data:
>n:=4.:
> h:=1/(n+1):
> K:=.001:
> beta:=K/(h*h):
> with(linalg):
> d:=vector([1/beta,1/beta,1/beta,1/beta]);
> A:=matrix(4,4,[2,-1,0,0, -1,2,-1,0, 0,-1,2,-1, 0,0,-1,2]);
Call to linsolve:
> temp:=linsolve(A,d);
Output Data:
Second, we use a combination of intrinsic procedures. The procedure augment forms the augmented matrix. The procedure gausselim does the forward elimination sweep which is the row operations to get zeros in the lower triangular part of the augmented matrix. And, the procedure backsub does the backward sweep to solve the upper triangular problem.
Define Augmented Matrix:
> Aug:=augment(A,d);
Forward Sweep:
> UD:=gausselim(Aug);
Backward Sweep:
> temp:=backsub(UD);
.
Matlab Code for Linear Solves (heatgelm.m) with Variable n.
n = 4
h = 1./(n+1)
K = .001;
beta = K/(h*h);
A= zeros(n,n);
for i=1:n
d(i) = 1/beta;
A(i,i) = 2;
if i<n
A(i,i+1) = -1;
end;
if i>1
A(i,i-1) = -1;
end;
end
d = d'
A
temp = A\d
Output for n = 4:
temp =
80.0000
120.0000
120.0000
80.0000
Output for n = 8:
temp =
49.3827
86.4198
111.1111
123.4568
123.4568
111.1111
86.4198
49.3827
Output for n = 16:
temp =
27.6817
51.9031
72.6644
89.9654
103.8062
114.1869
121.1073
124.5675
124.5675
121.1073
114.1869
103.8062
89.9654
72.6644
51.9031
27.6817
The above model for heat conduction depends upon the
mesh size, h, but as the mesh size h goes to zero there will be little
difference in the computed solutions. For example in the Matlab output, the
ith component of temp is the approximate temperature at ih where
The four basic properties of inverse matrices needs some justification.
Proof that inverse are unique:
Let B and C be inverses of A so that AB = BA = I and AC = CA = I.
Subtract these matrix equations and use the distributive property
- AB - AC = I - I = 0
- A(B - C) = 0.
Use B is an inverse of A and use the associative property
- B(A(B - C)) = B0 = 0
- (BA)(B - C) = 0
- B - C = 0.
Proof that A-1d is a solution of Ax = d:
Let x = A-1d and again use the associative property
- A(A-1d) = (AA-1)d = I d = d.
Proofs of properties 3 and 4 are also a consequence of the associative property.