Ask Your Question

Revision history [back]

It is possible to make an even less computational solution than in @dan_fulea answer. As already mentioned, we simply want to count the solutions of a d - b c != 0 where a, b, c, d are elements of {0, 1, ..., 9}. This is easily obtained from the number of solutions of ad - bc = 0 which itself can be obtained by solving x y = s for all possible values of s. For example

  • xy = 0 has 19 solutions (from which we get 19 * 19 = 361 matrices)
  • xy = 1 has 1 solution (from which we get 1 matrix)
  • xy = 6 has 4 solutions (from which we get 6 * 6 = 36 matrices)

Except for s = 0, the number of solutions of xy = s is the number of divisors of s. In Sage, the number of divisors of s can be obtained with sigma(s, 0) (sigma is the divisor function). Hence

sage: P = set(i * j for i in range(1, 10) for j in range(1, 10))
sage: 19 + sum(sigma(s,0) for s in P)
570
sage: 10**4 - 570
9430

It is possible to make an even less computational solution than in @dan_fulea answer. As already mentioned, we simply want to count the solutions of a d - b c != 0 where a, b, c, d are elements of {0, 1, ..., 9}. This is easily obtained from the number of solutions of ad - bc = 0 which itself can be obtained by solving x y = s for all possible values of s. For example

  • xy = 0 has 19 solutions (from which we get 19 * 19 = 361 matrices)
  • xy = 1 has 1 solution (from which we get 1 matrix)
  • xy = 6 has 4 solutions (from which we get 6 * 6 = 36 matrices)

Except for s = 0, the number of solutions of xy = s is the number of divisors of s. In Sage, the number of divisors of s can be obtained with sigma(s, 0) (sigma is the divisor function). HenceSage

sage: P = set(i * j for i in range(1, 10) range(10) for j in range(1, 10))
sage: 19 + sum(sigma(s,0) range(10))
sage: sum(sum(x * y == s for x in range(10) for y in range(10))**2 for s in P)
570
sage: 10**4 - 570
9430

Now, we can even be more clever. The number of solutions for xy = s is, excepted for s = 0, the number of divisors d of s that belongs to {1, ..., 9} and so that s/d also beongs to {1, ..., 9}. We recover 570 with

sage: Q = set(i * j for i in range(1, 10) for j in range(1, 10))
sage: 19**2 + sum(sum(s%d == 0 and s < 10*d for d in range(1,10))**2 for s in Q)
570

It is possible to make an even less computational solution than in @dan_fulea answer. As already mentioned, we simply want to count the solutions of a d - b c != 0 where a, b, c, d are elements of {0, 1, ..., 9}. This is easily obtained from the number of solutions of ad - bc = 0 which itself can be obtained by solving x y = s for all possible values of s. For example

  • xy = 0 has 19 solutions (from which we get 19 * 19 = 361 matrices)
  • xy = 1 has 1 solution (from which we get 1 matrix)
  • xy = 6 has 4 solutions (from which we get 6 * 6 = 36 matrices)
  • etc

In Sage

sage: P = set(i * j for i in range(10) for j in range(10))
sage: sum(sum(x * y == s for x in range(10) for y in range(10))**2 for s in P)
570
sage: 10**4 - 570
9430

Here 570 is the number of non-invertible matrices with entries in {0, 1, ..., 9}. Now, we can even be more clever. The number of solutions for xy = s is, excepted for s = 0, the number of divisors d of s that belongs to {1, ..., 9} and so that s/d also beongs to {1, ..., 9}. We recover 570 with

sage: Q = set(i * j for i in range(1, 10) for j in range(1, 10))
sage: 19**2 19^2 + sum(sum(s%d == 0 and s < 10*d for d in range(1,10))**2 for s in Q)
570