What is the determinant of a 0x0 matrix

926 views
Skip to first unread message

Travis Scrimshaw

unread,
Mar 18, 2016, 11:31:04 PM3/18/16
to sage-devel
Hey all,
   We ended up needing to compute the determinant of a 0x0 matrix in #17030.Sage currently says the following:

sage: mat = matrix(ZZ, 0, 0)
sage
: mat.det()
1

However, the code (and myself) was expecting this to be 0 as the sum in the definition is vacuous.

Although, in a sense, the 0x0 matrix is its own inverse, so this might be an argument for having it be 1.

Thoughts?

Best,
Travis

Montgomery-Smith, Stephen

unread,
Mar 18, 2016, 11:40:53 PM3/18/16
to sage-...@googlegroups.com
Given two matrices G and H, the matrix K = [G, 0; 0, H] has determinant
det(K) = det(G) det(H)
So if you want this formula to remain true if one of the matrices is 0x0, then you want the determinant of a 0x0 matrix to be 1.



From: sage-...@googlegroups.com [sage-...@googlegroups.com] on behalf of Travis Scrimshaw [tsc...@ucdavis.edu]
Sent: Friday, March 18, 2016 10:31 PM
To: sage-devel
Subject: [sage-devel] What is the determinant of a 0x0 matrix

--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To post to this group, send email to sage-...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Fredrik Johansson

unread,
Mar 18, 2016, 11:53:41 PM3/18/16
to sage-devel

Using the Leibniz formula as the definition, the determinant of an n by n matrix is a sum of products, one product for each of the n! permutations on n elements. When n = 0, there is exactly one such permutation, the identity permutation of the empty set, so there is one term in the sum for the determinant, and its value is 1 since it is the empty product.

This convention also agrees with the determinant being the product of all eigenvalues, and other useful properties.

Fredrik

John Cremona

unread,
Mar 19, 2016, 7:09:45 AM3/19/16
to SAGE devel

Definitely 1 not 0.   It's a multiplicative gadget.

John

--

Florent Hivert

unread,
Mar 19, 2016, 7:38:24 AM3/19/16
to sage-...@googlegroups.com
Hi Travis,

This was my first sage contribution ! In src/sage/matrix/matrix_space.py
there is a function:

test_trivial_matrices_inverse

Which is supposed to be runs on all various implementation of matrix. The doc
says:

The methods determinant, is_invertible, rank and inverse are checked for
- the 0x0 empty identity matrix
- the 0x3 and 3x0 matrices
- the 1x1 null matrix [0]
- the 1x1 identity matrix [1]

This was done before categories and there is the following comment:

TODO: must be adapted to category check framework when ready (see trac \#5274).

which has been forgotten so far... This should clearly be moved to the generic
test-suite for matrix spaces.

Cheers,

Florent

Simon King

unread,
Mar 19, 2016, 8:34:19 AM3/19/16
to sage-...@googlegroups.com
Hi Florent,

On 2016-03-19, Florent Hivert <Florent...@lri.fr> wrote:
> This was done before categories and there is the following comment:
>
> TODO: must be adapted to category check framework when ready (see trac \#5274).
>
> which has been forgotten so far... This should clearly be moved to the generic
> test-suite for matrix spaces.

I don't see how you could reasonably move that test to the category
framework. After all, tests are performed on parents (here: matrix
spaces) and elements, and you talk here about very special parents
(namely: those with one dimension equal to zero). Hence, the categorial
_test_... method would need to explicitly test whether one dimension is
zero (otherwise the test is skipped), and in addition you need to
explicitly add TestSuite(MatrixSpace(ZZ,0,0)).run() somewhere in the docs.
How is that a progress compared to what we have now?

Best regards,
Simon

Travis Scrimshaw

unread,
Mar 19, 2016, 8:46:44 AM3/19/16
to sage-devel
Hey all,
   Thank you for the clarification (I always seem to forget that S_0, being the trivial group,
has an identity element...). We can just work around it.

Hey Florent,

On 2016-03-19, Florent Hivert <Florent...@lri.fr> wrote:
> This was done before categories and there is the following comment:
>
>     TODO: must be adapted to category check framework when ready (see trac \#5274).
>
> which has been forgotten so far... This should clearly be moved to the generic
> test-suite for matrix spaces.

I don't see how you could reasonably move that test to the category
framework. After all, tests are performed on parents (here: matrix
spaces) and elements, and you talk here about very special parents
(namely: those with one dimension equal to zero). Hence, the categorial
_test_... method would need to explicitly test whether one dimension is
zero (otherwise the test is skipped), and in addition you need to
explicitly add TestSuite(MatrixSpace(ZZ,0,0).run() somewhere in the docs.
How is that a progress compared to what we have now?

I agree with Simon that I don't think it could be moved to a category-level.
Yet, what could be done is have it be a method _test_trivial_matrices_inverse,
as any method _test_* gets called by TestSuite. I do, however, think this would
be progress because parents nowadays always have a TestSuite check run.
So any new matrix space subclasses will then get this consistency check.

Best,
Travis

Dima Pasechnik

unread,
Mar 19, 2016, 9:59:43 AM3/19/16
to sage-devel
several formulae for determinants need the base case, and it is always 1 for 0x0 matrix. E.g. think of decomposing w.r.t. a row, or expressing the determinant of the matrix times the determinant of the submatrix obtained by removing 1st and last rows and columns in terms of certain minors.
Reply all
Reply to author
Forward
0 new messages