Ask Your Question
2

Zero Matrix has an Inverse over Finite Field?

asked 2020-07-16 04:15:30 +0100

brantmv gravatar image

updated 2023-01-09 23:59:52 +0100

tmonteil gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-07-16 22:06:01 +0100

nbruin gravatar image

Looks like this bug is still present in current versions too. As far as I can see, it's limited to non-prime finite fields of characteristic 2 (which have their own implementation), and it does seem to apply to non-invertible square matrices of size larger than 1 too. I wasn't able to find a trac ticket for it, so please do report (should it be reported already, we can manage then). There's a good chance it's not too difficult to fix once someone with knowledge of the code looks at it.

edit flag offensive delete link more

Comments

1

Thank you, I will try my hand at making a ticket.

brantmv gravatar imagebrantmv ( 2020-07-16 23:45:54 +0100 )edit
0

answered 2020-07-17 19:18:06 +0100

slelievre gravatar image

Thanks for reporting this bug here and on Sage Trac:

To analyse the error coming from:

sage: M = Matrix([0], ring=GF(4))
sage: M
[0]
sage: M.inverse()
[1]

we can check the documentation and the source code for the inverse method of M:

sage: M.inverse?
sage: M.inverse??

and we see that it calls ~M. In Sage, ~M calls M.__invert__().

The source code for the __invert__ method revealed by

sage: M.__invert__??

involves mzed_invert_newton_john from m4rie.

The source code for that function is at

and it echelonizes the augmented matrix to compute the inverse --- a fine thing to do for an invertible matrix.

There is now a fix at the Sage Trac ticket. After the fix, we first check whether the matrix has full rank; if not, we raise an error; if yes, we compute the inverse by echelonizing the augmented matrix.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-07-16 04:15:30 +0100

Seen: 434 times

Last updated: Jul 17 '20