MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: sum over i+j+k==n


Szabolcs Horvát wrote:
> Jack Kennedy wrote:
>> Hi All,
>> I often find myself needing to sum over triples
>> (or other tuples) like i,j,k where i+j+k=n. Is there
>> a convenient way to write this in Mathematica?
> 
> You didn't mention exactly how do you wish to write n as a sum of three 
> numbers.  In Mathematica 6, the Combinatorica package has 
> IntegerPartitions[], which does it one way.  For example:
> 
> In[1]:= << Combinatorica`
> 
> In[2]:= IntegerPartitions[10, {3}]
> Out[2]= {{8, 1, 1}, {7, 2, 1}, {6, 3, 1}, {6, 2, 2}, {5, 4, 1}, {5, 3,
>    2}, {4, 4, 2}, {4, 3, 3}}
> 

Oops ... IntegerPartitions[] is actually a built-in function (new in Mathematica 6), and not part of Combinatorica ...

Szabolcs


  • Prev by Date: Bug in AbsoluteOptions, PlotRange when Using an Arrow
  • Next by Date: Re: sum over i+j+k==n
  • Previous by thread: Re: sum over i+j+k==n
  • Next by thread: Re: sum over i+j+k==n