Matrix Characteristic Polynomial

47 views
Skip to first unread message

firebird

unread,
Mar 17, 2012, 4:13:42 PM3/17/12
to sage-support
I was expecting x^2 as the characteristic polynomial. What's gone
wrong?

sage: type(m)
<type 'sage.matrix.matrix_rational_dense.Matrix_rational_dense'>
sage: m
[ 0 0 1/4 0 0 1/4 0 0 -1/4 0 0 -1/4]
[ 1/4 0 0 -1/4 0 0 1/4 0 0 -1/4 0 0]
[ 0 1/4 0 0 -1/4 0 0 -1/4 0 0 1/4 0]
[ 0 0 1/4 0 0 1/4 0 0 -1/4 0 0 -1/4]
[-1/4 0 0 1/4 0 0 -1/4 0 0 1/4 0 0]
[ 0 -1/4 0 0 1/4 0 0 1/4 0 0 -1/4 0]
[ 0 0 -1/4 0 0 -1/4 0 0 1/4 0 0 1/4]
[ 1/4 0 0 -1/4 0 0 1/4 0 0 -1/4 0 0]
[ 0 -1/4 0 0 1/4 0 0 1/4 0 0 -1/4 0]
[ 0 0 -1/4 0 0 -1/4 0 0 1/4 0 0 1/4]
[-1/4 0 0 1/4 0 0 -1/4 0 0 1/4 0 0]
[ 0 1/4 0 0 -1/4 0 0 -1/4 0 0 1/4 0]
sage: m.charpoly()
x^12
sage: m**2
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]

Graham

Justin C. Walker

unread,
Mar 17, 2012, 4:21:19 PM3/17/12
to sage-s...@googlegroups.com

On Mar 17, 2012, at 13:13 , firebird wrote:

> I was expecting x^2 as the characteristic polynomial. What's gone
> wrong?

I believe that the characteristic polynomial of a matrix, M, is given as "det(\lambda I-M)" or something similar. In your case (a 12x12 matirx), you should expect a polynomial of degree 12. Perhaps you were thinking of the minimal polynomial?

HTH

Justin

--
Justin C. Walker
Curmudgeon-at-large
Director
Institute for the Absorption of Federal Funds
----
186,000 Miles per Second
Not just a good idea:
it's the law!
----

firebird

unread,
Mar 18, 2012, 8:31:23 AM3/18/12
to sage-support
Thanks Justin. My mistake... minimal_polynomial is what is required.
Graham

Justin C. Walker

unread,
Mar 18, 2012, 8:16:44 PM3/18/12
to sage-s...@googlegroups.com

On Mar 18, 2012, at 05:31 , firebird wrote:

> Thanks Justin. My mistake... minimal_polynomial is what is required.
> Graham

And, in case you didn't know about these features of sage/python:
- if you have an object, procedure, ..., you can find out more about what is available for said item by following it with a '.' and the TAB character. The system will print out a list of possible "methods" associated to the name. If you follow the '.' with the (possible) beginning of a name, then the TAB, you get a list of "methods" with that beginning:

sage: M.=min[TAB]
min minimal_polynomial minpoly
min_cycles minimize
min_symbolic minimize_constrained
sage: M.=min

- similarly, if you follow a name with one or two '?'s, you get the documentation associated with that name (one '?') or both doc and implementation (if in python) (two '?'s). A caveat: once you type "[]"s or "()"s, the parser won't be able to determine the object in question (dynamic typing), so this doesn't work:

sage: MS=MatrixSpace(ZZ,2,2)
sage: MS.random_element().min[TAB]

(yields no output).

HTH

Justin

PS: to be clear, in the above, [TAB] means "press the tab key" (brackets are not typed).

--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Enhancement of the Director's Income
--------
Experience is what you get
when you don't get what you want.
--------

Simon King

unread,
Mar 20, 2012, 4:08:51 PM3/20/12
to sage-s...@googlegroups.com
Justin C. Walker <justin <at> mac.com> writes:
> sage: M.=min[TAB]
> min minimal_polynomial minpoly
> min_cycles minimize
> min_symbolic minimize_constrained

I guess the "=" is a typo, isn't it? It should be "M", "." and then the tab key.

Just to avoid confusion.

Cheers,
Simon

Justin C. Walker

unread,
Mar 20, 2012, 4:14:11 PM3/20/12
to sage-s...@googlegroups.com

On Mar 20, 2012, at 13:08 , Simon King wrote:

> Justin C. Walker <justin <at> mac.com> writes:
>> sage: M.=min[TAB]
>> min minimal_polynomial minpoly
>> min_cycles minimize
>> min_symbolic minimize_constrained
>
> I guess the "=" is a typo, isn't it? It should be "M", "." and then the tab key.

Thanks for catching that. No idea where it came from, since I copy/pasted that from a Sage session in a terminal window...it's still there, without the '='.

However, and this is a quiz for preparser() experts, I do get the above results with "M.=min[TAB]" (sage-4.8). WT...?

Justin

--
Justin C. Walker, Curmudgeon-At-Large, Director


Institute for the Enhancement of the Director's Income
--------

The path of least resistance:
it's not just for electricity any more.
--------

Reply all
Reply to author
Forward
0 new messages