Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132939 views
License: OTHER
%auto %html(hide=True) <div class="mathbook-content"> <link rel="stylesheet" type="text/css" href="http://buzzard.ups.edu/mathbook-content.css"> <link rel="stylesheet" type="text/css" href="https://aimath.org/mathbook/mathbook-add-on.css"> </div>
%auto %html(hide=True) <div class="mathbook-content"><div class="hidden-content" style="display:none">\( \newcommand{\lt}{&lt;} \newcommand{\gt}{&gt;} \newcommand{\amp}{&amp;} \)</div></div>
%auto %html(hide=True) <div class="mathbook-content"><table width="90%" style="font-size: 200%;"><tr></tr></table></div>
%auto %html(hide=True) <div class="mathbook-content"><section class="article" id="SD"></section></div>
%auto %html(hide=True) <div class="mathbook-content"><section class="frontmatter" id="frontmatter-1"></section></div>
%auto %html(hide=True) <div class="mathbook-content"> <h2 class="heading"> <span class="title">Sage and Linear Algebra Worksheet:</span> <span class="subtitle">FCLA Section SD</span> </h2> <div class="author"> <div class="author-name">Robert Beezer</div> <div class="author-info">Department of Mathematics and Computer Science<br>University of Puget Sound</div> </div> <div class="date">Fall 2019</div> </div>
%auto %html(hide=True) <div class="mathbook-content"><section class="section" id="section-1"><h6 class="heading hide-type"> <span class="type">Section</span> <span class="codenumber">1</span> <span class="title">Similarity</span> </h6></section></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-1">We manufacture two matrices that are similar, and use Sage to check. A “unimodular” matrix is one with determinant 1. A unimodular matrix with integer entries will have an inverse with integer entries (that is a theorem, and Exercise PDM.M20).</p></div>
A = random_matrix(ZZ, 10, x = -9, y = 9).change_ring(QQ) S = random_matrix(QQ, 10, algorithm='unimodular', upper_bound=9) B = S.inverse()*A*S A, B
%auto %html(hide=True) <div class="mathbook-content"><p id="p-2">This next command might be broken, and might even just hang. My fault. It will be fixed, using rational canonical form, for Sage 7.6. See <a class="external" href="https://trac.sagemath.org/ticket/18505" target="_blank">Trac ticket #18505</a> for the details.</p></div>
A.is_similar(B)
%auto %html(hide=True) <div class="mathbook-content"><section class="section" id="section-2"><h6 class="heading hide-type"> <span class="type">Section</span> <span class="codenumber">2</span> <span class="title">Diagonalization</span> </h6></section></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-3">These two matrices are from the earlier demo for Section EE. First is diagonalizable, second is not. The easiest way to see the difference is with the <code class="code-inline tex2jax_ignore">eigenmatrix</code> commands.</p></div>
%auto %html(hide=True) <div class="mathbook-content"><article class="exercise-like" id="exercise-1"><h6 class="heading"> <span class="type">Demonstration</span> <span class="codenumber">1</span>.</h6> <p id="p-4">Diagonalize the matrix \(A\text{.}\)</p></article></div>
A = matrix(QQ, [ [-31, -23, -16, 12, 120, -17], [ -3, 7, 0, -12, 60, -21], [-28, -14, -9, -4, 152, -30], [-36, -20, -16, -1, 192, -32], [ -9, -5, -4, 0, 47, -8], [ -1, 1, 0, -4, 20, -3] ]) A
%auto %html(hide=True) <div class="mathbook-content"><p id="p-5"><code class="code-inline tex2jax_ignore">S</code>, the matrix whose columns are eigenvectors, will “diagonalize” <code class="code-inline tex2jax_ignore">A</code>.</p></div>
D, S = A.eigenmatrix_right() D, S
S.inverse()*A*S == D
%auto %html(hide=True) <div class="mathbook-content"><p id="p-6">Here is an equivalent formulation.</p></div>
A*S == S*D
%auto %html(hide=True) <div class="mathbook-content"><article class="exercise-like" id="exercise-2"><h6 class="heading"> <span class="type">Demonstration</span> <span class="codenumber">2</span>.</h6> <p id="p-7">Now, in contrast, a matrix that is not diagonalizable. Try to diagonalize the matrix \(C\text{.}\)</p></article></div>
C = matrix(QQ, [ [128, 20, 44, -50, 236, -18, -330, -565], [ -23, -16, -5, 6, -40, 27, 62, 128], [ -44, -12, -15, 16, -78, 20, 110, 207], [ -2, 10, -4, 3, -10, -23, 20, -9], [ -61, 5, -25, 27, -116, -26, 153, 225], [ -12, -12, -1, 2, -20, 24, 34, 82], [ -23, -3, -8, 9, -42, 2, 57, 99], [ 13, 6, 3, -4, 23, -12, -35, -72] ]) C
D, S = C.eigenmatrix_right() D, S
%auto %html(hide=True) <div class="mathbook-content"><p id="p-8">The zero columns in <code class="code-inline tex2jax_ignore">S</code> tell us that at least one eigenvalue has a geometric multiplicity strictly less than the algebraic multiplicity of the eigenvalue. So by Theorem DMFE the matrix <code class="code-inline tex2jax_ignore">C</code> is not diagonalizable.</p></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-9">A second consequence of the zero columns of <code class="code-inline tex2jax_ignore">S</code> is that it will not be an invertible matrix. But the output from Sage still obeys a fundamental relationship.</p></div>
C*S == S*D
%auto %html(hide=True) <div class="mathbook-content"><p id="p-10">Perhaps simpler is the built-in function <code class="code-inline tex2jax_ignore">.is_diagonalizable()</code>.</p></div>
A.is_diagonalizable()
C.is_diagonalizable()
%auto %html(hide=True) <div class="mathbook-content"><section class="section" id="section-3"><h6 class="heading hide-type"> <span class="type">Section</span> <span class="codenumber">3</span> <span class="title">Nearly Diagonalizable</span> </h6></section></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-11">A matrix that is not diagonalizable will always be similar to a matrix that is <em class="emphasis">almost</em> diagonalizable. The “nearly diagonal” matrix is called the <dfn class="terminology">Jordan canonical form</dfn> of the matrix.</p></div>
%auto %html(hide=True) <div class="mathbook-content"><article class="exercise-like" id="exercise-3"><h6 class="heading"> <span class="type">Demonstration</span> <span class="codenumber">3</span>.</h6> <p id="p-12">While beyond the scope of this course, use Sage to compute the Jordan canonical form for the matrix <code class="code-inline tex2jax_ignore">C</code>. Notice the eigenvalues of <code class="code-inline tex2jax_ignore">C</code> on the diagonal and the 1's on the <dfn class="terminology">super-diagonal</dfn>.</p> <p id="p-13">Peculiarly, the similarity matrix need not be computed to get the form, and it is a significant computational expense. So we ask for it explicitly.</p></article></div>
J, T = C.jordan_form(transformation=True) J, T
%auto %html(hide=True) <div class="mathbook-content"><p id="p-14">The transformation matrix, <code class="code-inline tex2jax_ignore">T</code>, is invertible and will “almost diagonalize” <code class="code-inline tex2jax_ignore">C</code>.</p></div>
T.inverse()*C*T == J
%auto %html(hide=True) <div class="mathbook-content"><article class="exercise-like" id="exercise-4"><h6 class="heading"> <span class="type">Demonstration</span> <span class="codenumber">4</span>.</h6> <p id="p-15"><dfn class="terminology">Rational canonical form</dfn> is another interesting version of this idea, try <code class="code-inline tex2jax_ignore">.rational_form()</code> on <code class="code-inline tex2jax_ignore">C</code>. And if you do, then execute the following two cells and see if the coefficients look familiar. Learn more about <dfn class="terminology">companion matrices</dfn> if this makes you curious.</p></article></div>
C.rational_form()
C.fcp()
((x-1)^3*(x+2)^3).expand()
%auto %html(hide=True) <div class="mathbook-content"><article class="conclusion" id="conclusion-1"><h5 class="heading"><span></span></h5></article></div>
%auto %html(hide=True) <div class="mathbook-content"><p id="p-16">This work is Copyright 2016–2019 by Robert A. Beezer. It is licensed under a <a class="external" href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank">Creative Commons Attribution-ShareAlike 4.0 International License</a>.</p></div>
%auto %html(hide=True) <div class="mathbook-content"><table width="90%" style="font-size: 200%;"><tr></tr></table></div>