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.

Remark 4.3.7 (Termination of PCG).<br />

Rem. 4.2.3, (4.2.11) ➤ Monitor transformed residual<br />

˜r = ˜b − Øx = B−1/2 r ⇒ ‖˜r‖ 2 2 = rT B −1 r .<br />

Estimates for energy norm of error e (l) := x − x (l) , x ∗ := A −1 b<br />

Use error equation Ae (l) = r l :<br />

r T l B−1 r l = (B −1 Ae (l) ) T Ae (l) ≤ λ max (B −1 ∥<br />

A) ∥e (l)∥ ∥2<br />

, A ∥<br />

∥e (l)∥ ∥2<br />

= A (Ae(l) ) T e (l) = r T l A−1 r l = B −1 r T BA −1 r l ≤ λ max (BA −1 ) (B −1 r l ) T r l .<br />

available during PCG iteration (4.3.2)<br />

MATLAB PCG algorithm<br />

function x = pcg(Afun,b,tol,maxit,Binvfun,x0)<br />

x = x0; r = b - feval(Afun,x); rho = 1;<br />

for i = 1 : maxit<br />

y = feval(Binvfun,r);<br />

rho1 = rho; rho = r’ * y;<br />

if (i == 1)<br />

p = y;<br />

else<br />

beta = rho / rho1;<br />

p = y + beta * p;<br />

end<br />

q = feval(Afun,p);<br />

alpha = rho /(p’ * q);<br />

x = x + alpha * p;<br />

if (norm(b - evalf(Afun,x))

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

Saved successfully!

Ooh no, something went wrong!