From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Generating a huge array.
Date: Sat, 10 Apr 2010 22:44:08 +0000 (UTC)
Organization: Magma Geosciences Inc.
Lines: 21
Message-ID: <hpquvn$kee$>
References: <hpp13j$o1i$> <hpp78k$ef6$> <hpp8ip$2cs$> <hppeh1$jdo$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1270939448 20942 (10 Apr 2010 22:44:08 GMT)
NNTP-Posting-Date: Sat, 10 Apr 2010 22:44:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872154
Xref: comp.soft-sys.matlab:625426

"Roger Stafford" <> wrote in message <hppeh1$jdo$>...
> "Uriah Stephenson-Ward" <> wrote in message <hpp8ip$2cs$>...
> > ........
> > Interestingly, the Mathematica script creates an array <174504x4 double> and this script creates an array <176851x4 double>, I'm wondering if Mathematica was dropping some possible values, or vice a versa.
> > 
> > Thanks.
>   Offhand I would guess that Mathematica suffered from some improper round offs with the decimal fractions you gave it.  With your inequality x < 0, you may have thrown away some combinations whose x was just a tiny round off amount below zero and that therefore ought to have been saved.  Perhaps if you had said x < -0.00000001, it might have worked properly.  Remember, on a binary machine (which we all have nowadays) the fractions 0.001 and 0.01 and most other decimal fractions cannot be exactly represented as binary fractions and this can cause mischief.  That is no fault of Mathemetica, but rather the algorithm and the machine used.  With n equal to 100 you should have gotten precisely 101*102*103/6 = 176851, as James has said.  It is something that can be proved with mathematical rigor.
> Roger Stafford

Roger is correct.

  Flatten[Table[{a, b, c, 1 - a - b - c}, {a, 0, 1, .01}, {b, 0, 
     1, .01}, {c, 0, 1, .01}], 2], {_, _, _, x_ /; x < -0.000001}]]

returns (176851,4)

So a basic lesson in round-off errors and relational operators is relearned. It just looked different in Mathematica, I guess.