I have the following definition of Dicke states:


Here ⊗ is the tensor product. It is a sum over all permutations of the shown vectors, where exactly $n$ vectors are $(1,0)$ and the other $N-n$ are $(0,1)$ (the 'excitations'). What is an efficient way to define the function $f(n,N)$ in Mathematica?

  • $\begingroup$ What is n? The number of spin down? But you don't specifiy the position! Or do you also want to symmetrice this tensor product? Then this would be a Dicke state, yes? $\endgroup$ – kiara Oct 6 '17 at 14:02
  • $\begingroup$ For me, it is not clear what ⊗ should be. Maybe you mean a tensor product? $\endgroup$ – Henrik Schumacher Oct 6 '17 at 14:05
  • $\begingroup$ It looks a lot like quantum physics where ⊗ is the tensor product. $\endgroup$ – kiara Oct 6 '17 at 14:09
  • 4
    $\begingroup$ I'm voting to close this question as off-topic because it is very specific and unlikely to help anyone other than the OP. Please reformat it by removing the picture and typesetting the actual question, and use a more descriptive title $\endgroup$ – yohbs Oct 6 '17 at 15:27

This gives the Dicke states, for example Dicke[2,1] means that you have two qubits with one exitation.

Dicke[NN_, n_] := 
Dicke[NN, n] = Module[{x, Temp, i, vec, k}, 
k = NN - n;
vec = Table[0, {2^(NN)}];
Temp = Permutations[Join[Table[0, {(NN) - k}], Table[1, {k}]]];
Do[vec[[FromDigits[Temp[[i]], 2] + 1]] = 1;, {i, 1, Length[Temp]}]; 
vec = vec/Norm[vec];
SparseArray[ArrayRules@Table[{vec[[i]]}, {i, 1, Length[vec]}], {2^NN, 1}]];

So use it as

Dicke[3, 0] // Normal

{{0}, {0}, {0}, {0}, {0}, {0}, {0}, {1}}


Dicke[2, 1] // Normal

{{0}, {1/Sqrt[2]}, {1/Sqrt[2]}, {0}}

BTW: You can use the ⊗ symbol also in mathematica if you specify

CircleTimes = KroneckerProduct;  

And then you can use it as in math, like

v = {{1, 0}};

{{1, 0, 0, 0, 0, 0, 0, 0}}

  • $\begingroup$ usage of N as a variable is a bad idea $\endgroup$ – yohbs Oct 6 '17 at 15:25
  • $\begingroup$ @yohbs At a glance I don't believe Fabian used N as a variable, but rather as a pattern name which I believe handles such conflict gracefully. This still could be a problem if one actually wanted to use N (the kernel function) in the body of the definition. $\endgroup$ – Mr.Wizard Oct 6 '17 at 16:40
  • $\begingroup$ True. I changed it to NN. $\endgroup$ – kiara Oct 7 '17 at 17:04
  • $\begingroup$ To be consistent with the usual notation I would suggest that f[n,NN]=Dicke[NN-n,NN] (the argument is the number of excitations), and a more compact definition could be Dicke[k_, NN_] :=SparseArray[({FromDigits[#, 2] + 1, 1} ->1/Sqrt[Binomial[NN, k]]) & /@ Permutations[PadRight[ConstantArray[1, k], NN]], {2^NN, 1}]; $\endgroup$ – M. Stern Nov 1 '17 at 15:18

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