Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions source/linear-algebra/exercises/outcomes/GT/GT3/generator.sage
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ TBIL.config_matrix_typesetting()
class Generator(BaseGenerator):
def data(self):
while True:
ls = [choice([-1,1])*i for i in range(2,7)]
l1,l2 = sample(ls,2)
S=random_matrix(QQ, 2, 2, algorithm='echelonizable', rank=2, upper_bound=2)
# eigenvalues will be two distinct small integers with
# different absolute values
l1,l2 = sample(range(2,6),2)
l1,l2 = l1*choice([-1,1]),l2*choice([-1,1])
S=random_matrix(QQ, 2, 2, algorithm='echelonizable', rank=2, upper_bound=6)
A=S.inverse()*matrix([[l1,1],[0,l2]])*S
if all(a!=0 for a in A.list()):
# to get roughly consistent difficulty
if all(abs(a)>5 for a in A.list()):
break

# Get an eigenvector
eigenvector = column_matrix((A-matrix([[l1,0],[0,l1]])).right_kernel(basis='pivot').basis()[0])
# Scale to get whole numbers
eigenvector = eigenvector[0].denominator()*eigenvector[1].denominator()*eigenvector

return {
"matrix": A,
"e1": l1,
"e2": l2,
"charpoly": A.charpoly('lambda_'),
"eigenvector": eigenvector,
"scaled_eigenvector": l1*eigenvector,
}
27 changes: 20 additions & 7 deletions source/linear-algebra/exercises/outcomes/GT/GT3/template.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<knowl mode="exercise" xmlns="https://spatext.clontz.org" version="0.2">
<content>
<p>Explain and demonstrate how to find the eigenvalues of the matrix <m>{{matrix}}</m>.</p>
</content>
<outtro>
<p>The characteristic polynomial of <m>{{matrix}}</m> is <m>{{charpoly}}</m>.</p>
<p>The eigenvalues of <m>{{matrix}}</m> are <m>{{e1}}</m> and <m>{{e2}}</m>.</p>
</outtro>
<knowl>
<content>
<p>Explain and demonstrate how to find the eigenvalues of the matrix <m>{{matrix}}</m>.</p>
</content>
<outtro>
<p>The characteristic polynomial of <m>{{matrix}}</m> is <m>{{charpoly}}</m>.</p>
<p>The eigenvalues of <m>{{matrix}}</m> are <m>{{e1}}</m> and <m>{{e2}}</m>.</p>
</outtro>
</knowl>
<knowl>
<content>
<p>Explain and demonstrate which of these eigenvalues is associated to the eigenvector <m>{{eigenvector}}</m>.</p>
</content>
<outtro>
<p>
<m>{{eigenvector}}</m> is associated with the eigenvalue <m>{{e1}}</m> because
<me>{{matrix}}{{eigenvector}}={{scaled_eigenvector}}={{e1}}{{eigenvector}}</me>
</p>
</outtro>
</knowl>
</knowl>
59 changes: 45 additions & 14 deletions source/linear-algebra/source/05-GT/samples/03.ptx
Original file line number Diff line number Diff line change
@@ -1,20 +1,51 @@
<?xml version='1.0' encoding='UTF-8'?>

<example xml:id="sample-GT3">
<title>GT3</title>

<task>
<statement>
<p>
Explain and demonstrate how to find the eigenvalues of the matrix <m>\left[\begin{array}{cc} -2 &amp; -2 \\ 10 &amp; 7 \end{array}\right] </m>.
</p>
</statement>

<solution>
<p>
Compute the characteristic polynomial:
<me>
\det(A-\lambda I) = \det \left[\begin{array}{cc} -2 - \lambda &amp; -2 \\ 10 &amp; 7-\lambda \end{array}\right]
</me>
<me>
= (-2-\lambda)(7-\lambda)+20 = \lambda ^2 -5\lambda +6 = (\lambda -2)(\lambda -3)
</me>
The eigenvalues are the roots of the characteristic polynomial, namely <m>2</m> and <m>3</m>.
</p>
</solution>
</task>

<example xml:id="sample-GT3"><title>GT3</title>
<statement>
<p>
Explain how to find the eigenvalues of the matrix <m>\left[\begin{array}{cc} -2 &amp; -2 \\ 10 &amp; 7 \end{array}\right] </m>.
</p>
</statement>
<solution>
<p>
Compute the characteristic polynomial:
<me>\det(A-\lambda I) = \det \left[\begin{array}{cc} -2 - \lambda &amp; -2 \\ 10 &amp; 7-\lambda \end{array}\right]
</me><me>= (-2-\lambda)(7-\lambda)+20 = \lambda ^2 -5\lambda +6 = (\lambda -2)(\lambda -3)</me>
The eigenvalues are the roots of the characteristic polynomial, namely <m>2</m> and <m>3</m>.
</p>
</solution>

<task>
<statement>
<p>
Explain and demonstrate which of these eigenvalues is associated to the eigenvector <m>\left[\begin{array}{cc} -1 \\ 2 \end{array}\right]</m>.
</p>
</statement>

<solution>
<p>
We can compute
<md>
\left[\begin{array}{cc} -2 &amp; -2 \\ 10 &amp; 7 \end{array}\right]
\left[\begin{array}{cc} -1 \\ 2 \end{array}\right] =
\left[\begin{array}{cc} -2 \\ 4 \end{array}\right]
</md> and <md>
2\left[\begin{array}{cc} -1 \\ 2 \end{array}\right] =
\left[\begin{array}{cc} -2 \\ 4 \end{array}\right]
</md>
which shows that <m>\left[\begin{array}{cc} -1 \\ 2 \end{array}\right]</m> is an
eigenvector associated with the eigenvalue <m>2</m>.
</p>
</solution>
</task>
</example>
1 change: 0 additions & 1 deletion source/linear-algebra/source/meta/sample-exercises.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ for a complete solution.
<xi:include href="../03-AT/samples/05.ptx"/>
<xi:include href="../03-AT/samples/06.ptx"/>


<xi:include href="../04-MX/samples/01.ptx"/>
<xi:include href="../04-MX/samples/02.ptx"/>
<xi:include href="../04-MX/samples/03.ptx"/>
Expand Down
Loading