# det of empty matrix is 1 #10383

Closed
opened this Issue Jan 12, 2016 · 2 comments

Projects
None yet
3 participants
Contributor

### akritas commented Jan 12, 2016

 If M = Matrix(0, 0, []), then M.det() returns 1. Is this on purpose? In other CAS's it returns an error message that the matrix is not square or something to that effect.

### skirpichev added a commit to diofant/diofant that referenced this issue Jan 12, 2016

``` Document that det(Matrix()) == 1: ```
```    Fixes sympy/sympy#10383, see e.g.
https://en.wikipedia.org/wiki/Matrix_%28mathematics%29#Empty_matrices```
``` 90303a8 ```
Member

### jksuom commented Jan 13, 2016

 I believe it is set on purpose. It simplifies coding as it is not necessary make preparations for exceptions. The value 1 is analogous to the value of an empty product. In fact, the determinant of a diagonal matrix is the product of its diagonal entries. For a 0x0 matrix this product takes conventionally the value 1.
Member

### asmeurer commented Jan 13, 2016

 Or applying the Leibniz formula, which (at least according to Wikipedia) is the definition of the determinant, you get Sum(sgn(sigma(i))*Product(a_i,sigma(i), (i, 1, n)), (sigma in S_n)). n=0, so the Product is the empty product (i.e., 1), and the Sum is over S_0, which contains one element (the identity; S_n is a group so it always has at least one element). sgn(e) = 1, so the determinant is 1. Note that `Matrix(1, 0, []).det()` does give a NonSquareMatrixError. But a 0x0 matrix is square.