Skip to content

Commit 262f9a4

Browse files
committed
Website build
1 parent 2336de7 commit 262f9a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4719
-1794
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: d22bf392ac5466eace936293413c78ce
3+
config: 11becc8b83db97df9a9b4c09f88adc4c
44
tags: 645f666f9bcd5a90fca523b33c5a78b7
616 KB
Binary file not shown.

L0_setup.html

Lines changed: 517 additions & 0 deletions
Large diffs are not rendered by default.

L1_preliminaries.html

Lines changed: 84 additions & 60 deletions
Large diffs are not rendered by default.

L2_QR_factorisation.html

Lines changed: 117 additions & 72 deletions
Large diffs are not rendered by default.

L3_analysing_algorithms.html

Lines changed: 86 additions & 166 deletions
Large diffs are not rendered by default.

L4_LU_decomposition.html

Lines changed: 81 additions & 78 deletions
Large diffs are not rendered by default.

L5_eigenvalues.html

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

L6_krylov.html

Lines changed: 74 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta charset="utf-8" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
88

9-
<title>6. Iterative Krylov methods for \(Ax=b\) &#8212; Computational linear algebra course 2020.0 documentation</title>
9+
<title>6. Iterative Krylov methods for \(Ax=b\) &#8212; Computational linear algebra course 2023.0 documentation</title>
1010
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
1111
<link rel="stylesheet" type="text/css" href="_static/fenics.css" />
1212
<link rel="stylesheet" type="text/css" href="_static/proof.css" />
@@ -18,6 +18,7 @@
1818
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
1919
<link rel="index" title="Index" href="genindex.html" />
2020
<link rel="search" title="Search" href="search.html" />
21+
<link rel="next" title="7. Preconditioning Krylov methods" href="L7_preconditioning.html" />
2122
<link rel="prev" title="5. Finding eigenvalues of matrices" href="L5_eigenvalues.html" />
2223
<!--[if lte IE 6]>
2324
<link rel="stylesheet" href="_static/ie6.css" type="text/css" media="screen" charset="utf-8" />
@@ -156,10 +157,10 @@ <h2><span class="section-number">6.2. </span>Arnoldi iteration<a class="headerli
156157
<span class="proof-type">Exercise 6.1</span>
157158

158159
</div><div class="proof-content">
159-
<p>The <a class="reference internal" href="cla_utils.html#cla_utils.exercises10.arnoldi" title="cla_utils.exercises10.arnoldi"><code class="xref py py-func docutils literal notranslate"><span class="pre">cla_utils.exercises10.arnoldi()</span></code></a> function has been left
160-
unimplemented. It should implement the Arnoldi algorithm using
161-
Numpy array operations where possible, and return the <span class="math notranslate nohighlight">\(Q\)</span> and <span class="math notranslate nohighlight">\(H\)</span>
162-
matrices after the requested number of iterations is complete.
160+
<p><span class="math notranslate nohighlight">\((\ddagger)\)</span> The <a class="reference internal" href="cla_utils.html#cla_utils.exercises10.arnoldi" title="cla_utils.exercises10.arnoldi"><code class="xref py py-func docutils literal notranslate"><span class="pre">cla_utils.exercises10.arnoldi()</span></code></a> function has
161+
been left unimplemented. It should implement the Arnoldi algorithm
162+
using Numpy array operations where possible, and return the <span class="math notranslate nohighlight">\(Q\)</span> and
163+
<span class="math notranslate nohighlight">\(H\)</span> matrices after the requested number of iterations is complete.
163164
What is the minimal number of Python for loops possible?</p>
164165
<p>The test
165166
script <code class="docutils literal notranslate"><span class="pre">test_exercises10.py</span></code> in the <code class="docutils literal notranslate"><span class="pre">test</span></code> directory will test
@@ -276,25 +277,26 @@ <h2><span class="section-number">6.3. </span>GMRES<a class="headerlink" href="#g
276277
<span class="proof-type">Exercise 6.2</span>
277278

278279
</div><div class="proof-content">
279-
<p>The <a class="reference internal" href="cla_utils.html#cla_utils.exercises10.GMRES" title="cla_utils.exercises10.GMRES"><code class="xref py py-func docutils literal notranslate"><span class="pre">cla_utils.exercises10.GMRES()</span></code></a> function has been left
280-
unimplemented. It should implement the basic GMRES algorithm above,
281-
using one loop over the iteration count. You can paste code from
282-
your <a class="reference internal" href="cla_utils.html#cla_utils.exercises10.arnoldi" title="cla_utils.exercises10.arnoldi"><code class="xref py py-func docutils literal notranslate"><span class="pre">cla_utils.exercises10.arnoldi()</span></code></a> implementation, and you
283-
should use your least squares code to solve the least squares
284-
problem. The test script <code class="docutils literal notranslate"><span class="pre">test_exercises10.py</span></code> in the <code class="docutils literal notranslate"><span class="pre">test</span></code>
285-
directory will test this function.</p>
280+
<p><span class="math notranslate nohighlight">\((\ddagger)\)</span> The <a class="reference internal" href="cla_utils.html#cla_utils.exercises10.GMRES" title="cla_utils.exercises10.GMRES"><code class="xref py py-func docutils literal notranslate"><span class="pre">cla_utils.exercises10.GMRES()</span></code></a> function has
281+
been left unimplemented. It should implement the basic GMRES
282+
algorithm above, using one loop over the iteration count. You can
283+
paste code from your <a class="reference internal" href="cla_utils.html#cla_utils.exercises10.arnoldi" title="cla_utils.exercises10.arnoldi"><code class="xref py py-func docutils literal notranslate"><span class="pre">cla_utils.exercises10.arnoldi()</span></code></a>
284+
implementation, and you should use your least squares code to solve
285+
the least squares problem. The test script <code class="docutils literal notranslate"><span class="pre">test_exercises10.py</span></code>
286+
in the <code class="docutils literal notranslate"><span class="pre">test</span></code> directory will test this function.</p>
286287
</div></div><div class="proof proof-type-exercise" id="id3">
287288

288289
<div class="proof-title">
289290
<span class="proof-type">Exercise 6.3</span>
290291

291292
</div><div class="proof-content">
292-
<p>The least squares problem in GMRES requires the QR factorisation of
293-
<span class="math notranslate nohighlight">\(H_k\)</span>. It is wasteful to rebuild this from scratch given that we
294-
just computed the QR factorisation of <span class="math notranslate nohighlight">\(H_{k-1}\)</span>. Modify your code
295-
so that it recycles the QR factorisation, applying just one extra
296-
Householder rotation per GMRES iteration. Don’t forget to check
297-
that it still passes the test.</p>
293+
<p><span class="math notranslate nohighlight">\((\ddagger)\)</span> The least squares problem in GMRES requires the QR
294+
factorisation of <span class="math notranslate nohighlight">\(H_k\)</span>. It is wasteful to rebuild this from scratch
295+
given that we just computed the QR factorisation of
296+
<span class="math notranslate nohighlight">\(H_{k-1}\)</span>. Modify your code so that it recycles the QR
297+
factorisation, applying just one extra Householder rotation per
298+
GMRES iteration. Don’t forget to check that it still passes the
299+
test.</p>
298300
</div></div><div class="admonition hint">
299301
<p class="admonition-title">Hint</p>
300302
<p>Don’t get confused by the two Q matrices involved in GMRES! There
@@ -363,13 +365,15 @@ <h2><span class="section-number">6.4. </span>Convergence of GMRES<a class="heade
363365
well-conditioned, and <span class="math notranslate nohighlight">\(p(x)\)</span> is small for all <span class="math notranslate nohighlight">\(x\in \Lambda(A)\)</span>. This
364366
latter condition is not trivial due to the <span class="math notranslate nohighlight">\(p(0)=1\)</span> requirement. One
365367
way it can happen is if <span class="math notranslate nohighlight">\(A\)</span> has all eigenvalues clustered in a small
366-
number of groups. Then we can find a low degree polynomial that passes
367-
through 1 at <span class="math notranslate nohighlight">\(x=0\)</span>, and 0 near each of the clusters. Then GMRES will
368-
essentially converge in a small number of iterations (equal to the
369-
degree of the polynomial). There are problems if the eigenvalues are
370-
scattered over a wide region of the complex plane: we need a very
371-
high degree polynomial to make <span class="math notranslate nohighlight">\(p(x)\)</span> small at all the eigenvalues and
372-
hence we need a very large number of iterations.</p>
368+
number of groups, away from $0$. Then we can find a low degree
369+
polynomial that passes through 1 at <span class="math notranslate nohighlight">\(x=0\)</span>, and 0 near each of the
370+
clusters. Then GMRES will essentially converge in a small number of
371+
iterations (equal to the degree of the polynomial). There are problems
372+
if the eigenvalues are scattered over a wide region of the complex
373+
plane: we need a very high degree polynomial to make <span class="math notranslate nohighlight">\(p(x)\)</span> small at
374+
all the eigenvalues and hence we need a very large number of
375+
iterations. Similarly there are problems if eigenvalues are very close
376+
to zero.</p>
373377
<div class="proof proof-type-exercise" id="id4">
374378

375379
<div class="proof-title">
@@ -385,8 +389,8 @@ <h2><span class="section-number">6.4. </span>Convergence of GMRES<a class="heade
385389
What do you observe? What is it about the three matrices that
386390
causes this different behaviour?</p>
387391
</div></div></section>
388-
<section id="preconditioning">
389-
<h2><span class="section-number">6.5. </span>Preconditioning<a class="headerlink" href="#preconditioning" title="Permalink to this headline"></a></h2>
392+
<section id="preconditioned-gmres">
393+
<h2><span class="section-number">6.5. </span>Preconditioned GMRES<a class="headerlink" href="#preconditioned-gmres" title="Permalink to this headline"></a></h2>
390394
<details>
391395
<summary>
392396
Supplementary video</summary><div class="video_wrapper" style="">
@@ -395,24 +399,24 @@ <h2><span class="section-number">6.5. </span>Preconditioning<a class="headerlink
395399
over the last 30 years. Typically, the matrices that we want to solve
396400
do not have eigenvalues clustered in a small number of groups, and so
397401
GMRES is slow. The solution (and the challenge) is to find a matrix
398-
<span class="math notranslate nohighlight">\(M\)</span> such that <span class="math notranslate nohighlight">\(Mx = y\)</span> is cheap to solve (diagonal, or triangular, or
399-
something else) and such that <span class="math notranslate nohighlight">\(M^{-1}A\)</span> <em>does</em> have eigenvalues clustered
400-
in a small number of groups (e.g. <span class="math notranslate nohighlight">\(M\)</span> is a good approximation of <span class="math notranslate nohighlight">\(A\)</span>, so
401-
that <span class="math notranslate nohighlight">\(M^{-1}A\approx I\)</span> which has eigenvalues all equal to 1). We call
402-
<span class="math notranslate nohighlight">\(M\)</span> the preconditioning matrix, and the idea is to apply GMRES to
402+
<span class="math notranslate nohighlight">\(\hat{A}\)</span> such that <span class="math notranslate nohighlight">\(\hat{A}x = y\)</span> is cheap to solve (diagonal, or triangular, or
403+
something else) and such that <span class="math notranslate nohighlight">\(\hat{A}^{-1}A\)</span> <em>does</em> have eigenvalues clustered
404+
in a small number of groups (e.g. <span class="math notranslate nohighlight">\(\hat{A}\)</span> is a good approximation of <span class="math notranslate nohighlight">\(A\)</span>, so
405+
that <span class="math notranslate nohighlight">\(\hat{A}^{-1}A\approx I\)</span> which has eigenvalues all equal to 1). We call
406+
<span class="math notranslate nohighlight">\(\hat{A}\)</span> the preconditioning matrix, and the idea is to apply GMRES to
403407
the (left) preconditioned system</p>
404408
<blockquote>
405409
<div><div class="math notranslate nohighlight">
406-
\[M^{-1}Ax = M^{-1}b.\]</div>
410+
\[\hat{A}^{-1}Ax = \hat{A}^{-1}b.\]</div>
407411
</div></blockquote>
408412
<p>GMRES on this preconditioned system is equivalent to the following algorithm,
409413
called preconditioned GMRES.</p>
410414
<ul class="simple">
411-
<li><p>SOLVE <span class="math notranslate nohighlight">\(M\tilde{b}=b\)</span>.</p></li>
415+
<li><p>SOLVE <span class="math notranslate nohighlight">\(\hat{A}\tilde{b}=b\)</span>.</p></li>
412416
<li><p><span class="math notranslate nohighlight">\(q_1 \gets \tilde{b}/\|\tilde{b}\|\)</span></p></li>
413417
<li><p>FOR <span class="math notranslate nohighlight">\(n=1,2,\dots\)</span></p>
414418
<ul>
415-
<li><p>SOLVE <span class="math notranslate nohighlight">\(Mv = Aq_n\)</span></p></li>
419+
<li><p>SOLVE <span class="math notranslate nohighlight">\(\hat{A}v = Aq_n\)</span></p></li>
416420
<li><p>FOR <span class="math notranslate nohighlight">\(j=1\)</span> TO <span class="math notranslate nohighlight">\(n\)</span></p>
417421
<ul>
418422
<li><p><span class="math notranslate nohighlight">\(h_{jn}=q_j^*v\)</span></p></li>
@@ -437,13 +441,45 @@ <h2><span class="section-number">6.5. </span>Preconditioning<a class="headerlink
437441
</div><div class="proof-content">
438442
<p>Show that this algorithm is equivalent to GMRES applied to the
439443
preconditioned system.</p>
440-
</div></div><p>The art and science of finding preconditioning matrices <span class="math notranslate nohighlight">\(M\)</span> (or
441-
matrix-free procedures for solving <span class="math notranslate nohighlight">\(Mx=y\)</span>) for specific problems
444+
</div></div><p>The art and science of finding preconditioning matrices <span class="math notranslate nohighlight">\(\hat{A}\)</span> (or
445+
matrix-free procedures for solving <span class="math notranslate nohighlight">\(\hat{A}x=y\)</span>) for specific problems
442446
arising in data science, engineering, physics, biology etc. can
443447
involve ideas from linear algebra, functional analysis, asymptotics,
444448
physics, etc., and represents a major activity in scientific computing
445449
today.</p>
446450
</section>
451+
<section id="knowing-when-to-stop">
452+
<h2><span class="section-number">6.6. </span>Knowing when to stop<a class="headerlink" href="#knowing-when-to-stop" title="Permalink to this headline"></a></h2>
453+
<p>We should stop an iterative method when the error is sufficiently small.
454+
But, we don’t have access the the exact solution, so we can’t compute the
455+
error. Two things we can look at are:</p>
456+
<ul class="simple">
457+
<li><p>The residual <span class="math notranslate nohighlight">\({r}^k=A{x}^k-{b}\)</span>, or</p></li>
458+
<li><p>The pseudo-residual <span class="math notranslate nohighlight">\({s}^k = {x}^{k+1}-{x}^k\)</span>,
459+
which both tend to zero as <span class="math notranslate nohighlight">\({x}^k\to{x}^*\)</span> provided that <span class="math notranslate nohighlight">\(A\)</span> is
460+
invertible.</p></li>
461+
</ul>
462+
<p>How do their sizes relate to the size of <span class="math notranslate nohighlight">\({e}^k={x}^k-{x}^*\)</span>?</p>
463+
<div class="math notranslate nohighlight">
464+
\[\begin{split}{e}^k = &amp; {x}^* - {x}^k \\
465+
= &amp; A^{-1}(A{x}^*-A{x}^k) \\
466+
= &amp; A^{-1}({b}-A{x}^k) \\
467+
= &amp; A^{-1}{r}^k,\end{split}\]</div>
468+
<p>so <span class="math notranslate nohighlight">\(\|e^k\| \leq \|A^{-1}\|\|r^k\|\)</span>.</p>
469+
<p>The relative error <span class="math notranslate nohighlight">\(\|e^k\|/\|x^*\|\)</span> satisfies</p>
470+
<div class="math notranslate nohighlight">
471+
\[\frac{\|e^k\|}{\|x^*\|}
472+
= \frac{\|A^{-1}r^k\|}{\|x\|}
473+
\leq \|A^{-1}\|\frac{\|r^k\|}{\|x\|}
474+
\leq \|A^{-1}\|\|A\|\frac{\|r^k\|}{\|b\|},\]</div>
475+
<p>so the relative error is bounded from above by
476+
the condition number of <span class="math notranslate nohighlight">\(\|A\|\)</span> multiplied by
477+
the relative residual <span class="math notranslate nohighlight">\(\|r^k\|/\|b\|\)</span>. If the condition
478+
number is large, it is possible to have a small residual
479+
but still have a large condition number.</p>
480+
<p>Similar results hold for the pseudoresidual, but are
481+
more complicated to show for the case of GMRES.</p>
482+
</section>
447483
</section>
448484

449485

@@ -454,7 +490,7 @@ <h2><span class="section-number">6.5. </span>Preconditioning<a class="headerlink
454490
<div class="clearer"></div>
455491
</div>
456492
<div class="footer" role="contentinfo">
457-
&#169; Copyright 2020, Colin J. Cotter.
493+
&#169; Copyright 2020-2023, Colin J. Cotter.
458494
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.0.
459495
</div>
460496
</body>

0 commit comments

Comments
 (0)