6
$\begingroup$

Assume that I have two number $a$ and $b$ and an $n \times n$ matrix. How can I write code which can compute all determinants of the matrices with entries $a$ or $b$. In other words, I want to see the determinant of all $2^{n^{2}}$ matrices with entries $a$ and $b$.

$\endgroup$
  • $\begingroup$ A short example with a Mathematica code would be helpful for understanding the problem. At least show what you have tried. $\endgroup$ – Sumit Sep 29 '17 at 12:16
  • $\begingroup$ Do you need the multiplicity of each possible determinant value? $\endgroup$ – Coolwater Sep 29 '17 at 12:23
  • $\begingroup$ A.Mpi, please see Michael E2's comment here which is our community's standard welcome message to new users. $\endgroup$ – kglr Sep 29 '17 at 12:57
8
$\begingroup$
n = 3; 
matrices = Tuples[{a, b}, {n, n}];
Length@matrices

512

Det /@ matrices // Simplify // Short

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-a (a-b)^2, -a (a-b)^2, a (a-b)^2, <<486>>, (a-b)^2 b, -(a-b)^2 b, -(a-b)^2 b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Det /@ matrices // Simplify // Tally // Grid[#, Dividers -> All] &

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.