Message Boards Message Boards

0
|
4029 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

sequence of sums of binomial coefficients

Posted 10 years ago

Hi everyone. I would like to define a following sequence:

sum_(I=1)^2 (2 binomial i)

sum(j=1)^2 (sum(i=1)^2 (2 binomial i)*(2 binomial j))

sum(l=1)^2 [sum(j=1)^2 (sum_(i=1)^2 (2 binomial i)(2 binomial j)(2 binomial l))]

etc

How could I define such a sequence in mathematica without relying on having different letters for different sums (as i,j,l). Notice that I can't write it down as Sum[ Product[Binomial[2,i]^n,{n,1,..}] , {i,2,2} ], for example, since it counts only a subset of realizations needed. Thanks a lot for your help!

POSTED BY: d m
2 Replies
Posted 10 years ago

Is this what you are looking for? Or can you adapt this technique to get what you need?

First just show the constructed strings to try to be able to verify this is correct:

In[1]:= sumbinomial[n_] :=
 StringJoin[
  Join[
   Table["Sum[", {i, 1, n}],
   Table["Binomial[2,i" <> ToString[i] <> "],{i" <> ToString[i] <> ",1,2}]", {i, 1, n}]
   ]
  ]

In[2]:= FullForm[sumbinomial[1]]

Out[2]//FullForm= "Sum[Binomial[2,i1],{i1,1,2}]"

In[3]:= FullForm[sumbinomial[2]]

Out[3]//FullForm= "Sum[Sum[Binomial[2,i1],{i1,1,2}]Binomial[2,i2],{i2,1,2}]"

In[4]:= FullForm[sumbinomial[3]]

Out[4]//FullForm= "Sum[Sum[Sum[Binomial[2,i1],{i1,1,2}]Binomial[2,i2],{i2,1,2}]Binomial[2,i3],{i3,1,2}]"

Now the actual function, which just wraps that with ToExpression to interpret the string and carry out the calculation:

In[5]:= sumbinomial[n_] :=
 ToExpression[
  StringJoin[
   Join[
    Table["Sum[", {i, 1, n}],
    Table["Binomial[2,i" <> ToString[i] <> "],{i" <> ToString[i] <> ",1,2}]", {i, 1, n}]
    ]
   ]
  ]

In[6]:= sumbinomial[1]

Out[6]= 3

In[7]:= sumbinomial[2]

Out[7]= 9

In[8]:= sumbinomial[3]

Out[8]= 27

There should be a clear, simple, easy to understand recursive definition which does exactly what you want, but without the string hacking. Getting all the iterations correctly might be difficult to do until you think about functional programming just the right way.

POSTED BY: Bill Simpson
Posted 10 years ago

Hi Bill, thanks a lot for that. On the one hand, for the above problem I reformulated the formulas mathematically making them a function of (binomial[2,i])^x*binomial([2,2])^(k-x) for some k,x.

But for more complicated examples in my model, I have to use recursive definitions you described above. I still need a bit of time to go through it since my experience with mathematica is limited atm.

POSTED BY: d m
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract