Re: sum over i+j+k==n
- To: mathgroup at smc.vnet.net
- Subject: [mg84447] Re: sum over i+j+k==n
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Mon, 24 Dec 2007 04:52:11 -0500 (EST)
- References: <fkla8k$3v1$1@smc.vnet.net>
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}} (IIRC in earlier versions Combinatorica could be loaded with <<DiscreteMath`Combinatorica`) I hope this helps, Szabolcs