Re: sum over i+j+k==n
- To: mathgroup at smc.vnet.net
- Subject: [mg84430] Re: sum over i+j+k==n
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Mon, 24 Dec 2007 04:43:10 -0500 (EST)
- References: <fkla8k$3v1$1@smc.vnet.net> <476E87EB.7020205@gmail.com>
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