Page 1 of 2

Old HPMuseum HP-30b primality test on the 41x

Posted: Mon May 04, 2020 3:33 pm
by jonmoore
Reading an old HP-30b thread at HPMuseum this morning, I thought it would be interesting to benchmark the speed of the same 9,999,999,967 primality test on the 41x. As a comparative benchmark, the fastest routine on the 30b was 40 seconds.

The 41x came in at 14 seconds in Fast mode (with USB power) and 34 seconds, Fast Mode (no USB). The primality test routine was one originally authored by Jason DeLooze but subsequently converted to MCode by Ángel Martin for inclusion in SandMath.

Pretty impressive considering the the 41x is running as an emulation and the 30b is already recognised to by pretty zippy by most in the HP calc community. I didn't test in Slow mode, but as Bob said in his HHC announcement last year - if you're running long calculations, there are far better options out there than handheld calculators!

I'm sure that the WP43s will be able to better this score considerably (and the same can probably be said for the DM42) but the 41x seems to be reasonably performant, especially for an emulated solution; particularly when it's running well designed MCode routines such as those found in SandMath.

Re: Old HPMuseum HP-30b primality test on the 41x

Posted: Mon May 04, 2020 3:56 pm
by Walter
Just FYI, the WP43S' function PRIME? returns "true" for an input of 9 999 999 967 instantaneously (i.e. <<1s) on the target hardware.
Still far less than 1s for an input of 999 999 999 999 999 999 017.
For 999 999 999 999 999 999 999 999 999 999 999 999 943, it needs ~ 1s. 8-)

Re: Old HPMuseum HP-30b primality test on the 41x

Posted: Mon May 04, 2020 4:27 pm
by jonmoore
Walter wrote:
Mon May 04, 2020 3:56 pm
Just FYI, the WP43S' function PRIME? returns "true" for an input of 9 999 999 967 instantaneously (i.e. <<1s) on the target hardware.
Still far less than 1s for an input of 999 999 999 999 999 999 017.
For 999 999 999 999 999 999 999 999 999 999 999 999 943, it needs ~ 1s. 8-)
And that's why I'm keen for one of those beta units when they're available! :)

Re: Old HPMuseum HP-30b primality test on the 41x

Posted: Mon May 04, 2020 4:47 pm
by jonmoore
On a more serious note, the reason I purchased the 41x is the range of excellent Modules that have been produced in the 41CL era. The programs I write with those Modules don't require high precision or super performance (although my unfounded fear was that an emulated 41 solution on DM hardware would be sluggish).

My interest in the 43s is in particular driven by its precision and speed (and hopefully, the elegance of its 42+ programming language). The 42 stays in my armoury because of it's relative simplicity.

There's a definitive utility for each DM, and combined they'll take up less room in my backpack and weigh less than my 50g!

Re: Old HPMuseum HP-30b primality test on the 41x

Posted: Tue May 05, 2020 1:30 pm
by pauli
The 43S is using a completely different algorithm for its primality test. It's using Miller-Rabin. It is set up so that gives precise results up to a reasonably large number (3317044064679887385961981), beyond that it is only reporting probable primes.

Pauli

Re: Old HPMuseum HP-30b primality test on the 41x

Posted: Tue May 05, 2020 2:37 pm
by jonmoore
pauli wrote:
Tue May 05, 2020 1:30 pm
The 43S is using a completely different algorithm for its primality test. It's using Miller-Rabin. It is set up so that gives precise results up to a reasonably large number (3317044064679887385961981), beyond that it is only reporting probable primes.

Pauli
Thanks for the extra info Paul. I'm pretty sure the level of precision you're offering in the 43s is going to more than satisfy the needs of more than 99% of pocket scientific-calculator users.

The thing that I find most interesting in the 43s project is that much as you and Walter have worked to a design strategy based on decades of community involvement and feedback, the project still benefits from a definitive design DNA based on your own goals. By comparison, the 41 universe is a truly 'crowd-sourced' affair with all the positives and negatives of such projects. As an end user I'm very grateful that I will have access to both (as well as the DM42).

For me there's no such thing as an 'ultimate' pocket calculator 'to rule them all'; so having access to multiple DM devices that come in the same form factor is nothing but a good thing. Variety being the spice of life and all that jazz...

Re: Old HPMuseum HP-30b primality test on the 41x

Posted: Tue May 05, 2020 10:30 pm
by Mark Hardman
pauli wrote:
Tue May 05, 2020 1:30 pm
The 43S is using a completely different algorithm for its primality test. It's using Miller-Rabin. It is set up so that gives precise results up to a reasonably large number (3317044064679887385961981), beyond that it is only reporting probable primes.

Pauli
Does "probable" only include false positives or is there a possibility of false negatives as well? Can the 43s handle Belphegor's "satanic" prime?

1000000000000066600000000000001

* 1 followed by 13 zeros, the number of the beast followed by another 13 zeros and a final 1

Re: Old HPMuseum HP-30b primality test on the 41x

Posted: Tue May 05, 2020 10:43 pm
by Walter
Mark Hardman wrote:
Tue May 05, 2020 10:30 pm
pauli wrote:
Tue May 05, 2020 1:30 pm
The 43S is using a completely different algorithm for its primality test. It's using Miller-Rabin. It is set up so that gives precise results up to a reasonably large number (3317044064679887385961981), beyond that it is only reporting probable primes.
Does "probable" only include false positives or is there a possibility of false negatives as well? Can the 43s handle Belphegor's "satanic" prime?

1000000000000066600000000000001

* 1 followed by 13 zeros, the number of the beast followed by another 13 zeros and a final 1
1) This question goes to Pauli.
2) Yes, it can - the target hardware responds with "true" in <1s. BTW, the next prime ends with ...000 229.

Re: Old HPMuseum HP-30b primality test on the 41x

Posted: Tue May 05, 2020 10:50 pm
by jonmoore
:)

At 31 digits it would appear to be into the realm of the probable. But to be frank I'd be even more spooked if the 43s answers in the affirmative as to the identity of Belphegor's prime.

Re: Old HPMuseum HP-30b primality test on the 41x

Posted: Tue May 05, 2020 11:13 pm
by Walter
Please see here:
.
PRIME.png
PRIME.png (20.72 KiB) Viewed 746 times