2017-12-26 14:43:36 -0500 received badge ● Student (source) 2017-12-19 06:51:53 -0500 commented answer Matrix Permutations Thanks for your help. @vdelecroix I'll try to comprehend your solution ... 2017-12-19 06:49:14 -0500 received badge ● Scholar (source) 2017-12-16 15:19:56 -0500 commented answer Matrix Permutations I think, now I get your point: The 1st step remains and the I'll do this: CountOfInvertibleMatrices3Tuples = len(invertibleMatrices)^3 CountOfInvertibleMatrices3Tuples 838561807000  Is it now ok? Thanks 2017-12-16 14:55:27 -0500 commented answer Matrix Permutations I don't think that I do so. I perform the following steps: I put all invertible Matrices in the variable invertibleMatrices. I try to build all tuple-combinations with 3 matrices and put it in the variable invertibleMatrices3Tuples. I build the products of matrices in each tuple and see if the product is invertible and put them all in the variable invertibleSTUProducts. Did I miss something? 2017-12-16 13:55:31 -0500 commented answer Matrix Permutations Thanks for your help. I tried it as follow based on your code, but it doesn't work. I use CoCalc. It shows the green bar for computation, but it doesn't stop and doesn't return any results. R = [0,1,2,3,4,5,6,7,8,9] C = cartesian_product((R,R,R,R)).list() invertibleMatrices = [matrix(ZZ, 2,2,list(c)) for c in C if matrix(ZZ, 2,2,list(c)).det()] invertibleMatrices3Tuples = cartesian_product((invertibleMatrices, invertibleMatrices, invertibleMatrices)).list() invertibleSTUProducts = [c for c in invertibleMatrices3Tuples if c*c*c.det()] len(invertibleSTUProducts)  BTW: What do you mean by "It is a good idea to use structure in mathematics"? 2017-12-15 22:47:56 -0500 asked a question Matrix Permutations Hello, how do I get all permutations of a Matrix? For the following exercise I would like to get all permutations of a Matrix with integer values in the range $0$ to $9$. There should be $10^4$ permutations. And then generate the permutations of tuples with three matrices. $10^{12}$ permutations and then I would filter the list somehow for the invertible matrices. Is there a better way? Exercise: Let $S, T, U \in \mathbb{R}^{2x2}$ such that, $S_{i, j}, T_{i, j}, U_{i, j} \in {0,1, \cdots, 9}$ How many of the products $S \cdot T \cdot U$ are invertible? In the Sage reference for permutation I couldn't find any thing. Thanks PS: The curly braces couldn't be escaped properly in the LaTex part ... \{0,1, \cdots, 9\}