From: akcs.joehorn@hpcvbbs.external.hp.com (Joseph K. Horn)
Date: Sun, 24 Oct 1993 06:40:02 GMT
Subject: GX has improved accuracy!
Message-ID: <2cca1b36.2343comp.sys.hp48@hpcvbbs.external.hp.com>
Path: cdc486.cdc.polimi.it!ghost.dsi.unimi.it!batcomputer!munnari.oz.au!spool.mu.edu!sdd.hp.com!hp-cv!hp-pcd!hpcvra!rnews!hpcvbbs!akcs.joehorn
Newsgroups: comp.sys.hp48
Lines: 138
+------------------------------------------------------+
| G SERIES HAS BETTER INTERNAL MATRIX ACCURACY THAN SX |
+------------------------------------------------------+
WOW, check this out. HP improved the ACCURACY of the matrix functions
in the G series! Why don't they advertise the fact? This is great!
Try out these examples.
The inverse of
[[ 58 59 ]
[ 68 69 ]]
(obtained by pressing 1/X) is supposed to be exactly
[[ -6.9 5.9 ]
[ 6.8 -5.8 ]]
and that's what the GX gets. And if you then invert that, you get
the original back, as you should.
But the SX gets:
[[ -6.89999999197 5.89999999314 ]
[ 6.79999999211 -5.79999999326 ]]
Lots of wrong digits at the end of each element. Re-invert, and you
get:
[[ 58.0000000022 59.0000000020 ]
[ 68.0000000027 69.0000000023 ]]
instead of the original.
Even if you key in the correct inverse listed above, and press 1/X on
that, you *still* don't get the original back. The SX just doesn't
have the accuracy of the GX.
Other examples to try:
[[ 79 94 ] <--> [[ 25 -18.8 ]
[ 105 125 ]] [ -21 15.8 ]]
[[ 3 101 ] <--> [[ -36.7 10.1 ]
[ 11 367 ]] [ 1.1 -.3 ]]
GX gets these right. SX doesn't.
Here's a fascinating and unexpectedly elegant proof of the GX's
superiority, brought to my attention by Rodger Rosenbaum. Hilbert
matrices are horribly ill-conditioned and are a good test of a
machine's accuracy. The 4x4 Hilbert matrix has this form:
[[ 1/1 1/2 1/3 1/4 ]
[ 1/2 1/3 1/4 1/5 ]
[ 1/3 1/4 1/5 1/6 ]
[ 1/4 1/5 1/6 1/7 ]]
It can be obtained by running this 'HILBERT' program:
%%HP: T(3);
@ HILBERT, by Joe Horn; input n, returns n-by-n Hilbert matrix
\<< \-> n
\<< 1 n
FOR j j DUP n + 1 -
FOR k k INV
NEXT
NEXT { n n } \->ARRY
\>>
\>>
It has this as its exact inverse:
[[ 16 -120 240 -140 ]
[ -120 1200 -2700 1680 ]
[ 240 -2700 6480 -4200 ]
[ -140 1680 -4200 2800 ]]
which I just verified using the Derive program. But if you invert the
4x4 Hilbert matrix on your HP48, you'll see elements that differ from
the expected inverse listed above. Until yesterday I'd have
attributed this just to round-off errors accumulating during the
internal calculation of the inverse.
*** WRONG! *** That's NOT primarily what's happening. Here's proof.
Here's what the SX gets:
[[ 16.0000000111 -120.000000119 240.000000282 -140.000000182 ]
[ -120.000000124 1200.00000133 -2700.00000317 1680.00000205 ]
[ 240.000000302 -2700.00000326 6480.00000779 -4200.00000504 ]
[ -140.000000199 1680.00000216 -4200.00000516 2800.00000334 ]]
Lots of wrong digits. But do the same process on the "more accurate"
GX and you get even worse-looking results:
[[ 16.0000000325 -120.000000365 240.000000882 -140.000000575 ]
[ -120.000000365 1200.00000411 -2700.00000995 1680.00000649 ]
[ 240.000000882 -2700.00000995 6480.00002408 -4200.00001572 ]
[ -140.000000576 1680.00000650 -4200.00001572 2800.00001027 ]]
If the GX is more accurate, why are its results all worse than the
SX's results? The answer is that the HP48 NEVER CONTAINED the Hilbert
matrix. For example, the third element is supposed to be 1/3, right?
But the HP48 only had the first 12 digits of 1/3 (0.333333333333) in
that position, not 1/3. Thus we need to test a new hypothesis: could
the GX result actually be the CORRECT answer, given that the values in
the matrix were rounded off to 12 places BEFORE the inverse was
calculated?
To test this, I typed the following into Derive, setting the
calculation accuracy to 20 places and the notation to 12 digits:
[[ 1.00000000000 .500000000000 .333333333333 .250000000000 ]
[ .500000000000 .333333333333 .250000000000 .200000000000 ]
[ .333333333333 .250000000000 .200000000000 .166666666667 ]
[ .250000000000 .200000000000 .166666666667 .142857142857 ]
[ .200000000000 .166666666667 .142857142857 .125000000000 ]]
That is what you REALLY get when you run 'HILBERT' on the HP48, not
the idealized matrix of reciprocals listed above.
Inverting this in Derive yields what the HP48 SHOULD get:
[[ 16.0000000325 -120.000000366 240.000000884 -140.000000576 ]
[ -120.000000366 1200.00000412 -2700.00000997 1680.00000651 ]
[ 240.000000884 -2700.00000997 6480.00002413 -4200.00001575 ]
[ -140.000000576 1680.00000651 -4200.00001575 2800.00001029 ]]
Compare this to what the GX gets! Almost the same! The very worst
error is only 5 off in the 12th place. So the "errors" that we
mistakenly attributed to faulty calculations were in fact due to
faulty inputs, and our hypothesis is validated. The SX, however, has
errors propagating all the way up to the 9th decimal place. The GX
therefore is superior to the SX in matrix math accuracy.
-Joseph K. Horn- EQU akcs.joehorn@hpcvbbs.cv.hp.com