1

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$ ?
Widawensen
  • 8,172
  • 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. – quasi Jan 10 '17 at 13:40
  • @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? – Widawensen Jan 10 '17 at 13:46
  • No, it's a lot less than 10^9. – quasi Jan 10 '17 at 13:47
  • At least, it's not 10^9 rank calculations. – quasi Jan 10 '17 at 13:47
  • @quasi Yes, I see .. how many ? – Widawensen Jan 10 '17 at 13:48
  • Actually, the upper left hand corner can be forced to be least, but not necesarily 0. – quasi Jan 10 '17 at 13:51
  • As to how many ranks need to be computed, I'm not sure, but it's definitely a lot less than $10^9$. – quasi Jan 10 '17 at 13:52
  • @quasi If it could be less than $10^6$ - it would be, I suppose, available for computations in a reasonable time. – Widawensen Jan 10 '17 at 13:56
  • 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$. – quasi Jan 10 '17 at 14:50
  • @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? – Widawensen Jan 10 '17 at 14:57
  • 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. – Florian Jan 10 '17 at 17:08
  • @FlorianThe easiest usage of primes would be in the case of $2\times{2}$ matrices :) – Widawensen Jan 10 '17 at 17:25

2 Answers2

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

quasi
  • 58,772
  • 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.. – Widawensen Jan 11 '17 at 08:11
  • 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). – quasi Jan 11 '17 at 08:20
  • 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.. – Widawensen Jan 11 '17 at 08:27
  • Can you progam in C? If so, you can use my program. – quasi Jan 11 '17 at 08:29
  • I'll try the range -4 .. 5 and let you know. – quasi Jan 11 '17 at 08:31
  • 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.. – Widawensen Jan 11 '17 at 08:32
  • 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. – quasi Jan 11 '17 at 08:35
  • Thank you for the warning.. – Widawensen Jan 11 '17 at 08:38
  • 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. – Florian Jan 11 '17 at 08:39
  • @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.. – Widawensen Jan 11 '17 at 08:45
  • @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? – quasi Jan 11 '17 at 08:51
  • @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). – Florian Jan 11 '17 at 09:01
  • @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? – quasi Jan 11 '17 at 09:15
  • Yes, should have been 6624, sorry for that. – Florian Jan 11 '17 at 09:16
  • So the discrepancy for 0,1,...,9 could be due to MatLab rounding error? My C program uses only integer arithmetic so is exact. – quasi Jan 11 '17 at 09:18
  • 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. – Florian Jan 11 '17 at 09:21
  • Since it's only 3x3, I used determinants and sub-determinants to find the rank -- no Gaussian elmination. – quasi Jan 11 '17 at 09:24
  • 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. – Florian Jan 11 '17 at 15:03
  • @Florian Congratulations :) You have discovered that even Matlab can be imperfect, btw it is strange that it makes errors on so simple matrices.. – Widawensen Jan 11 '17 at 16:32
  • 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-intege – Florian Jan 11 '17 at 17:31
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}

quasi
  • 58,772
  • 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.. – Widawensen Jan 11 '17 at 08:54
  • 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 .. – Widawensen Jan 11 '17 at 09:13
  • 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. – Florian Jan 11 '17 at 09:14
  • @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.. – Widawensen Jan 11 '17 at 09:21
  • @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.. – Widawensen Jan 16 '17 at 16:01
  • @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. – quasi Jan 17 '17 at 02:55
  • @quasi It's ok. Thank you very much that you have found the way. The code is completely comprehensible. – Widawensen Jan 17 '17 at 07:22
  • @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]=abc etc.. – Widawensen Jan 17 '17 at 07:41
  • @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
    – Widawensen Jan 17 '17 at 07:55
  • @Widawensen -- I tried that, but it truncated the code (too long for MSE, I suspect). – quasi Jan 17 '17 at 07:56
  • @quasi Hmm, so it must be a limit for a code.. Good you have found the other method .. – Widawensen Jan 17 '17 at 08:00