mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Programming (https://www.mersenneforum.org/forumdisplay.php?f=29)
-   -   Two small programs needed! (https://www.mersenneforum.org/showthread.php?t=5343)

robert44444uk 2006-01-13 09:34

Two small programs needed!
 
I am looking for someone (maybe you!) who can write one or both of the following two challenges, in a very fast code, and as a windows executable.

These refer to [url]http://groups.yahoo.com/group/primenumbers/message/17203[/url]

Below are my own pathetic efforts in Maple.

Exercise 1: As part of a search for the 1st instance prime gap k in the series 2kp+1. The following just pushes out all gaps in excess of k=150. Axn1 has written a progam which can processed all p between p=5 billion to p= 45 billion in a day. The Maple code below processed 2 billion a day.

restart:
outputfilename := "name.txt":
fdwrite := fopen(outputfilename, WRITE):
target:= 298:
cnt:=7172:
a:=31648223287:
for n from 1 to 10000000000 do
a:= nextprime(a):
for b from 2 to 2000 by 2 do
c:= a*b+1:
if isprime(c)=true then
break:
fi:
od:

if b>target then
cnt:=cnt+1:
print(cnt,a,c,b);
fprintf(fdwrite,"%a %a %a %a\n",cnt,a,c,b):

fi:
od:

fclose(fdwrite):

Exercise 2:

A sieve for primes of the form n^p-(n-1)^p, which only has factors of the form 2kp+1. Below uses p=19 as the example

restart:
with(numtheory):
amax:=20000:
k := array(1..amax):
upper:= 500000:
x:=19:
for n from 1 to upper do
e:= 2*n*x+1:
if isprime(e)=true then
b:= rootsunity(x,e):
for f from 2 to x do
a:= b[f]/(b[f]-1) mod e:
for y from a to amax by e do
k[y] := z:

od:
od:

fi:

od:

for m from 1 to amax do
if k[m] <> z then
print(m);
fi:
od:


Regards

Robert Smith

xilman 2006-01-13 17:05

[QUOTE=robert44444uk]I am looking for someone (maybe you!) who can write one or both of the following two challenges, in a very fast code, and as a windows executable.
Regards

Robert Smith[/QUOTE]Are you willing to pay my consultancy rates?


Paul

R.D. Silverman 2006-01-13 18:39

[QUOTE=xilman]Are you willing to pay my consultancy rates?


Paul[/QUOTE]

Or mine?

If the original poster had bothered to read some elementary number theory
books, before computing, he would have discovered the (simple!) reasons
behind his "discoveries". In particular, he should look up the prime number
theorem for arithmetic progressions. And the PNT itself. One should
*expect* numbers of the form n^p - (n-1)^p to be rarely prime.

What is it that compels people to start computing BEFORE doing some
background reading? After all, it is much easier to spend and waste
several weeks of writing code and computing than spend an hour in the
library......


I never understood this.....

R.D. Silverman 2006-01-13 20:09

[QUOTE=R.D. Silverman]Or mine?

If the original poster had bothered to read some elementary number theory
books, before computing, he would have discovered the (simple!) reasons
behind his "discoveries". In particular, he should look up the prime number
theorem for arithmetic progressions. And the PNT itself. One should
*expect* numbers of the form n^p - (n-1)^p to be rarely prime.

What is it that compels people to start computing BEFORE doing some
background reading? After all, it is much easier to spend and waste
several weeks of writing code and computing than spend an hour in the
library......


I never understood this.....[/QUOTE]


There is also an old saying in software engineering:

"The sooner you start writing your code, the longer it will take you
to finish the job".

Isn't this taught to students anymore????

Analyze the problem FIRST. Do the background reading FIRST. Code
LATER.

xilman 2006-01-13 20:55

[QUOTE=R.D. Silverman]
If the original poster had bothered to read some elementary number theory
books, before computing, he would have discovered the (simple!) reasons
behind his "discoveries". In particular, he should look up the prime number
theorem for arithmetic progressions. And the PNT itself. One should
*expect* numbers of the form n^p - (n-1)^p to be rarely prime.

What is it that compels people to start computing BEFORE doing some
background reading? After all, it is much easier to spend and waste
several weeks of writing code and computing than spend an hour in the
library......


I never understood this.....[/QUOTE]To be fair, there is nothing in the original posting which states that he has not researched the problem beforehand and is not already aware of the rarity of primes of that form.

He asks only for fast programs to sieve out candidates. He has prototyped them in Maple and wishes to commission faster versions. It is precisely because candidates are rare that he needs fast code.

Exactly the same could be said for code to find primes of other rare types, such as Mersenne primes or Wieferich primes.


Paul

R.D. Silverman 2006-01-13 22:10

[QUOTE=xilman]To be fair, there is nothing in the original posting which states that he has not researched the problem beforehand and is not already aware of the rarity of primes of that form.

Paul[/QUOTE]

Actually there is. Go to his URL. He expresses total surprise at the
scarceness of such primes.

robert44444uk 2006-01-13 23:28

Correct
 
Dr Paul

Sadly, my consultancy rate does not allow me any time for programming, but there again I do not have the mind set for efficient programming, so I won't give up the day job :)

Dr RD

You are right, these primes (if they are - all I do is prove to prp3 level) are quite rare. I am really interested to prove my point that some p values provide more prp-3 than others. Hence the need for a fast sieve. I have already posted over 120 prps to H. Lifchitz's site using my pathetic means, but concentrating on those p which are prp rich (in a poor world).

Regarding the 2kp+1 sieve - I love the thought that some polynomial series do not provide any factors below a certain level

For example the series k^36673176307-k^36673176306 from k =1 to infinity has no factors less than 22664022957727 is a the inevitable result of my endeavours to date. That may be abstruse but I have to tell you that no smaller p in k^p-k^(p-1) has larger smallest factors, and because of the work I have done, I can demonstrate it!!

Regards

Not a Dr. Smith

TTn 2006-01-14 04:48

[QUOTE]What is it that compels people to start computing BEFORE doing some
background reading? After all, it is much easier to spend and waste
several weeks of writing code and computing than spend an hour in the
library......[/QUOTE]As a general rule this makes sense.
The library/ies local to the individual may not always be the best source. You also have to know what to look for, to quickly find the information which may or may not exist.
Sounds like you do not know how hard it is for others, to obtain information, because it's so darn easy for you to do.
In this, you are not grounded in reality, because of your superior nature to us.

[QUOTE]I never understood this.....[/QUOTE]Well not so superior.:smile:

:surrender
Shane F.

xilman 2006-01-14 10:01

[QUOTE=R.D. Silverman]Actually there is. Go to his URL. He expresses total surprise at the scarceness of such primes.[/QUOTE]Ok, so I didn't check the references. I still believe that there is nothing in his posting [i]per se[/i] on the matter but, as you say, there is referenced information that supports your claim.

Paul

xilman 2006-01-14 10:10

[QUOTE=TTn]As a general rule this makes sense.
The library/ies local to the individual may not always be the best source. You also have to know what to look for, to quickly find the information which may or may not exist.
Sounds like you do not know how hard it is for others, to obtain information, because it's so darn easy for you to do. [/QUOTE]
To be fair, one of the prerequisites to be able to do research efficiently is to know how to find previously discovered knowlege in an efficient manner. Learning how to do literature searches is very important skill, in my opinion.

Literature searches are very much easier these days than they were when Bob and I began our careers. 25 years or so ago almost everything was printed and if you wanted a copy of a research paper you either went to a library and took notes or a photocopy, or contacted a fellow researcher (by post or phone) to request a preprint. These days, email, search engines and on-line archives make searching the literature very much easier.

There are those who would claim that we had it easy. In their day the photocopier hadn't been invented and the telephone was far from being universally available. Such people are slowly dying off but they certainly still exist.

Paul

TTn 2006-01-14 11:52

[QUOTE]To be fair, one of the prerequisites to be able to do research efficiently is to know how to find previously discovered knowlege in an efficient manner. Learning how to do literature searches is very important skill, in my opinion.[/QUOTE]Oh yes I agree, but where does one draw the line, and conclude that after hours of looking for this elusive widgetal math property that, they can safely say it's unknown?

These skills may come natural to some people, and taught to others.
However, both require little effort which is an important observation.
I sure wish that I was handed a first class education, by my parents.


All times are UTC. The time now is 08:01.

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