I don’t feel too strongly about this issue, but let me at least add a
motivating example:
A=(rand(Int64,2,2))
2x2 Array{Int64,2}:
-7148224804043827887 1550119287025645287
4310643582572096085 2785513071409872787
A[1,1]*A[2,2]-A[1,2]*A[2,1]
5953626061256297424
det(A)
-2.659348538587869e37
A user might reasonably expect these to return the same value.
What I find perhaps more disappointing is that for a BigInt array it
still gives a floating point number and not a BigInt. BTW - this can
be done efficiently. You pick a sequence of primes p_1,p_2,…,p_k
such that their product is larger than the determinant (easy using
Hadamard’s inequality) and compute the determinant in GF(p_i) for each
i and then use the Chinese remainder theorem to compute the remainder
modulo p_1p_2…*p_k which uniquely specifies the determinant.
Mathematically, the determinant is just a polynomial in the entries of
the matrix and thus if you have a matrix whose elements are in a ring
R, the determinant should be an element of R as well. Integers in
Julia are in point of fact elements of a ring (e.g. Z/2^64Z) and as
such it does make sense that the determinant returns the corresponding
ring element. It would seem crazy to a user if they constructed a
matrix of elements of integers modulo 3^40, took its determinant, and
got a floating point number. In a way, Julia currently does the same.
Tamas, I think your question is a good one. In point of fact, the
determinant is a very important mathematical quantity, but not the
most important for numerical analysis. It is certainly not a good way
to test for invertibility. If M is the 500 by 500 identity matrix then
Julia reports:
det(M/5)
0.0
rank(M)
500
What is most important of course is that if Julia chooses to do a
floating point computation that it gives the correct number! I’m
pleased to see this is getting fixed.
Danny