ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 23 Jan 2018 18:32:17 -0600Making a dictionary of matrices, and save the sessionhttp://ask.sagemath.org/question/40756/making-a-dictionary-of-matrices-and-save-the-session/Some time ago I [made a dictionary of matrices](https://ask.sagemath.org/question/40234/) with your help.
Now I like to save the session by `save_session()` but somehow I fail. The terminal goes as follows
sage: A=matrix(GF(2),[[1,0],[0,1]])
sage: A.set_immutable()
sage: dictA={A:1}
sage: save_session(verbose=true)
Saving A
Not saving dictA: mutable matrices are unhashable
On the other hand
sage: A=matrix([[1,0],[0,1]])
sage: A.set_immutable()
sage: dictA={A:1}
sage: save_session(verbose=true)
Saving A
Saving dictA
I have no idea why specifying `GF(2)` fails `save_session()`. Does anyone know a fix?Symbol 1Tue, 23 Jan 2018 18:32:17 -0600http://ask.sagemath.org/question/40756/Lifting a matrix from $\mathbb{Q}[Y]/(Y-1)$http://ask.sagemath.org/question/35555/lifting-a-matrix-from-mathbbqyy-1/I have a matrix in $\mathbb{Q}[Y]/(Y-1)$ and want to lift it to $\mathbb{Q}[Y]$, however, I get an error:
sage: D.<Y> = QQ[]
sage: B = matrix(D, [[Y, 0]])
sage: Dbar = D.quotient(Y-1)
sage: Bbar = B.change_ring(Dbar)
sage: Bbar.lift()
Traceback (most recent call last):
...
TypeError: unable to convert 1 to a rational
Lifting single elements instead of a matrix works:
sage: Dbar(Y^2).lift()
1
Lifting a matrix from the integers modulo a prime works also:
sage: B = matrix(ZZ, [[7, 0]])
sage: Dbar = ZZ.quotient(5)
sage: Bbar = B.change_ring(Dbar)
sage: Bbar.lift()
[2 0]
So how do I lift the matrix? Building a new matrix by hand und lifting componentwise seems to be an option; however, I think that it is somewhat ugly.Clemens HeubergerSat, 12 Nov 2016 23:47:52 -0600http://ask.sagemath.org/question/35555/Minimal polynomial isn't minimal?http://ask.sagemath.org/question/23915/minimal-polynomial-isnt-minimal/Quoting [MathWorld](http://mathworld.wolfram.com/MatrixMinimalPolynomial.html),
> The minimal polynomial of a matrix $A$ is the monic polynomial in $A$ of smallest degree $n$ such that
>
> $$p(A) = \sum_{i=0}^n c_i A^i = 0$$.
I'd like to find the minimal polynomial of a matrix $A$ over the reals. My attempt:
sage: A = matrix(RR, [
....: [0,-9, 0, 0, 0, 0],
....: [1, 6, 0, 0, 0, 0],
....: [0, 0, 0,-9, 0, 0],
....: [0, 0, 1, 6, 0, 0],
....: [0, 0, 0, 0, 0,-5],
....: [0, 0, 0, 0, 1, 0]
....: ])
sage: f = A.minpoly()
sage: f.is_monic()
True
sage: f(A).is_zero()
True
However, $f$ doesn't appear to actually be the minimal polynomial:
sage: R.<x> = RR['x']
sage: g = x^4 - 6*x^3 + 14*x^2 - 30*x + 45
sage: g(x).is_monic()
True
sage: g(A).is_zero()
True
sage: g.degree() < f.degree()
True
Did I make a mistake or is this a bug?
I noticed that `A.minpoly()` gives $g$ if I do the computation over $\mathbb{Q}$ instead of $\mathbb{R}$. Perhaps the `minpoly` function just needs to be restricted to exact rings?WilsonSun, 24 Aug 2014 13:13:39 -0500http://ask.sagemath.org/question/23915/