MathGroup Archive 2011

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

Search the Archive

Simple n-tuple problem - with no simple solution

Problem: Given an n-tuple  (n >= 1). with each element  able to take
on the values in
Range[0, 1.0, .05] , produce all the n-tuples that sum to 1.0.

The most direct way to solve this problem is to generaate all possible
n-tuples and Select out all those that sum to 1.0.

For example, when n = 2 :

n = 2;
Select[Tuples[Table[Range[0, 1.0, .05], {n}]], Total[#] == 1 &]

The problem with this solution is that the number of n-tuples that are
generated before the Select is used grows exponentially fast as a
of n - causing the system to run out of memory (RAM) very quickly.

Is there a more memory efficient way to solve this problem that
use so much memory but still is not too slow in terms of processor

Thank you.

  • Prev by Date: Re: Solve fails with this simple inequality problem
  • Next by Date: Mathematica browser plugin with Firefox 3.6.x or 4 beta
  • Previous by thread: Cannot run a program using << with a string I create
  • Next by thread: Re: Simple n-tuple problem - with no simple solution