21.06.2014 Views

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

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.

Ax = b :<br />

1 LU-decomposition A = LU, #elementary operations 1 3n(n − 1)(n + 1)<br />

2 forward substitution, solve Lz = b, #elementary operations 1 2n(n − 1)<br />

3 backward substitution, solve Ux = z, #elementary operations 1 2n(n + 1)<br />

(in leading order) the same as for Gaussian elimination<br />

Remark 2.2.6 (Many sequential solutions of LSE).<br />

With A 11 ∈ K n,n regular, A 12 ∈ K n,m , A 21 ∈ K m,n , A 22 ∈ K m,m :<br />

( ) ( ) ( )<br />

A11 A 12 I 0 A11 A Schur complement<br />

=<br />

12<br />

A 21 A 22 A 21 A −1<br />

,<br />

11 I 0 S S := A 22 − A 21 A −1<br />

11 A 12<br />

→ block Gaussian elimination, see Rem. 2.1.4.<br />

(2.2.2)<br />

△<br />

Given:<br />

regular matrix A ∈ K n,n , n ∈ N, and N ∈ N, both n,N large<br />

foolish !<br />

1 % Setting: N ≫ 1, large matrix A<br />

2 for j =1:N<br />

3 x = A\ b ;<br />

4 b = some_function ( x ) ;<br />

5 end<br />

computational effort O(Nn 3 )<br />

smart !<br />

1 % Setting: N ≫ 1, large matrix A<br />

2 [ L ,U] = lu (A) ;<br />

3 for j =1:N<br />

4 x = U \ ( L \ b ) ;<br />

5 b = some_function ( x ) ;<br />

6 end<br />

Ôº¿ ¾º¾<br />

+ N backward substitutions (cost Nn 2 )<br />

computational effort O(n 3 + Nn 2 )<br />

Efficient implementation requires one LU-decomposition of A (cost O(n 3 )) + N forward substitutions<br />

Remark 2.2.7 ("‘Partial LU-decompositions” of principal minors).<br />

⎛<br />

⎜<br />

⎝<br />

⎞<br />

⎛<br />

=<br />

⎟ ⎜<br />

⎠ ⎝<br />

0<br />

⎞ ⎛<br />

⎟ ⎜<br />

⎠ ⎝ 0<br />

The left-upper blocks of both L and U in the LU-factorization of A depend only on the corresponding<br />

left-upper block of A!<br />

⎞<br />

⎟<br />

⎠<br />

△<br />

2.3 Pivoting<br />

Known from linear algebra:<br />

( ) ( ) ( ) ( )( ) ( )<br />

0 1 x1 b1<br />

1 0 x1 b2<br />

= =<br />

1 0 x 2 b 2 0 1 x 2 b 1<br />

Idea (in linear algebra):<br />

breakdown of Gaussian elimination<br />

pivot element = 0<br />

Example 2.3.1 (Pivoting and numerical stability).<br />

1 % Example: numerical instability without pivoting<br />

2 A = [ 5 . 0 E−17 , 1 ; 1 , 1 ] ;<br />

3 b = [ 1 ; 2 ] ;<br />

4 x1 = A \ b ,<br />

5 x2 =gausselim (A, b ) , % see Code 2.1.5<br />

6 [ L ,U] = l u f a k (A) ; % see Code 2.2.1<br />

7 z = L \ b ; x3 = U\ z ,<br />

A =<br />

( )<br />

ǫ 1<br />

1 1<br />

Gaussian elimination feasible<br />

Avoid zero pivot elements by swapping rows<br />

(<br />

1<br />

, b =<br />

2)<br />

⎛<br />

⇒ x = ⎜<br />

⎝<br />

1<br />

1 − ǫ<br />

1 − 2ǫ<br />

1 − ǫ<br />

⎞<br />

( )<br />

⎟ 1<br />

⎠ ≈ 1<br />

Ouput of MATLAB run:<br />

x1 = 1<br />

1<br />

x2 = 0<br />

1<br />

x3 = 0<br />

1<br />

for |ǫ| ≪ 1 .<br />

What is wrong with MATLAB? Needed: insight into roundoff errors → Sect. 2.4<br />

Ôº ¾º¿<br />

△<br />

Remark 2.2.8. Block matrix multiplication (1.2.3) ∼ = block LU-decomposition:<br />

Ôº ¾º¾<br />

Straightforward LU-factorization: if ǫ ≤ 1 2eps,eps ˆ= machine precision,<br />

( ) ( ) ( )<br />

1 0 ǫ 1 (∗) ǫ 1<br />

L =<br />

ǫ −1 , U =<br />

1 0 1 − ǫ −1 = Ũ := 0 −ǫ −1<br />

(∗): because 1˜+2/eps = 2/eps, see Rem. 2.4.9.<br />

in M ! (2.3.1)<br />

Ôº ¾º¿

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

Saved successfully!

Ooh no, something went wrong!