Path: news.mathworks.com!not-for-mail
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$1@fred.mathworks.com>
References: <hpp13j$o1i$1@fred.mathworks.com> <hpp78k$ef6$1@fred.mathworks.com> <hpp8ip$2cs$1@fred.mathworks.com> <hppeh1$jdo$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1270939448 20942 172.30.248.35 (10 Apr 2010 22:44:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 10 Apr 2010 22:44:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872154
Xref: news.mathworks.com comp.soft-sys.matlab:625426

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hppeh1$jdo$1@fred.mathworks.com>...
> "Uriah Stephenson-Ward" <uriah+spam@urijah.org> wrote in message <hpp8ip$2cs$1@fred.mathworks.com>...
> > ........
> > 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.

Dimensions[
 DeleteCases[
  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.