ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 16 Jul 2020 04:15:30 +0200Zero Matrix has an Inverse over Finite Field?https://ask.sagemath.org/question/52487/zero-matrix-has-an-inverse-over-finite-field/The following code
M = Matrix([0], ring=GF(4))
M
Prints "[0]" as expected. The inverse of M clearly does not exist. Even so, running
M.inverse()
does not throw an error, and instead prints "[1]". What's going on here?
I am running Sage 8.1. Thanks for the help.brantmvThu, 16 Jul 2020 04:15:30 +0200https://ask.sagemath.org/question/52487/Making a dictionary of matrices, and save the sessionhttps://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 1Wed, 24 Jan 2018 01:32:17 +0100https://ask.sagemath.org/question/40756/Lifting a matrix from $\mathbb{Q}[Y]/(Y-1)$https://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 HeubergerSun, 13 Nov 2016 06:47:52 +0100https://ask.sagemath.org/question/35555/Minimal polynomial isn't minimal?https://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 20:13:39 +0200https://ask.sagemath.org/question/23915/