20190302, 00:27  #1 
Feb 2019
China
3B_{16} Posts 
why is prime95 much faster than mathematica?
I test M86243=2^862431 with prime95 and mathematica ,
by using the same algorithm lucas lehmer algorithm , but prime95 is much much much fast than mathematica 11.3! prime 95 takes no more than 2 seconds, but mathematica took 49.8735 seconds, prime 95 is 25 times faster than mathematica ! it is much much much much faster than mathematica ! so I think there should be something wrong with prime 95， my mathematica code as follow Code:
LucasLehmer[n_]:=Module[{Mp,s,k},Mp=2^n1;s=4;Do[s=Mod[s^22,Mp],{k,1,n2}];If[s==0,Return[True],Return[False]]] Timing[LucasLehmer[86243]] 
20190302, 00:32  #2 
P90 years forever!
Aug 2002
Yeehaw, FL
2^{2}×1,873 Posts 

20190302, 00:34  #3 
Sep 2002
Database er0rr
111001011101_{2} Posts 
Prime95 uses George Woltman's wellcrafted FFT assembly subroutines to perform multiplication, a luxury not seen in Mathematica.
Last fiddled with by paulunderwood on 20190302 at 00:36 
20190302, 01:00  #4 
Feb 2019
China
73_{8} Posts 

20190302, 01:21  #5  
Sep 2016
514_{8} Posts 
Quote:
FFT differences aside, you're also using the Mod function  which is very slow. Prime95 doesn't need a mod function thanks to the aforementioned FFT wraparound. 

20190302, 01:33  #6  
"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest
3·5·7^{3} Posts 
Quote:
Mathematica is a general purpose application; prime95 is not. Prime95 was written by George Woltman for a narrow purpose (and refined with cpumodelspecific assembler tuned for performance over 23 years); Mathematica was not. Prime95 has found the last 17 Mersenne primes; Mathematica zero total. Prime95's accuracy has been validated by multiple other applications, including software used to make previous discoveries. https://en.wikipedia.org/wiki/Prime95 https://en.wikipedia.org/wiki/Wolfram_Mathematica 

20190302, 01:38  #7 
Einyen
Dec 2003
Denmark
3,137 Posts 
This is why GIMPS is so successful running for 23 years and finding 17 huge primes, because it is literally the fastest program there is, and it is running the fastest known primality testing algorithm, so we can find primes over 24 million digits.

20190302, 02:35  #9  
Feb 2005
Colorado
2×3×103 Posts 
Quote:
George's program uses every available register and every CPU extension in order to maximize throughput, in addition to making the most efficient use of the CPU's cache memory. When driven to extremes like that, not only does it use more power but it speeds things up about 25 times. Make sense? 

20190302, 03:43  #10  
"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest
3·5·7^{3} Posts 
Quote:
Prime95 works the cpu so hard, that on some computers, you can hear the iterations. (Variation in current draw and voltage fluctuation with the computation progress causes capacitors that are a little bit piezoelectric to act as speakers. There can also be other effects, such as circuit traces heating and induction, varying magnetic forces in coils in the power supply, etc.) It tests or exceeds the cooling design limits. The laptop I'm using now for this post requires considerable throttling of prime95 to avoid thermal shutdown with prime95. It's also well known as a stress testing program in the overclocking community, and has been employed as a test program by Intel. Last fiddled with by kriesel on 20190302 at 03:44 

20190302, 04:03  #11  
Feb 2019
China
59 Posts 
Quote:
Testing Mersenne Primes with Elliptic Curves https://link.springer.com/chapter/10.1007/11870814_27 

Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Is Mathematica really slow?  wakko  Software  6  20210209 16:52 
How to make Prime95 run faster without charger?  ChemicalCat59  Information & Answers  6  20170220 23:22 
Long Division in Mathematica  JuanTutors  Information & Answers  7  20070614 17:29 
Mathematica 6 Released  jinydu  Lounge  0  20070507 05:05 
Mathematica questionsolving systems  ZetaFlux  Math  6  20050922 21:47 