1
$\begingroup$

Suppose we have a matrix $A_{3 \times 3}$ and its entries are only from the set of numbers $\{0,1,2,3,4,5,6,7,8,9\}$. Evidently there are $10^9$ possible different such matrices $A$.

Question:

  • Is it a method of computation how many from these $10^9$ matrices are singular?
  • or more accurately can we compute how many matrices of rank $1,2,3$ are in the set of all possible matrices $A$ ?
  • 0
    I doubt than you can do much better than brute force search. You can make it a little more efficient by only computing the rank of those matrices for which the upper left hand corner value is 0, row 1 is nondecreasing (left to right), and the rows are in (non-strictly) ascending lexicographic order.2017-01-10
  • 0
    @quasi Only brute force i.e. to develop a program and make $10^9$ computations? Maybe if it is not possible to give the exact number from this general constraint imposed on a matrix then there are some theorems for an approximate number?2017-01-10
  • 0
    No, it's a lot less than 10^9.2017-01-10
  • 0
    At least, it's not 10^9 _rank_ calculations.2017-01-10
  • 0
    @quasi Yes, I see .. how many ?2017-01-10
  • 0
    Actually, the upper left hand corner can be forced to be _least_, but not necesarily 0.2017-01-10
  • 0
    As to how many ranks need to be computed, I'm not sure, but it's definitely a lot less than $10^9$.2017-01-10
  • 0
    @quasi If it could be less than $10^6$ - it would be, I suppose, available for computations in a reasonable time.2017-01-10
  • 0
    If I've computed correctly, a brute force approach with the reductions I suggested would need to compute the rank for 63,192,712 matrices. That's a lot more than the $10^6$ you wished for, but it's still a lot less than $10^9$.2017-01-10
  • 0
    @quasi ok maybe there are possible other reductions. I wonder how the set of ten natural numbers should look in order to reduce the number of computations the most - maybe {1,2,4,8, ....2^10} or ten distinct prime numbers?2017-01-10
  • 0
    If you use prime numbers, it should at least be easy to count the rank-one matrices, since you can only have those where columns repeat or rows repeat. Every other scaling would require that one element can be written as the multiple of another, which primes forbid. This is not true for your digits, since you can have $\begin{bmatrix} 1&3&2\\2&6&4\\3&9&6\end{bmatrix}$ which is rank one.2017-01-10
  • 0
    @FlorianThe easiest usage of primes would be in the case of $2\times{2}$ matrices :)2017-01-10

2 Answers 2

1

Ok, I wrote a brute force program to compute the ranks for each of the $10^9$ possible $3\times3$ matrices with integer entries between $0$ and $9$ inclusive. The run time was only $2$ minutes. Here are the counts: \begin{align} &\text{rank }0\text{ :}\;\;1\\ &\text{rank }1\text{ :}\;\;16\text{,}461\\ &\text{rank }2\text{ :}\;\;19\text{,}929\text{,}402\\ &\text{rank }3\text{ :}\;\;980\text{,}054\text{,}136\\ \end{align}

As requested, here is the program I wrote to get the counts. Nothing clever here, and no attempt at optimization -- just a brute force search.

enter image description here

  • 0
    This is an interesting result, the time of calculations is astonishingly short. The number of singular matrices is here only a small percentage of the general number of matrices, what I suspect ( however almost 20 millions) Did you use calculations of determinant for the result, can your program be easily adopted for different ten entry numbers ? Please write something about it..2017-01-11
  • 0
    Yes, I used determinants. The program can easily be modifies for other sets of numbers. If the numbers are relatively small, the program will be fast (assuming 3 x 3 matrices).2017-01-11
  • 0
    Do you have some view how should be chosen these ten integer digits (negative including) to **maximize** the number of of singular matrices? Maybe {-4,-3,-2,-1,0,1,2,3,4,5} ? Having so fast program you can make some interesting experiments.. I was also thinking about developing such program, but it's still only an idea..2017-01-11
  • 0
    Can you progam in C? If so, you can use my program.2017-01-11
  • 0
    I'll try the range -4 .. 5 and let you know.2017-01-11
  • 0
    Are you ready publish it here? I could transform it into matlab, I suppose .. I've added tag computational mathematics to question to make your answer coherent with it..2017-01-11
  • 0
    For this kind of brute force search, CAS programs such as Maple, Mathematica, MatLab would be too slow. For example, if I converted my C program to Maple, it would be slower by a factor of 200. My C program is not doing anything clever. The fact that it's fast is simply due to the fact that many C statements compile to single instructions at the CPU level.2017-01-11
  • 0
    Thank you for the warning..2017-01-11
  • 0
    I did a naive implementation of a brute-force search in Matlab (using Matlabs rank() function which actually computes an SVD and counts non-zero singular values, not a very efficient method). It took 6 hours to go through all combinations. Interestingly I have one more rank 3 and one less rank 2 matrix. Might be numerical inaccuracies though, I'm not sure.2017-01-11
  • 0
    @Florian 6 hours to 2 minutes.. really, it is a difference ..interesting what case was classified differently.. anyway, thank you for the confirmation of the quasi's result..2017-01-11
  • 0
    @Florian: Can we figure out the reason for the discrepancy? How about getting the counts using a smaller range -- say 0,1,2 instead of 0,1,2,...,9?2017-01-11
  • 0
    @quasi: Sure For 0,1, 2 I have: #(rk=0)=1, #(rk=1)=266, #(rk=2)=6224, #(rk=3)=12792. For 0, 1, 2, 3: (1, 735, 48510, 212898). For 0, 1, 2, 3, 4: (1, 1684, 227052, 1724388).2017-01-11
  • 0
    @Florian: My results are the same except that for 0,1,2, I get #(rk=2)=6624). I suspect that your result of 6624 is just a typo. Yes?2017-01-11
  • 0
    Yes, should have been 6624, sorry for that.2017-01-11
  • 0
    So the discrepancy for 0,1,...,9 could be due to MatLab rounding error? My C program uses only integer arithmetic so is exact.2017-01-11
  • 0
    Matlab would use float32 in this case so it fails to detect the correct rank if the condition number exceeds something a bit less than $10^{16}$. Maybe. Could you elaborate how you do it with integer arithmetic (maybe as part of your reply)? I'd be interested to know for my own curiosity.2017-01-11
  • 0
    Since it's only 3x3, I used determinants and sub-determinants to find the rank -- no Gaussian elmination.2017-01-11
  • 1
    The mystery is solved, quasi was right. I reimplemented with sub-determinants (only 1h40) and can confirm quasis results. The one matrix where it differed is $M = \begin{bmatrix} 0 & 0 & 0 \\ 6 & 1 & 3 \\ 1 & 7 & 0 \end{bmatrix}$ for which Matlabs (R2014a) ${\rm rank}(M)$ returns 3 instead of 2. Funny: ${\rm rank}(M^T)$ returns 2. Btw, R2016b does not do this, there it is correct. P.S.: This has nothing to do with the question, sorry for the Offtopic.2017-01-11
  • 0
    @Florian Congratulations :) You have discovered that even Matlab can be imperfect, btw it is strange that it makes errors on so simple matrices..2017-01-11
  • 0
    I made a post at SO, so the OT-Matlab discussion can continue there. ;-) Seems to be version and/or platform dependent. http://stackoverflow.com/questions/41594612/surprised-by-inconsistent-behaviour-of-matlabs-rank-function-on-small-intege2017-01-11
1

Here are the counts for the $10^9$ possible $3\times3$ matrices with integer entries between $-4$ and $5$ inclusive: \begin{align} &\text{rank }0\text{ :}\;\;1\\ &\text{rank }1\text{ :}\;\;23\text{,}913\\ &\text{rank }2\text{ :}\;\;28\text{,}143\text{,}360\\ &\text{rank }3\text{ :}\;\;971\text{,}832\text{,}726\\ \end{align}

  • 0
    as I suspect, the number is greater :) I wonder whether this choice of numbers is the most optimal to maximize the number of singular matrices..but without some kind of theory, I suppose,it can't be proved..2017-01-11
  • 0
    Interesting in this result that the number of rank 2 matrices has increased almost in the same ratio as the number of rank 1 matrices ..2017-01-11
  • 0
    I could imagine that including highly composite numbers helps, as there are many ways to rescale them to form linear dependencies. Just a theory though.2017-01-11
  • 0
    @Florian Whatever it is, we probably could agree that for some set of ten different integers the number of singular matrices achieves maximum.. how to find it I have not a slightest idea, only intuition..2017-01-11
  • 0
    @quasi Hey, quasi. Would it be possible for you to attach to the answer the code which produced these results ? Then I would accept the answer, probably, as it is visible, there are no other methods than just computational programs..2017-01-16
  • 0
    @Widawensen -- I couldn't find a way to post the code as text (too many lines for MSE, I think), so I posted it as an image.2017-01-17
  • 0
    @quasi It's ok. Thank you very much that you have found the way. The code is completely comprehensible.2017-01-17
  • 0
    @quasi Btw I wonder how the program could be speeded-up if we, at the beginning, would insert into table all possible triple and double products of integers, for example product_3[a][b][c]=a*b*c etc..2017-01-17
  • 0
    @quasi quasi, I have found the example of a inserting of code with the use of
        
    see answer of Felix Marin in http://math.stackexchange.com/questions/838326/3-random-numbers-to-describe-point-on-a-sphere
    2017-01-17
  • 0
    @Widawensen -- I tried that, but it truncated the code (too long for MSE, I suspect).2017-01-17
  • 0
    @quasi Hmm, so it must be a limit for a code.. Good you have found the other method ..2017-01-17