On Jun 21, 9:59 pm, Rob Beezer <goo...@beezer.cotse.net> wrote:
> I think I have one more big push left in me as I try to tidy up linear
> algebra in Sage to make it even more useful for students studying the
> subject for the first time. Eigen-stuff is on my radar. Some
> behaviors that I find problematic, most vexing first.
>
> 1. Eigenspaces
>
> sage: A = matrix(QQ, [[0,-1,0,0],[1,0,0,0],[0,0,0,-1],[0,0,1,0]])
> sage: A.eigenspaces_right()
> [
> (a0, Vector space of degree 4 and dimension 2 over Number Field in a0
> with defining polynomial x^2 + 1
> User basis matrix:
> [ 1 -a0 0 0]
> [ 0 0 1 -a0])
> ]
>
> It is real impressive that we can do computations in QQbar and get
> Galois conjugates and all, but there is no possible way to explain
> this to a student who is fresh out of calculus.
what about
sage: A = matrix(QQbar, [[0,-1,0,0],[1,0,0,0],[0,0,0,-1],[0,0,1,0]])
sage: A.eigenspaces_right()
Now let's compare a more nontrivial example. Mathematica does basically
what you suggest, and it looks like a *mess*. Part of this is because
the Mathematica output can be directly copied and pasted to be
mathematica input, but part of the mess also comes from it not
formatting the vectors as using Galois conjugates
m = ( {
{0, -1, 0, 4},
{1, 0, 0, 3},
{0, 2, 0, -1},
{5, -1, 1, 0}
} )
Eigensystem[m]
{{Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1],
Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2],
Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4],
Root[-7 + 13 #1 - 15 #1^2 + #1^4 &,
3]}, {{-(23/10) + 24/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1] -
1/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1]^2 -
3/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1]^3,
61/10 - 8/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1] -
3/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1]^2 +
1/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1]^3,
88/5 - 123/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1] +
1/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1]^2 +
8/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 1]^3,
1}, {-(23/10) + 24/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2] -
1/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2]^2 -
3/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2]^3,
61/10 - 8/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2] -
3/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2]^2 +
1/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2]^3,
88/5 - 123/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2] +
1/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2]^2 +
8/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 2]^3,
1}, {-(23/10) + 24/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4] -
1/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4]^2 -
3/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4]^3,
61/10 - 8/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4] -
3/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4]^2 +
1/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4]^3,
88/5 - 123/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4] +
1/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4]^2 +
8/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 4]^3,
1}, {-(23/10) + 24/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 3] -
1/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 3]^2 -
3/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 3]^3,
61/10 - 8/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 3] -
3/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 3]^2 +
1/10 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 3]^3,
88/5 - 123/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 3] +
1/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 3]^2 +
8/5 Root[-7 + 13 #1 - 15 #1^2 + #1^4 &, 3]^3, 1}}}
Now here is Sage's output:
sage: m=matrix([[0, -1, 0, 4], [1, 0, 0, 3], [0, 2, 0, -1], [5, -1, 1, 0]])
sage: m.eigenspaces_right()
[
(a0, Vector space of degree 4 and dimension 1 over Number Field in a0
with defining polynomial x^4 - 15*x^2 + 13*x - 7
User basis matrix:
[ 1 16/55*a0^3 + 12/55*a0^2 -
21/5*a0 + 76/55 19/55*a0^3 + 28/55*a0^2 - 24/5*a0 - 171/55 4/55*a0^3
+ 3/55*a0^2 - 4/5*a0 + 19/55])
]
To me, it is much easier to explain: okay, we have 4 roots to our
characteristic polynomial. Each root is an eigenvalue and each
eigenvalue has a one-dimensional eigenspace. Whatever your root is,
plug it into this formula and you'll get a corresponding eigenvector.
Personally, I find this is more elegant and it is clearer what is going
on. Of course, I haven't actually explained it to a student that way,
so I might change my mind after I try :). The output from the same
matrix over QQbar is also pretty reasonable, but it is not nearly as
clear what is going on mathematically:
sage: m.change_ring(QQbar).eigenspaces_right()
[
(3.436547504370473?, Vector space of degree 4 and dimension 1 over
Algebraic Field
User basis matrix:
[ 1.000000000000000? 1.331601478275790? 0.4280940999706945?
1.192037245661566?]),
(0.4270724496970427? + 0.540685587055116?*I, Vector space of degree 4
and dimension 1 over Algebraic Field
User basis matrix:
[ 1 -0.5221757474677046? -
2.130035329012798?*I -5.317495122489429? - 2.312582446540107?*I
-0.02377582444266547? - 0.3973374354894205?*I]),
(0.4270724496970427? - 0.540685587055116?*I, Vector space of degree 4
and dimension 1 over Algebraic Field
User basis matrix:
[ 1 -0.5221757474677046? +
2.130035329012798?*I -5.317495122489429? + 2.312582446540107?*I
-0.02377582444266547? + 0.3973374354894205?*I]),
(-4.290692403764558?, Vector space of degree 4 and dimension 1 over
Algebraic Field
User basis matrix:
[ 1.000000000000000? 0.4400227439323470? -0.4294674913554725?
-0.9626674149580528?])
]
How do you propose getting the Galois conjugate type of output if your
suggested change is made?
Thanks,
Jason
I'd be okay with that. So +epsilon. Or maybe +2*epsilon.
Jason
What's wrong with:
sage: B = matrix(ZZ, [[-87, -1, 1], [17, 2, -6], [-1, -2, 7]])
sage: B.eigenvectors_right()
[(-86.80242042716417?, [(1, -0.190991066220052?, 0.006588506615773?)],
1), (0.12344763849958892?, [(1, -122.6499594923977?,
-35.52651185389811?)], 1), (8.67897278866459?, [(1,
-43.93682721916003?, 51.74214556950456?)], 1)]
?
And what if the output of "B.eigenspaces_right()" is a bit confusing?
I'd argue that's actually a feature, because it will make the student
*think* about it, get a glimpse of some interesting mathematics, and
maybe open a door to a new world.
We can just tell students to use the eigenvectors_* methods, and
challenge them to figure out how to read the output of the
eigenspaces_* methods.
Best,
Gonzalo
I'll add my vote for that.
John
> Rob
>
> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>