DM42 and accuracy

Discussion around the SwissMicros DM42 calculator
race_herens
Posts: 2
Joined: Thu May 21, 2020 11:02 pm

DM42 and accuracy

Post by race_herens »

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: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: DM42 and accuracy

Post by grsbanks »

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: 192
Joined: Mon Mar 30, 2020 12:10 am
Location: Overijssel Netherlands

Re: DM42 and accuracy

Post by EM41 »

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 (2x), HP41CV, HP41CX, DM41X β, DM41X, DM42, HP11C, HP48G, HP97
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

Re: DM42 and accuracy

Post by Walter »

EM41 wrote:
Mon Jun 08, 2020 1:49 pm
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.
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
Thomas Okken
Posts: 1102
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: DM42 and accuracy

Post by Thomas Okken »

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: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

Re: DM42 and accuracy

Post by Walter »

Thanks, Thomas, for correction of my statement about Free42. I've learned something new today.
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: DM42 and accuracy

Post by grsbanks »

Thomas Okken wrote:
Mon Jun 08, 2020 2: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 11:02 pm

Re: DM42 and accuracy

Post by race_herens »

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: 252
Joined: Tue May 02, 2017 10:11 am
Location: Australia

Re: DM42 and accuracy

Post by pauli »

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: 20
Joined: Wed May 03, 2017 5:09 pm

Re: DM42 and accuracy

Post by michel.lample »

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

Michel
Post Reply