# Checking for invertibility of large matrices in MAGMA

If you have a number of large matrices, and you wish to determine whether each matrix has determinant zero or not, what is the most efficient way to do this in MAGMA

(it appears that calculating the rank is slightly more efficient than calculating the determinant).

**EDIT: **In case it helps, the matrix entries are rational functions in two commuting variables, which come from the coefficients of a power series in a third, noncommuting variable: the aim is to get some sort of indication of when a power series represents a rational function, which requires checking the determinant of progressively larger matrices until it starts being zero. (Although the overall setting is noncommutative, everything in the matrices themselves is commutative so there's no need to worry about left/right determinants, quasi-determinants, etc.)

-
What is in these matrices? Integers, rational, floating point numbers? – Federico Poloni Mar 27 '12 at 18:55

I don't know about Magma specifically, but in general, computing the determinant modulo a bunch of primes is the way to go (bunch = enough small primes so that their product exceeds the Hadamard bound, but of course, once the determinant is nonzero modulo some prime, you can safely halt).

EDIT Just a remark: the above is particularly fast for checking that your matrices are NOT singular, since if the determinant is really zero, you will have to do a lot more checking to be sure. On the other hand, computing the rank will ALWAYS be much slower than this.

-
Thanks for a quick response. – dward1996 Mar 27 '12 at 14:18
But dward1996 did not say that his matrices have integer entries, did he? – Federico Poloni Mar 27 '12 at 18:55
He did say "MAGMA", which people do not usually do floating point computations in... – Igor Rivin Mar 27 '12 at 19:02

I can guess that both the rank and the determinant are computed through some kind of (pivoted) LU factorization.

If so, in order to compute the determinant, after computing the LU factorization, you have to take the product of the factors on the diagonal of U, so it is not surprising that it takes more time than computing the rank: there are indeed more operations to do.

-

There are different parameters for the Determinant command when working over the integers. You should take a look at the online documentation:

http://magma.maths.usyd.edu.au/magma/handbook/text/243

It's quite comprehensive.

-
I just looked, and I do not see the options as especially useful for the OP's problem, unless the Magma people had put in a special hack for zero-checking. – Igor Rivin Mar 27 '12 at 19:21
There is also the IsSingular() command which could be interesting. But unfortunately the manual does not say anything about the implementation. – Hans Giebenrath Mar 27 '12 at 19:35
Thanks for that. I will give the IsSingular command a try. – dward1996 Mar 28 '12 at 7:37