17.11.2012 Views

Numerical recipes

Numerical recipes

Numerical recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

830 Chapter 19. Partial Differential Equations<br />

In contrast to initial value problems, stability is relatively easy to achieve<br />

for boundary value problems. Thus, the efficiency of the algorithms, both in<br />

computational load and storage requirements, becomes the principal concern.<br />

Because all the conditions on a boundary value problem must be satisfied<br />

“simultaneously,” these problems usually boil down, at least conceptually, to the<br />

solution of large numbers of simultaneous algebraic equations. When such equations<br />

are nonlinear, they are usually solved by linearization and iteration; so without much<br />

loss of generality we can view the problem as being the solution of special, large<br />

linear sets of equations.<br />

As an example, one which we will refer to in §§19.4–19.6 as our “model<br />

problem,” let us consider the solution of equation (19.0.3) by the finite-difference<br />

method. We represent the function u(x, y) by its values at the discrete set of points<br />

xj = x0 + j∆, j =0, 1, ..., J<br />

yl = y0 + l∆, l =0, 1, ..., L<br />

(19.0.4)<br />

where ∆ is the grid spacing. From now on, we will write u j,l for u(xj,yl), and<br />

ρj,l for ρ(xj,yl). For (19.0.3) we substitute a finite-difference representation (see<br />

Figure 19.0.2),<br />

uj+1,l − 2uj,l + uj−1,l<br />

∆2 or equivalently<br />

+ uj,l+1 − 2uj,l + uj,l−1<br />

∆ 2 = ρj,l (19.0.5)<br />

uj+1,l + uj−1,l + uj,l+1 + uj,l−1 − 4uj,l =∆ 2 ρj,l<br />

(19.0.6)<br />

To write this system of linear equations in matrix form we need to make a<br />

vector out of u. Let us number the two dimensions of grid points in a single<br />

one-dimensional sequence by defining<br />

i ≡ j(L +1)+l for j =0, 1, ..., J, l =0, 1, ..., L (19.0.7)<br />

In other words, i increases most rapidly along the columns representing y values.<br />

Equation (19.0.6) now becomes<br />

ui+L+1 + u i−(L+1) + ui+1 + ui−1 − 4ui =∆ 2 ρi<br />

(19.0.8)<br />

This equation holds only at the interior points j =1, 2, ..., J − 1; l =1, 2, ...,<br />

L − 1.<br />

The points where<br />

j =0<br />

j = J<br />

l =0<br />

l = L<br />

[i.e., i =0, ..., L]<br />

[i.e., i = J(L +1), ..., J(L +1)+L]<br />

[i.e., i =0,L+1, ..., J(L +1)]<br />

[i.e., i = L, L +1+L, ..., J(L +1)+L]<br />

(19.0.9)<br />

Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)<br />

Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by <strong>Numerical</strong> Recipes Software.<br />

Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable<br />

files (including this one) to any server computer, is strictly prohibited. To order <strong>Numerical</strong> Recipes books or CDROMs, visit website<br />

http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!