You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: L1_preliminaries.html
+1-3Lines changed: 1 addition & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -564,9 +564,7 @@ <h2><span class="section-number">1.5. </span>Inner products and orthogonality<a
564
564
<p>Let <spanclass="math notranslate nohighlight">\(x,y\in \mathbb{C}^m\)</span>. Then the inner product of <spanclass="math notranslate nohighlight">\(x\)</span> and <spanclass="math notranslate nohighlight">\(y\)</span> is</p>
565
565
<divclass="math notranslate nohighlight">
566
566
\[x^*y = \sum_{i=1}^m \bar{x}_iy_i.\]</div>
567
-
</div></div><p>(Exercise: check that the inner product is bilinear, i.e. linear in
568
-
both of the arguments.)</p>
569
-
<p>We will frequently use the natural norm derived from the inner product
567
+
</div></div><p>We will frequently use the natural norm derived from the inner product
<p><spanclass="math notranslate nohighlight">\((\ddagger)\)</span> The <aclass="reference internal" href="cla_utils.html#cla_utils.exercises2.GS_classical" title="cla_utils.exercises2.GS_classical"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">cla_utils.exercises2.GS_classical()</span></code></a> function has been
199
-
left unimplemented. It should implement the classical Gram-Schmidt
200
-
algorithm above, using Numpy slice notation so that only one Python
201
-
for loop is used. The function should work “in place” by making a
202
-
copy of <spanclass="math notranslate nohighlight">\(A\)</span> and then changing the values in the copy, without
203
-
introducing additional intermediate arrays (you will need to create
204
-
a new array to store <spanclass="math notranslate nohighlight">\(R\)</span>). The test script <codeclass="docutils literal notranslate"><spanclass="pre">test_exercises2.py</span></code>
205
-
in the <codeclass="docutils literal notranslate"><spanclass="pre">test</span></code> directory will test this function.</p>
198
+
<p><spanclass="math notranslate nohighlight">\((\ddagger)\)</span> The <aclass="reference internal" href="cla_utils.html#cla_utils.exercises2.GS_classical" title="cla_utils.exercises2.GS_classical"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">cla_utils.exercises2.GS_classical()</span></code></a> function
199
+
has been left unimplemented. It should implement the classical
200
+
Gram-Schmidt algorithm above, using Numpy slice notation so that
201
+
only one Python for loop is used. The function should work “in
202
+
place” by changing the values in <spanclass="math notranslate nohighlight">\(A\)</span>, without introducing
203
+
additional intermediate arrays (you will need to create a new array
204
+
to store <spanclass="math notranslate nohighlight">\(R\)</span>). The test script <codeclass="docutils literal notranslate"><spanclass="pre">test_exercises2.py</span></code> in the
205
+
<codeclass="docutils literal notranslate"><spanclass="pre">test</span></code> directory will test this function.</p>
206
206
</div></div><divclass="admonition hint">
207
207
<pclass="admonition-title">Hint</p>
208
208
<p>The <spanclass="math notranslate nohighlight">\((\ddagger)\)</span> symbol in an exercise indicates that the code for
algorithm above, using Numpy slice notation where possible.
322
322
What is the minimal number of Python
323
323
for loops possible?</p>
324
-
<p>The function should work “in place” by making a
325
-
copy of <spanclass="math notranslate nohighlight">\(A\)</span> and then changing those values, without introducing
326
-
additional intermediate arrays. The test script
324
+
<p>The function should work “in place” by changing the values in <spanclass="math notranslate nohighlight">\(A\)</span>,
325
+
without introducing additional intermediate arrays (you will need
326
+
to create a new array to store <spanclass="math notranslate nohighlight">\(R\)</span>). The test script
327
327
<codeclass="docutils literal notranslate"><spanclass="pre">test_exercises2.py</span></code> in the <codeclass="docutils literal notranslate"><spanclass="pre">test</span></code> directory will test this
<p>The last equation yields <spanclass="math notranslate nohighlight">\(x_m\)</span> directly by dividing by <spanclass="math notranslate nohighlight">\(R_{mm}\)</span>, then
674
+
we can use this value to directly compute <spanclass="math notranslate nohighlight">\(x_{m-1}\)</span>. This is repeated
675
+
for all of the entries of <spanclass="math notranslate nohighlight">\(x\)</span> from <spanclass="math notranslate nohighlight">\(m\)</span> down to 1. This procedure is
676
+
called back substitution, which we summarise in the following
<aclass="reference internal" href="cla_utils.html#cla_utils.exercises3.householder" title="cla_utils.exercises3.householder"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">cla_utils.exercises3.householder()</span></code></a>. If you have not already
710
733
done so, you will need to modified
711
734
<aclass="reference internal" href="cla_utils.html#cla_utils.exercises3.householder" title="cla_utils.exercises3.householder"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">cla_utils.exercises3.householder()</span></code></a> to use the <codeclass="docutils literal notranslate"><spanclass="pre">kmax</span></code>
712
-
argument. You may make use of the built-in triangular solve
triangular matrix algorithms briefly later). The test script
715
-
<codeclass="docutils literal notranslate"><spanclass="pre">test_exercises3.py</span></code> in the <codeclass="docutils literal notranslate"><spanclass="pre">test</span></code> directory will also test this
716
-
function.</p>
735
+
argument. You will also need <aclass="reference internal" href="cla_utils.html#cla_utils.exercises3.solve_U" title="cla_utils.exercises3.solve_U"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">cla_utils.exercises3.solve_U()</span></code></a>.</p>
717
736
</div></div><p>If we really need <spanclass="math notranslate nohighlight">\(Q\)</span>, we can get it by matrix-vector products with
718
737
each element of the canonical basis <spanclass="math notranslate nohighlight">\((e_1,e_2,\ldots,e_n)\)</span>. This
719
738
means that first we need to compute a matrix-vector product <spanclass="math notranslate nohighlight">\(Qx\)</span> with
@@ -809,24 +828,7 @@ <h2><span class="section-number">2.7. </span>Application: Least squares problems
809
828
\[\hat{R}x = \hat{Q}^*b.\]</div>
810
829
</div></blockquote>
811
830
<p>This is an upper triangular system that can be solved efficiently
812
-
using back-substitution. Written in components, this equation is</p>
<p>The last equation yields <spanclass="math notranslate nohighlight">\(x_m\)</span> directly by dividing by <spanclass="math notranslate nohighlight">\(R_{mm}\)</span>, then
818
-
we can use this value to directly compute <spanclass="math notranslate nohighlight">\(x_{m-1}\)</span>. This is repeated
819
-
for all of the entries of <spanclass="math notranslate nohighlight">\(x\)</span> from <spanclass="math notranslate nohighlight">\(m\)</span> down to 1. This procedure is
820
-
called back substitution, which we summarise in the following
<aclass="reference external" href="http://scipy.github.io/devdocs/reference/generated/scipy.linalg.solve_triangular.html#scipy.linalg.solve_triangular" title="(in SciPy v1.10.0.dev0+1717.ebbd597)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">scipy.linalg.solve_triangular()</span></code></a> to solve the resulting upper
845
+
<aclass="reference internal" href="cla_utils.html#cla_utils.exercises3.solve_U" title="cla_utils.exercises3.solve_U"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">cla_utils.exercises3.solve_U()</span></code></a> to solve the resulting upper
844
846
triangular system, before returning the solution <spanclass="math notranslate nohighlight">\(x\)</span>. The test
845
847
script <codeclass="docutils literal notranslate"><spanclass="pre">test_exercises3.py</span></code> in the <codeclass="docutils literal notranslate"><spanclass="pre">test</span></code> directory will also
<p>An algorithm <spanclass="math notranslate nohighlight">\(\tilde{f}\)</span> for <spanclass="math notranslate nohighlight">\(f\)</span> is stable if for each <spanclass="math notranslate nohighlight">\(x\in X\)</span>,</p>
<p>An algorithm <spanclass="math notranslate nohighlight">\(\tilde{f}\)</span> for <spanclass="math notranslate nohighlight">\(f\)</span> is stable if for each <spanclass="math notranslate nohighlight">\(x\in X\)</span>,
747
+
there exists <spanclass="math notranslate nohighlight">\(\tilde{x}\)</span> with</p>
<li><p>Finding an eigenvector <spanclass="math notranslate nohighlight">\(v\)</span> of <spanclass="math notranslate nohighlight">\(A\)</span> with eigenvalue <spanclass="math notranslate nohighlight">\(\lambda\)</span> (you can use <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.linalg.eig.html#numpy.linalg.eig" title="(in NumPy v1.23)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.linalg.eig()</span></code></a> for this),</p></li>
500
500
<li><p>Choosing a perturbation vector <spanclass="math notranslate nohighlight">\(r\)</span>, and perturbation parameter <spanclass="math notranslate nohighlight">\(\epsilon>0\)</span>,</p></li>
501
501
<li><p>Comparing the Rayleigh quotient of <spanclass="math notranslate nohighlight">\(v + \epsilon r\)</span> with <spanclass="math notranslate nohighlight">\(\lambda\)</span>,</p></li>
502
-
<li><p>Plotting (on a log-log graph, use <aclass="reference external" href="https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.loglog.html#matplotlib.pyplot.loglog" title="(in Matplotlib v3.5.3)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">matplotlib.pyplot.loglog()</span></code></a>) the error in estimating the eigenvalue as a function of <spanclass="math notranslate nohighlight">\(\epsilon\)</span>.</p></li>
502
+
<li><p>Plotting (on a log-log graph, use <aclass="reference external" href="https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.loglog.html#matplotlib.pyplot.loglog" title="(in Matplotlib v3.6.0)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">matplotlib.pyplot.loglog()</span></code></a>) the error in estimating the eigenvalue as a function of <spanclass="math notranslate nohighlight">\(\epsilon\)</span>.</p></li>
503
503
</ol>
504
504
<p>The best way to do this is to plot the computed data values as points,
505
505
and then superpose a line plot of <spanclass="math notranslate nohighlight">\(a\epsilon^k\)</span> for appropriate
@@ -773,7 +773,7 @@ <h2><span class="section-number">5.8. </span>The pure QR algorithm<a class="head
<aclass="reference internal" href="cla_utils.html#cla_utils.exercises9.get_C100" title="cla_utils.exercises9.get_C100"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">cla_utils.exercises9.get_C100()</span></code></a>, and
775
775
<aclass="reference internal" href="cla_utils.html#cla_utils.exercises9.get_D100" title="cla_utils.exercises9.get_D100"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">cla_utils.exercises9.get_D100()</span></code></a>. You can use
776
-
<aclass="reference external" href="https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pcolor.html#matplotlib.pyplot.pcolor" title="(in Matplotlib v3.5.3)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">matplotlib.pyplot.pcolor()</span></code></a> to visualise the entries,
776
+
<aclass="reference external" href="https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pcolor.html#matplotlib.pyplot.pcolor" title="(in Matplotlib v3.6.0)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">matplotlib.pyplot.pcolor()</span></code></a> to visualise the entries,
777
777
or compute norms of the components of the matrices below the diagonal,
778
778
for example. What do you observe? How does this relate to the structure
0 commit comments