Page 70 - Numerical methods for chemical engineering
P. 70
56 1 Linear algebra
manageable; however, in many problems, elimination cannot be applied because of severe
fill-in.
Boundary value problems in three dimensions, for example, cannot be solved with Gaus-
sian elimination due to fill-in. For a boundary value problem involving a single field on a
regular grid in d dimensions with N grid points in each direction, the following scaling laws
hold for the number of nonzero elements before and after fill-in from elimination:
total number of grid points = N d
d
matrix dimension = N × N d
d 2
total number of elements in A = (N ) = N 2d
number of nonzero elements per row = 1 + 2d
d
total number of nonzero elements in A = N (1 + 2d) (1.261)
−d
fraction of A elements that are nonzero ∝ N
bandwidth of A = N (d−1)
bandwidth of U following elimination = 2N (d−1) + 1
d
number of nonzero elements in U if band is dense = N [2N (d−1) + 1] ∝ N (2d−1)
As the dimension increases, the fill-in problem becomes more acute, and we may not have
enough memory to store even the contents of A. For these reasons, in our later discussion
of boundary value problems (Chapter 6), we consider iterative methods for solving linear
systems that are not susceptible to fill-in and that do not require us even to store in memory
the components of A.
MATLAB summary
The primary tool to solve systems of linear algebraic equations is Gaussian elimination. In
MATLAB, this calculation is performed using the “backslash” operator “\.” The following
code demonstrates its use:
A=[1- 22;31- 4;3- 21];
b = [7; - 3; 8];
x=A\b,
A matrix can be stored either in full format, allocating a memory location for each element,
as above, or in sparse format. To allocate memory for a sparse M × N matrix containing no
more than NZ nonzero elements, use
A = spalloc(M, N, NZ);
The matrix then may be treated essentially as one stored in full format,
N = 100;
A = spalloc(N, N, 3 N);
∗
for k = 1:N
A(k,k) = 2;
if(k > 1)
A(k,k- 1) = - 1