From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Very weird resolution issue. Bug ????? Seriously !!
Date: Wed, 4 Mar 2009 03:16:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 11
Message-ID: <gokrpi$ing$>
References: <goju5b$nv4$> <gok3qm$2gn$> <gok5db$mqi$> <gok6c5$19g$> <gok8gq$2na$> <gok9cs$3ut$> <gokdr9$heh$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1236136562 19184 (4 Mar 2009 03:16:02 GMT)
NNTP-Posting-Date: Wed, 4 Mar 2009 03:16:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:522319

"Sung Soo Kim" <> wrote in message <gokdr9$heh$>...
> .......
> So, isn't really there any standard on matrix multiplication? If it is, it is really surprising...   :(
>  .......

  Sung Soo Kim, it is a serious mistake in my opinion to constrain oneself to always performing arithmetic operations in precisely the same order or even with the same algorithm in accomplishing some goal.  To give a rather extreme example of this latter, consider a problem that was posed recently on this newsgroup.  The task (in slightly simplified form) was to compute the sum of the squares of every possible difference in pairings of the n elements of a vector of values.  To do this directly requires n^2 subtractions, n^2 squarings, and n^2-1 additions.  However, it can readily be shown that the same answer (mathematically speaking) can be obtained using a quite different expression that uses only 2*n-2 additions, n squarings, n subtractions, one division, and one crucial multiplication, which amounts to vastly fewer operations for large n.  Obviously the rounding errors in the two 
methods would be different, but it would be a shame not to be able to take advantage of such savings as this. 

  I think the same principle should apply even to such seemingly routine tasks as computing the product of matrices.  There are some important shortcuts that can be used in such calculations but they require processing the data in different arrangements than one would expect.  I seriously doubt that Mathworks would be happy living under the restriction that they always had to use a consistent order of operations or even a consistent algorithm in matrix multiplication from one Matlab version to the next.  In your case it was a mistake to assume that the b(1,1) element was arrived at in precisely the same manner as was c.  It is far better that users create their applications with sufficient robustness so as not to be vulnerable to variations in rounding errors.  Rounding errors are a fact of life that must be faced in any use of floating point numbers.

Roger Stafford