DM42 and accuracy

Discussion around the Swiss Micros DM42 calculator.
race_herens
Posts: 2
Joined: Thu May 21, 2020 9:02 pm

DM42 and accuracy

Post by race_herens » Sun Jun 07, 2020 11:09 pm

Hi,

I was playing with the calculator in parallel with python to test and enjoy its accuracy.
Computing 154^154, I get with iPython:
7554244008786559575879374904245441795033866870437465716418717350003149580116668117770406909654319320442010072703598802918492552989100733852103867467407663874552204474375211211930657345710855907754492776113727267222087200137903834965849330652115912127071191115726255782293402295495170668402583178024581141574042154569857487294527130566656

Free42 and DM42 give me:
7,554244008786559575879374904245436e336

The windows calculator with a similar engine:
7,5542440087865595758793749042454e+336

The last two digits given by free42 are wrong. Has anyone encountered similar issues?

Theo

grsbanks
Posts: 923
Joined: Tue Apr 25, 2017 9:23 am
Location: Preston, Lancs, UK
Contact:

Re: DM42 and accuracy

Post by grsbanks » Mon Jun 08, 2020 6:35 am

It looks like iPython is able to give arbitrary precision results.

The DM 42 is not.

Behind the scenes, it calculated e^(154 * ln(154)). It gave you an answer accurate to 32 digits having evaluated two transcendental functions. Most pocket calculators give you between 8 and 12 digits of accuracy.
There are only 10 kinds of people in the world: those who understand binary and those who do not.

EM41
Posts: 103
Joined: Sun Mar 29, 2020 10:10 pm
Location: Overijssel Netherlands

Re: DM42 and accuracy

Post by EM41 » Mon Jun 08, 2020 11:49 am

In python you can set the precision to any number of digits (up to 1000 I beleive.)

from mpmath import *
mp.dps=100
mp.prec=100
mpf(154**154)

Gives 100 digits precision and 100 decimal places, and it gives you an error in the last 2 digits comparable with the DM42.
As far as I know the DM42 works internally with 100 digits precision, never actually checked.
In normal life the DM42 is way beyond what I need but playing around is always fun.
The WP43S uses 1000 digits precision in case you need that.
HP41C, HP41CV, HP41CX, DM41X β, DM42, HP11C, HP48G, HP97

User avatar
Walter
Posts: 1540
Joined: Tue May 02, 2017 9:13 am
Location: Close to FRA, Germany

Re: DM42 and accuracy

Post by Walter » Mon Jun 08, 2020 12:02 pm

EM41 wrote:
Mon Jun 08, 2020 11:49 am
As far as I know the DM42 works internally with 100 digits precision, never actually checked.
In normal life the DM42 is way beyond what I need but playing around is always fun.
The WP43S uses 1000 digits precision in case you need that.
Hmmh ... in principle but the DM42 works with Free42 precision, i.e. 39 digits internally and up to 34 digits output. Same applies to the WP34S in double precision mode and to the WP43S in general but the latter uses 72 digits internally for solving quadratic equations, 75 digits for statistics, up to 1001 digits for integers, and even 1065 digits for 2π modulo reduction for trigonometric functions. Just FYI.
DM42 SN: 00041 Beta
WP 43S running on this device

HP-35, HP-45, ..., HP-50, WP 34S, WP 31S, DM16L

Thomas Okken
Posts: 700
Joined: Tue May 02, 2017 3:48 pm
Contact:

Re: DM42 and accuracy

Post by Thomas Okken » Mon Jun 08, 2020 12:25 pm

No, Free42 does not use higher precision internally. It's 34 digits throughout. The result of 154^154 is off by 5 in the final digit because there are no guard digits during the calculation, and the calculation involves multiple calls to the Intel library.

In the case at hand, the calculation behind the scenes is performed as a series of multiplications using repeated squaring; the result from calculating exp(154*ln(154)) would be even worse.

User avatar
Walter
Posts: 1540
Joined: Tue May 02, 2017 9:13 am
Location: Close to FRA, Germany

Re: DM42 and accuracy

Post by Walter » Mon Jun 08, 2020 12:38 pm

Thanks, Thomas, for correction of my statement about Free42. I've learned something new today.
DM42 SN: 00041 Beta
WP 43S running on this device

HP-35, HP-45, ..., HP-50, WP 34S, WP 31S, DM16L

grsbanks
Posts: 923
Joined: Tue Apr 25, 2017 9:23 am
Location: Preston, Lancs, UK
Contact:

Re: DM42 and accuracy

Post by grsbanks » Mon Jun 08, 2020 12:49 pm

Thomas Okken wrote:
Mon Jun 08, 2020 12:25 pm
In the case at hand, the calculation behind the scenes is performed as a series of multiplications using repeated squaring
Of course it is. I did know that but had completely forgotten for some reason! Thanks for the reminder.
There are only 10 kinds of people in the world: those who understand binary and those who do not.

race_herens
Posts: 2
Joined: Thu May 21, 2020 9:02 pm

Re: DM42 and accuracy

Post by race_herens » Mon Jun 08, 2020 9:14 pm

Thank you for the quick and detailed replies!
I was well aware that Python can work with arbitrary precision, I was just trying to check the accuracy of the calculator
So in the best of worlds the engine should ideally check the expected error and truncate the last erroneous digits accordingly. But making an error is expected if you have a finite precision and are making a succession of operations.
This makes sense :)

User avatar
pauli
Posts: 102
Joined: Tue May 02, 2017 8:11 am
Location: Australia

Re: DM42 and accuracy

Post by pauli » Tue Jun 09, 2020 12:36 pm

Free42 uses Intel's decimal library. The 34S doesn't. Intel's library is faster, larger and doesn't carry as many guard digits as the 34S.

Pauli

michel.lample
Posts: 15
Joined: Wed May 03, 2017 3:09 pm

Re: DM42 and accuracy

Post by michel.lample » Wed Jun 10, 2020 12:36 pm

Does the DM42 (Free42) still use the CORDIC algorithm for exponentiation calculations, as do many hp calculators?

Michel

Post Reply