The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

Strange matrix results for HP-71B Math ROM
Message #1 Posted by J-F Garnier on 5 July 2004, 7:49 a.m.

Following a recent long discussion, about matrix calculation accuracy on various calculators, I was quite surprised by the HP-71B Math ROM matrix performance, and investigated a little bit.

First, using the Kahan exemple, I noticed that determinant calculation (DET function) gives a not so accurate answer:
Kahan matrix: DET=-.999999999998
transposed matrix: DET=-.999999999989
First, why is the determinant of the transposed matrix different?
Second, why is the result non-integer, as all elements are integer and no overflow occurs?

Then I built a simpler exemple, in order to check that the DET function uses internal 15-digit accuracy (this was stated many times, but no clear evidence was given). I used this matrix:
1+1E-7 1+2E-7
1+3E-7 1+4E-7
If DET uses 15-digits accuracy, result should be -2E-7, otherwise loss of accuracy will occur and result is expected to be 0.
HP-71B Math ROM gives 1.0000003E-14 so it seems that 15-digit accuracy is used but not only is the value half than expected, but the sign is wrong.
Transposing the matrix gives DET= 2.0000004E-14. Sign is still wrong.
Can we call this a bug? I don't know, but I checked that all next models starting from the HP-28S give correct DET value, so algorihms were changed at some point.

J-F

      
Re: Strange matrix results for HP-71B Math ROM
Message #2 Posted by J-F Garnier on 5 July 2004, 7:57 a.m.,
in response to message #1 by J-F Garnier

Sorry, my test matrix was not correctly reproduced in this post (a bug?):
| 1.0000001 1.0000002
| 1.0000003 1.0000004
I hope it's OK now.

J-F

      
Re: Strange matrix results for HP-71B Math ROM
Message #3 Posted by Werner Huysegoms on 5 July 2004, 8:29 a.m.,
in response to message #1 by J-F Garnier

As to why the results are non-integer and the transposed matrix has a 'different' result: The numerical operations in the algorithm used (some variant of LU-decomposition followed by the multiplication of the elements on the diagonal) are exposed to roundoff errors, of course. The operations are different in the transposed matrix - that's why the roundoff errors are different, too. As regards the 'internal 15-digit accuracy'. That only holds for single operations and dot products (that can be accumulated without extra storage). The numbers themselves are still stored in 12-digit format. The reason the 71B gets the determinant wrong, and the 28S gets it right is probably (guessing): the determinant of 2-by-2 matrices is calculated using the definition, in full 15-digit accuracy (28S). From the 48G onwards, a check for integer elements has been added - if all elements are integer, then so is the determinant, and the computed value is rounded off to the nearest integer. Also, the matrix is stored in full 15-digit form, reducing roundoff errors. BTW the determinant for the sample matrix you show is of course -2e-14.

Cheers, Werner

            
Re: Strange matrix results for HP-71B Math ROM
Message #4 Posted by Werner Huysegoms on 5 July 2004, 9:02 a.m.,
in response to message #3 by Werner Huysegoms

My guess does seem to be correct: If I try your original matrix on a 42S and a 48SX, they return the correct answer, but if I try the equivalent 3-by-3 matrix

1.0000000 0.0000000 0.0000000 0.0000000 1.0000001 1.0000002 0.0000000 1.0000003 1.0000004

Then the result is (in both cases) 1.0000003e-14, the result the 71B gave. And yes, the transpose's determinant is 2.0000004e-14. I'm pretty sure I can find out the exact order of 15-digit arithmetic operations and 12-digit rounded stores to come up with these answers. Valentin will probably post it in the next 2 minutes ;-)

Cheers, Werner

                  
Re: Strange matrix results for HP-71B Math ROM
Message #5 Posted by J-F Garnier on 5 July 2004, 12:10 p.m.,
in response to message #4 by Werner Huysegoms

Thanks Werner, I fill better: the HP-71B Math ROM is OK, just the HP28/HP48 added some filtering against the most visible rounding effects.

J-F


[ Return to Index | Top of Index ]

Go back to the main exhibit hall