Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: adding order matters for accuracy ?
Date: Thu, 17 Sep 2009 19:15:19 +0000 (UTC)
Organization: Battelle Energy Alliance (INL)
Lines: 54
Message-ID: <h8u1s7$kvb$1@fred.mathworks.com>
References: <h8mqh5$pgb$1@fred.mathworks.com> <JRCrm.36321$JG1.20628@newsfe24.iad> <h8pflj$qaf$1@fred.mathworks.com> <h8piqr$gnu$1@fred.mathworks.com> <h8ttfl$sl6$1@fred.mathworks.com> <h8tuq7$qpr$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1253214919 21483 172.30.248.37 (17 Sep 2009 19:15:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 17 Sep 2009 19:15:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 688530
Xref: news.mathworks.com comp.soft-sys.matlab:571176

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message 
> Not sure where this wrong statement you read from. Yes they sure can accumulate:
> 
> >> a=[2 repmat(eps,1,100)];
> >> sum(a) % Exactly 2
> 
> ans =
> 
>      2
> 
> >> sum(fliplr(a))
> 
> ans =
> 
>     2.0000
> 
> >> sum(fliplr(a))-sum(a)
> 
> ans =
> 
>   2.2204e-014
> 
> >> 100*eps % <- error are accumulated 100 times
> 
> ans =
> 
>   2.2204e-014


I am not sure about that Bruno.  sum(a) has no error because eps is smaller than eps(2) by definition.  Isn't this only a special case?  It seems to me that in the previous examples, for each element of x, x(ii), all other elements x(jj) were addable to x(ii) with eps(x(ii))<= abs(x(ii) - x(jj)) .  I.e.,

>> a = [10 repmat(eps,1,4)];
>> sum(fliplr(a))-sum(a)
ans =
     0
>> a = [10 repmat(eps,1,5)];
>> sum(fliplr(a))-sum(a)
ans =
     1.77635683940025e-015


because 

sum([eps eps eps eps eps]) > eps(10)/2   is true but not 
sum([eps eps eps eps]) > eps(10)/2




Given this, wouldn't you want to use:

a=[2 repmat(eps(2),1,100)];

to make your point?  Just wondering...