Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 .

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

another example

function[4,2]
(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\
\[CircleTimes]0\[CircleTimes]1\[CircleTimes]1)/Sqrt[4] 
share|improve this question
    
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. –  Kuba Sep 14 '13 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 :)

share|improve this answer
    
@user2777109 so does it fit? I'm confused, you deleted the comment. –  Kuba Sep 14 '13 at 20:50
    
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? –  user2777109 Sep 14 '13 at 20:53
    
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] –  user2777109 Sep 14 '13 at 21:13
    
@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 ] –  Kuba Sep 14 '13 at 21:24
    
i really thank you very much. it was very important for me. you solved my problem –  user2777109 Sep 14 '13 at 21:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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