Skip to content

Commit 54afef7

Browse files
committed
add task to EV3 to associate an eigenvector with an eigenvalue
1 parent 783fd7f commit 54afef7

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

source/linear-algebra/exercises/outcomes/GT/GT3/generator.sage

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,26 @@ TBIL.config_matrix_typesetting()
44
class Generator(BaseGenerator):
55
def data(self):
66
while True:
7-
ls = [choice([-1,1])*i for i in range(2,7)]
8-
l1,l2 = sample(ls,2)
9-
S=random_matrix(QQ, 2, 2, algorithm='echelonizable', rank=2, upper_bound=2)
7+
# eigenvalues will be two distinct small integers with
8+
# different absolute values
9+
l1,l2 = sample(range(2,6),2)
10+
l1,l2 = l1*choice([-1,1]),l2*choice([-1,1])
11+
S=random_matrix(QQ, 2, 2, algorithm='echelonizable', rank=2, upper_bound=6)
1012
A=S.inverse()*matrix([[l1,1],[0,l2]])*S
11-
if all(a!=0 for a in A.list()):
13+
# to get roughly consistent difficulty
14+
if all(abs(a)>5 for a in A.list()):
1215
break
1316

17+
# Get an eigenvector
18+
eigenvector = column_matrix((A-matrix([[l1,0],[0,l1]])).right_kernel(basis='pivot').basis()[0])
19+
# Scale to get whole numbers
20+
eigenvector = eigenvector[0].denominator()*eigenvector[1].denominator()*eigenvector
21+
1422
return {
1523
"matrix": A,
1624
"e1": l1,
1725
"e2": l2,
1826
"charpoly": A.charpoly('lambda_'),
27+
"eigenvector": eigenvector,
28+
"scaled_eigenvector": l1*eigenvector,
1929
}
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<knowl mode="exercise" xmlns="https://spatext.clontz.org" version="0.2">
3-
<content>
4-
<p>Explain and demonstrate how to find the eigenvalues of the matrix <m>{{matrix}}</m>.</p>
5-
</content>
6-
<outtro>
7-
<p>The characteristic polynomial of <m>{{matrix}}</m> is <m>{{charpoly}}</m>.</p>
8-
<p>The eigenvalues of <m>{{matrix}}</m> are <m>{{e1}}</m> and <m>{{e2}}</m>.</p>
9-
</outtro>
3+
<knowl>
4+
<content>
5+
<p>Explain and demonstrate how to find the eigenvalues of the matrix <m>{{matrix}}</m>.</p>
6+
</content>
7+
<outtro>
8+
<p>The characteristic polynomial of <m>{{matrix}}</m> is <m>{{charpoly}}</m>.</p>
9+
<p>The eigenvalues of <m>{{matrix}}</m> are <m>{{e1}}</m> and <m>{{e2}}</m>.</p>
10+
</outtro>
11+
</knowl>
12+
<knowl>
13+
<content>
14+
<p>Explain and demonstrate which of these eigenvalues is associated to the eigenvector <m>{{eigenvector}}</m>.</p>
15+
</content>
16+
<outtro>
17+
<p>
18+
<m>{{eigenvector}}</m> is associated with the eigenvalue <m>{{e1}}</m> because
19+
<me>{{matrix}}{{eigenvector}}={{scaled_eigenvector}}={{e1}}{{eigenvector}}</me>
20+
</p>
21+
</outtro>
22+
</knowl>
1023
</knowl>

0 commit comments

Comments
 (0)