Go Back > Great Internet Mersenne Prime Search > Software

Closed Thread
Thread Tools
Old 2005-02-10, 14:32   #1
Nov 2004

2·5 Posts
Default Is Mathematica really slow?


If[PrimeQ[p]==False,Print["The exponent must be prime"]];

Print["Iteration : 0 "," / ",iter];

If[Mod[counter,10^3]==0,Print["Iteration : ",counter," / ",iter]]

If[s==0,Print["is prime"],Print["is not prime"]]


'---- Test run -----'

Iteration : 0 / 11118
Iteration : 1000 / 11118
Iteration : 2000 / 11118
Iteration : 3000 / 11118
Iteration : 4000 / 11118
Iteration : 5000 / 11118
Iteration : 6000 / 11118
Iteration : 7000 / 11118
Iteration : 8000 / 11118
Iteration : 9000 / 11118
Iteration : 10000 / 11118
Iteration : 11000 / 11118

" is not prime"

{15.112 Second,Null}


I was experimenting with Mathematica v5.0 about the Lucas_Lehmer test.
As you can see above the code is extremely slow. It needs 15+ sec
to test the exponent where as Prime95 only takes about 0.5 sec.

Can someone explain why is this happening because as far as I am concerned Mathematica is believed to be one of the fastest numerical computing platforms.

Any help would be grateful.
wakko is offline  
Old 2005-02-10, 14:49   #2
Mystwalker's Avatar
Jul 2004
Potsdam, Germany

3×277 Posts

I remember that Louis Helm (one of the creators of SoB - which uses the same algorithmic implementation as Prime95) once said that an implementation in Java would be roughly 30 times slower.
I think the reason here is similar: The speed difference (incidently 30 times as well) supposely comes from the fact that Mathematica's routines are not hand-optimized for this exact purpose and architecture (does Mathematica use SSE2/FFTs/IBDWT?). In addition, I believe some "tricks" prime95 uses can only be applied due to special properties of mersenne numbers. Mathematica can't take that into account, I guess.

Last fiddled with by Mystwalker on 2005-02-10 at 14:52
Mystwalker is offline  
Old 2005-02-10, 20:51   #3
jinydu's Avatar
Dec 2003
Hopefully Near M48

6DE16 Posts

Mathematica is slow in other things too. It took Mathematica hours to compute just 25,000 digits of Zeta(3). Other programs can do it in a fraction of a second on the same computer.
jinydu is offline  
Old 2005-02-10, 23:16   #4
grandpascorpion's Avatar
Jan 2005

503 Posts

Is Maple faster in general?
grandpascorpion is offline  
Old 2005-02-11, 01:45   #5
Nov 2004

2×5 Posts

Thanks anyway for your replies.

I am trying to comprehent the deeper things apon LL, that experiment showed me a lot.

Mayber I'll try something hand-optimized..

CU later sievers
wakko is offline  
Old 2021-02-09, 16:46   #6
mattprim's Avatar
Feb 2021
Salt Lake City, UT

1D16 Posts
Default I excluded giant Mersenne with Mathematica

I managed to exclude a giant Mersennes with Mathematica Pity I later learned they were both known but with Monte Carlo it worked below a Ghz x Minute and they are both above the biggest 2021 Mersenne prime known.

Last fiddled with by mattprim on 2021-02-09 at 16:51
mattprim is offline  
Old 2021-02-09, 16:52   #7
VBCurtis's Avatar
Feb 2005
Riverside, CA

2·3·5·7·23 Posts

"excluded" = trial-factored. Trial-factoring is not at all related to a primality test, and comparing the speed of those two things is akin to someone asking what the 99th power of 99 is, and you answering "Well, I added 99 and 99 really fast!"
VBCurtis is online now  
Closed Thread

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
why is prime95 much faster than mathematica? bbb120 Software 19 2019-04-21 16:20
Long Division in Mathematica JuanTutors Information & Answers 7 2007-06-14 17:29
Mathematica 6 Released jinydu Lounge 0 2007-05-07 05:05
Mathematica question-solving systems Zeta-Flux Math 6 2005-09-22 21:47

All times are UTC. The time now is 15:14.

Tue Jun 15 15:14:47 UTC 2021 up 18 days, 13:02, 1 user, load averages: 1.49, 1.68, 1.72

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.