Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: the sign of the sum of the difference different from the sign of the difference of the sums
Date: Wed, 23 Dec 2009 15:40:25 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 20
Message-ID: <hgtdl9$212$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 1261582825 2082 172.30.248.35 (23 Dec 2009 15:40:25 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Dec 2009 15:40:25 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2146203
Xref: news.mathworks.com comp.soft-sys.matlab:594531

Dear experts,
I'm using matlab 2009b with win xp (coreduo E8500). I should calcolate the difference of the sum of two vectors and I noticed this misbehavior: (you can find the workspace with the two vectors at http://www.box.net/shared/1rtxb8xt28 ):

>> format long
>> sum(lpt -lvt)

ans =

   -1.455870024968571e-015

>> sum(lpt)-sum(lvt)

ans =

    1.136868377216160e-013

ok, the numbers are not equal due to the finite precision arithmetic. But, what about the sign? I cannot distinguish which one of the two sums is larger. Is there a way to determine the correct sign of the result, i.e. which one of the sums is larger?
Thanks in advance,

Lorenzo