Homework 3 (Due 2/7.)

advertisement
Homework 3 (Due 2/7.)
Math. 639
This assignment compares the Gauss-Seidel method against the SOR
method with a near optimal choice of parameter.
We consider solving the variable coefficient problem on the unit square,
i.e.,
−
∂
∂u(x)
∂
∂u(x)
a1 (x)
−
a2 (x)
= f, for x = (x1 , x2 ) in (0, 1)2
∂x1
∂x1
∂x2
∂x2
u(x) = 0, for x1 = 0 or 1 or x2 = 0 or 1.
Its finite difference approximation is of the form
a1 (xi+1/2,j )(uhi,j − uhi+1,j ) + a1 (xi−1/2,j )(uhi,j − uhi−1,j )
(0.1)
h
h
h
h
+a2 (xi,j+1/2 )(ui,j − ui,j+1 ) + a2 (xi,j−1/2 )(ui,j − ui,j−1 ) = h2 f (xi,j ),
for i, j = 1, 2, . . . , n. The CRS files for the problem with coefficients given by
a1 (x) = 1 + x1 x2 and a2 (x) = 1 − (x21 + x22 )/3 are given below. In this case,
we have 1 ≤ a1 (x) ≤ 2 and 1/3 ≤ a2 (x) ≤ 1. The corresponding matrix will
e5 .
be denoted A
n=32: crsvc1
n=64: crsvc2
n=128: crsvc3
n=256: crsvc4
To do this problem, you need to implement SOR, i.e., the iteration
(ω −1 D + L)xj+1 = ((ω −1 − 1)D − U )xj + b.
This method can be implemented as a sweep and is a simple modification of
the Gauss-Seidel sweep, in fact, Gauss-Seidel is the case of ω = 1. You need
to develop a procedure which implements this sweep, each call subsequently
transforming xj into xj+1 .
Run Gauss-Seidel on this problem for each case above (ω = 1). As usual,
e5 x = 0 and
use (1, 1, . . . , 1)t as your initial iterate for solving the problem A
report the number of iterations needed to reduce the error by .001 in the
k · k∞ norm.
1
2
For a near optimal choice of parameter, we take
2
.
ω=
1 + sin(π/(n + 1))
The motivation for this choice of ω is discussed in Section 6 of the notes.
Run SOR on each problem with the corresponding choice of ω and report
the number of iterations needed to reduce the k · k∞ error by a factor of
10−3 .
Download