Re: Simple n-tuple problem - with no simple solution

• To: mathgroup at smc.vnet.net
• Subject: [mg115883] Re: Simple n-tuple problem - with no simple solution
• From: DrMajorBob <btreat1 at austin.rr.com>
• Date: Mon, 24 Jan 2011 05:22:27 -0500 (EST)

```Brilliant!

Bobby

On Sun, 23 Jan 2011 16:32:03 -0600, Dana DeLouis <dana.del at gmail.com>
wrote:

> On Jan 22, 3:23 am, DrMajorBob <btre... at austin.rr.com> wrote:
>> Here are some timings.
>
>> n = 5; addends = Rationalize@Range[0, 1.0, 0.05];
>> Length@t1[addends, n] // Timing
>>
>> {1.44372, 192}
>> {23.6318, 192}
>
>> n = 7;
>> Length@t1[addends, n] // Timing
>> {1.85135, 364}
>
>> n = 9;
>> Length@t1[addends, n] // Timing
>> {2.04216, 488}
>
>> The Compositions method rendered Mathematica unresponsive at n = 10, but
>> here's n = 25 for my approach:
>> n = 25;
>> Length@t1[addends, n] // Timing
>>
>> {2.57619, 627}
>>
>> I'd say Solve (which must use Integer Linear Programming for this) is
>> the
>> way to go.
>
>
> Hi.  Just some thoughts.   With the smallest unit 1, the most n can be
> is 20.
>
> If we assume that solution sizes smaller than n have implied 0's, then...
>
> IntegerPartitions[20,5]//Length //Timing
> {0.000085,192}
>
> IntegerPartitions[20,20]//Length //Timing
> {0.000244,627}
>
> If we want to look at each exact n, then the function uses {n}
>
> Table[Length[IntegerPartitions[20,{j}]],{j,20}]
> {1,10,33,64,84,90,82,70,54,42,30,22,15,11,7,5,3,2,1,1}
>
> Accumulate[%]
> =
> {1,11,44,108,192,282,364,434,488,530,560,582,597,608,615,620,623,625,626,627}
>
> By adding them up, we see that for n=5, we get the 192.  For n=7, 364,
> etc.
>
> If the question was "Count all possible combinations" as in the last
> total above, then one additional way...
>
> Timing[SeriesCoefficient[
>    1/Times @@ (1 - n^#1 & ) /@
>       Range[20], {n, 0, 20}]]
>
> {0.0003, 627}
>
> = = = = = = = = = =
> HTH  : >)
> Dana DeLouis
>
>

--
DrMajorBob at yahoo.com

```

• Prev by Date: Re: Mathematica 20x slower than Java at arithmetic/special functions, is
• Next by Date: Re: Wavelet and histogram
• Previous by thread: Re: Simple n-tuple problem - with no simple solution
• Next by thread: Re: Simple n-tuple problem - with no simple solution