Chapter 11
2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Solving Tridiagonal Systems
(Thomas Algorithm)
A tridiagonal system has a bandwidth of 3
f1 g1 x1 r1 DECOMPOSITION
e x r
2 f2 g2 2 2
e3 f3 g 3 x3 r3 DO k = 2, n
ek = ek / fk-1
e4 f 4 x4 r4 fk = fk - ek gk-1
1 0 0 0 f1 g1 END DO
e' 1 0 0 f 2' g2
A L U 2
0 e'3 1 0 f 3' g3 Time Complexity?
'
0 0 e' 4 1 f4 O(n)
vs. O(n3)
3
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Tridiagonal Systems (cont.)
{d}
1 0 0 0 f1 g1 x1 r1
e' 1 0 0 f 2' g2 x r
2 2 2
0 e'3 1 0 f 3' g3 x3 r3
0 0 e' 4 1 f 4' x4 r4
1 0 0 0 d1 r1 f1 g1 x1 d1
e ' 0 d 2 r2 x d
2 1 0
f 2' g2 2 2
0 e'3 1 0 d 3 r3 f 3' g3 x 3 d 3
'
0 0 e' 4 1 d 4 r4 f 4 x 4 d 4
i 1
aki lijlkj k 1
lkk akk lkj2
j 1
lki for k 1,2,, n i 1,2,, k 1
lii j 1
Time Complexity:
O(n3) but requires half the number of operations as standard Gaussian elimination.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Jacobi Iterative Method
Iterative methods provide an alternative to the elimination methods.
[ D ( A D )] x b Dx b ( A D ) x x D 1[b ( A D ) x ]
k 1 b1 a12 x2k a13 x3k k 1 b2 a21 x1k a23 x3k k 1 b3 a31 x1k a32 x2k
x1 x 2 x 3
a11 a22 a33
Choose an initial guess (i.e. all zeros) and Iterate until the equality is satisfied.
No guarantee for convergence! Each iteration takes O(n2) time! 6
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Gauss-Seidel
• The Gauss-Seidel method is a commonly used iterative method.
b1 a12 x2old a13 x3old • First, choose initial guesses for the x’s.
xnew
1
a11 • A simple way to obtain initial guesses is
to assume that they are all zero.
b2 a 21 x1new a 23 x3old
x 2new • Compute new x1 using the previous
a22 iteration values.
b3 a31 x1new a32 x 2new • New x1 is substituted in the equations to
x3new
a33 calculate x2 and x3
{ X }old { X }new • The process is repeated for x2, x3, …
7
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Convergence Criterion for Gauss-Seidel Method
• Iterations are repeated until the convergence criterion is satisfied:
xij xij 1 For all i, where j and j-1 are
a ,i j
100% s the current and previous iterations.
xi
• Note that this is not a necessary condition, i.e. the system may still have a
chance to converge even if A is not diagonally dominant.
Time Complexity: Each iteration takes O(n2) 8
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.