|The peculiar arithmetic of the SmartCalc 300s|
Message #1 Posted by Javier Goizueta on 27 May 2009, 4:48 a.m.
I've received my HP SmartCalc 300s and I'd like to share some findings about its arithmetic.
This calculator shows 10 digits but keeps 16 digits of internal precision in its registers.
So this machine should have impressive precision, right?
I'll do a little test that appeared on Fred Gruenberger's Computer Recreations in Scientific American, April, 1984
(I actually read it from the spanish "Investigación y Ciencia" in June 1984)
The test consists in computing (1.0000001)^(2^27) by applying the square operation 27 times starting with 1.0000001.
The correct answer is 674530.47074108455938....
First, to know what kind of precision we can expect we'll do some testing with a HP50G.
The HP50G has 15 internal digits and we can operate with that precision using the XREAL library
So let's try it:
<< 1.0000001 R~X 1 27 START XSQ NEXT >>
The result is 674530.467837207 with a percent error of 0.0000004305
But we can do better with 15 digits: the internal 15-digit arithmetic of the HP50G is truncated because
it's not meant to be seen; we can operate with 15 rounded digits (or any other rounding/number of digits) using the LongFloat library
<< 1.0000001 R<-->F 1 27 START FSQ NEXT >>
Now the result is 674530.469940699 and the percent error is 0.0000001186
So now we know what to expect with so many digits of precision; let's try the SmartCalc. We'll use the LinearIO mode so that we operate numerically and not with the mini-CAS that MathIO uses.
If we type 1.0000001 and then [x^2] [=] 27 times we get: 674529.1123 with a percent error of 0.0002014
(that's like 468 times larger than the XREAL result which one less digit and truncating the results!!) That's even worse that what can be achieved with 13 digits (percent error of 0.00002264 with LongFloat).
How can this be? Well, I wasn't too suprised becaused I'd played with Casio calculators before.
The reason is that following Casio tradition, some weird rounding if done on the internal numbers,
trying to hide the fact of a limited precision, so that for example
1-(4/3-1)*3 = 0 (which in a honest numerical calculator would reveal the internal precision.)
This rounding makes errors unpredictable and much larger than they could be. Note also that these attempts are bound to fail:
1/9-(10/9-1) = 0 but (1/9 - 0.01 - (10/9-1) + 0.01 = 1E-16
The results of the HP300S in the 1.0000001 test can be explained by a special rounding of the result
of arithmetic operations performed after normalization:
- if the trailing 6 digits are less than 000050, they are rounded down to 000000.
- if the trailing 4 digits are greater than 9949, the number is rounded up (so it ends in 0000)
You can see these rules in action here
1E9 + 1.000050 - 1E9 = 1.00005
1E9 + 1.000049 - 1E9 = 1
1E9 + 0.100049 - 1E9 = 0.100049
1E9 + 0.009950 - 1E9 = 0.01
1E9 + 0.009949 - 1E9 = 0.009949
Note that numbers typed in the calculator are truncated to 15 digits; if you need to enter a value
with full 16 digits you must add a pair of numbers or do some other operation.
The special rounding explains all the intermediate results of the test, which are show here with full internal precision
I've traced similar magic rounding in a Casio FX9960G (using an emulator) and in an old Casio FX750P.
These machines have more complicated rounding rules and the results of the test are similarly poor.
In the case of the FX750P we can operate either at the internal precision of 12 digits (using variables)
or at the displayed precision of 10 digits. Due to the idiosincratic rounding the result of the test using 10 digits
is more precise than with 12 digits!
It's a shame that the SmartCalc tries so hard to be smart. The result of computing 1-(4/3-1)*3 numerically should be 1E-15 showing that it is operating with limited precision. It should be 0 only if fractions or the MathIO mode are used, but the user should know the distinction between exact and approximate computations and be able to compute numerically with predictable results. The SmartCalc is very unreliable, with some results in accordance to its high internal precision and others randomly affected by large errors.
And now for something totally different:
My HP300S has a sticker on the back "Prototype Not for Sale" I saw it after ripping the package and then noticed
the sticker on it too:
I wonder if there's any difference with a production unit; my keyboard misses keystrokes quite often and the cover cannot
be snapped on the back as the user manual suggests.
Prototype - Not For Sale. The unit and contents of this packaging are currently undergoing quality testing and
verification and are subjected to changes. ...
Anybody with a production 300S can tell about that?
Edited: 27 May 2009, 6:53 a.m.