14.11.2013 Views

GS534: Solving the 1D Poisson equation using finite differences ...

GS534: Solving the 1D Poisson equation using finite differences ...

GS534: Solving the 1D Poisson equation using finite differences ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Lv = f<br />

(19a)<br />

followed by finding <strong>the</strong> solution u from<br />

Uu = f<br />

(19b)<br />

Once <strong>the</strong> decomposition is known it is easy to find v by solving (19a) with forward substitution:<br />

v 1 = f 1<br />

L 11<br />

v i = 1 ⎡<br />

⎢⎣ f i − i−1 ⎤<br />

L ii<br />

Σ L ij v j ⎥⎦<br />

j=1<br />

and solving (19b) for u by backsubstitution:<br />

u N =<br />

y N<br />

U NN<br />

u i = 1<br />

U ii<br />

⎡<br />

⎢⎣ y i −<br />

N<br />

j=i+1<br />

i = 2, 3, ..., N<br />

Σ U ij u j<br />

⎤<br />

⎥⎦ i = N − 1, N − 2, . . . . , 1<br />

(20a)<br />

(20b)<br />

(19a)<br />

(19b)<br />

Example:<br />

Consider <strong>the</strong> matrix-vector <strong>equation</strong><br />

⎡ 6 3 ⎤ ⎡ u 1<br />

⎤<br />

⎢ ⎥ ⎢ ⎥⎦ = ⎡ 3 ⎤<br />

⎢ ⎥<br />

⎣<br />

2 13<br />

⎦ ⎣<br />

u 2 ⎣<br />

−11<br />

⎦<br />

We can show that <strong>the</strong> LU decomposition can be written as<br />

⎡ 6 3 ⎤<br />

⎢ ⎥ = ⎡ 3 0 ⎤ ⎡ 2 1 ⎤<br />

⎢ ⎥ ⎢ ⎥ =<br />

⎣<br />

2 13<br />

⎦ ⎣<br />

1 3<br />

⎦ ⎣<br />

0 4<br />

⎦<br />

so that, <strong>using</strong> <strong>the</strong> notation in (18) and (19)<br />

and<br />

v = [1, −4] T<br />

u = [1, −1] T<br />

(verify). The decomposition into LU follows from Crout’s algorithm which can replace <strong>the</strong><br />

matrix A in memory with <strong>the</strong> upper and lower triangular matrices U and L (e.g, Press et al.,<br />

1992).<br />

4.4. Practical implementation of routines for Gaussian elimination<br />

The algorithms for Gaussian elimination are implemented in a variety of standard libraries and<br />

packages and it’s generally not necessary to write user programs for <strong>the</strong>se algorithms. A particular<br />

class of subroutines for <strong>the</strong> solution of problems arising from linear algebra is LINPACK<br />

(www.netlib.org/LINPACK) which was developed in <strong>the</strong> 70s and 80s and is now largely superseded<br />

by LAPACK (www.netlib.org/LAPACK), but <strong>the</strong> name linpack still exists as a ’generic’<br />

term. Most algorithms make extensive use of vector algebra, including <strong>the</strong> inner (dot) product and<br />

outer product. These are generally available in to programmers by calls to <strong>the</strong> BLAS (Basic<br />

(20)<br />

(21)<br />

(22)<br />

8

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

Saved successfully!

Ooh no, something went wrong!