I want to write a function(has 2 paremeter, n=range,k=number of 1 digits) which finds all probable combinatorics of arbitrary bit strings and evaluate sum of tensor product and divide to sqrt(n) each elements. if you look at the example you all understand easily. and sorry for my bad english .

(1\[CircleTimes]0\[CircleTimes]0)/Sqrt[3] + (0\[CircleTimes]1\
\[CircleTimes]0)/Sqrt[3] + (0\[CircleTimes]0\[CircleTimes]1)/Sqrt[3]

another example

(1\[CircleTimes]1\[CircleTimes]0\[CircleTimes]0)/Sqrt[4] + (1\
\[CircleTimes]0\[CircleTimes]1\[CircleTimes]0)/Sqrt[4] + (1\
\[CircleTimes]0\[CircleTimes]0\[CircleTimes]1)/Sqrt[4] + (0\
\[CircleTimes]1\[CircleTimes]1\[CircleTimes]0)/Sqrt[4] + (0\
\[CircleTimes]1\[CircleTimes]0\[CircleTimes]1)/Sqrt[4] + (0\
  • $\begingroup$ You know how to get permutation from you previous quesiton what you should have mentioned. Now you can use for example this function circle[x_List] := 1/Sqrt[Length@x] CircleDot @@ x to map what you want. Try to use Mathematica notation here, here is no such thing as sqrt(n), also, please pay attention to the way you format your questions. $\endgroup$
    – Kuba
    Sep 14, 2013 at 8:46

1 Answer 1


Using ybeltukov's function from your previous quesiton and the one I suggested in comments you can create what you need:

 f[n_, k_] := Permutations@UnitStep@Range[k-n, k-1]

 circle[x_List] := 1/Sqrt[Length@x] CircleDot @@ x

 function[n_, k_]:= circle /@ f[n, k] // Total

enter image description here

Oh, I see, I used CircleDot instead of CircleTimes. Doesn't matter in fact, let me leave it as it is :)

  • $\begingroup$ @user2777109 so does it fit? I'm confused, you deleted the comment. $\endgroup$
    – Kuba
    Sep 14, 2013 at 20:50
  • $\begingroup$ yes,thank you. lastly, if i want to merge two functions in one.like this. f[n_, k_] := Permutations@UnitStep@Range[k-n, k-1] circle[x_List] := 1/Sqrt[Binomial[n, k]] CircleTimes @@ x function[n_, k_] := circle /@ f[n, k] // Total there is a fail about Binomial[n,k]. how can i correct it? $\endgroup$ Sep 14, 2013 at 20:53
  • $\begingroup$ i would write like this f[n_, k_] := Permutations@UnitStep@Range[k - n, k - 1] circle[x_List] := 1/Sqrt[Binomial[n, k]] CircleTimes @@ x function[n_, k_] := circle /@ f[n, k] // Total and there is an error, i think it is in Binomial[n,k] $\endgroup$ Sep 14, 2013 at 21:13
  • $\begingroup$ @user2777109 func[n_, k_] := Module[{perm, circle}, perm = Permutations@UnitStep@Range[k - n, k - 1]; circle[x_] := 1/Sqrt[Binomial[n, k]] CircleTimes @@ x; circle /@ perm // Total ] $\endgroup$
    – Kuba
    Sep 14, 2013 at 21:24
  • $\begingroup$ i really thank you very much. it was very important for me. you solved my problem $\endgroup$ Sep 14, 2013 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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