Post Reply 
Multiplication is not commutative
01-28-2014, 12:55 AM (This post was last modified: 02-01-2014 07:02 AM by Joe Horn.)
Post: #1
Multiplication is not commutative
The old timers here will know this already, but the newbies might enjoy it.

Everybody knows that multiplication is commutative* (except for matrices). So ABC=CBA, right? That might make the following seem like a bug in the HP Prime:

[Image: CPoM.png]

But it's not a bug. The same discrepancy occurs on all HP calculators (I think), and rightly so, even on the greatly revered HP-41 (I just checked). Why does this happen? Because of accumulated roundoff errors, combined with HP's philosophy of What You See Is What You Have (no hidden digits). The first multiplication above \((\sqrt 2 *\sqrt 3)\) can't be exact (it is rounded to 12 digits), and then THAT error gets fed into the second multiplication \((...*\sqrt 5)\), which is ALSO inexact (rounded to 12 digits). The error gets compounded. In other words, it's due to the same reason that \((\sqrt 2)^2 \ne2\) on most HP calculators: you're not really squaring the square root of 2, you're actually squaring only the first 12 digits of the square root of 2.

Floating point math in the HP Prime's CAS is a tad more accurate than floating point math in Home (usually), because Home uses 12-digit BCD, whereas CAS uses 48-bit binary, roughly equivalent to 15 BCD digits. That's why CAS seems to get the same answer for all the problems shown above; it uses the very non-HP method of performing the entire calculation to 15 digits, and returning all 15 digits as the answer, but rounding the display to 12 digits. In other words, in CAS, What You See Is Not What You Have, as can be seen in this CAS screen shot:

[Image: CPoM2.png]

* Edit: Many thanks to those who pointed out that all of the the above is not really an example of the commutative property of multiplication being violated, but rather the associative property, because A*B*C = (A*B)*C, and C*B*A = A*(B*C). Quite right. Good catch.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)