mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

CRGreathouse 2010-08-16 21:52

[QUOTE=science_man_88;225738]do you have a search function on your OS if so maybe search "mseive + GGNFS"[/QUOTE]

I think he's on Windows, so he could use Start -> Run -> cmd and type "dir/s c:\ggnfs*" and see what comes up.

science_man_88 2010-08-16 21:58

[QUOTE=CRGreathouse;225744]I think he's on Windows, so he could use Start -> Run -> cmd and type "dir/s c:\ggnfs*" and see what comes up.[/QUOTE]

windows 7 it's just start-> search box->type something related to what you want to find.

CRGreathouse 2010-08-16 22:00

[QUOTE=science_man_88;225745]windows 7 it's just start-> search box->type something related to what you want to find.[/QUOTE]

Yes, but my search is faster. :smile:

3.14159 2010-08-16 23:11

[QUOTE=CRGreathouse]I think he's on Windows, so he could use Start -> Run -> cmd and type "dir/s c:\ggnfs*" and see what comes up.
[/QUOTE]

Testing that out.

[QUOTE=science_man_88]windows 7 it's just start-> search box->type something related to what you want to find.
[/QUOTE]

Screw Win7.

[QUOTE=CRGreathouse]Yes, but my search is faster.
[/QUOTE]

Start -> Activate Virus Which Eats Your Hard Drive Rendering It Useless->Buy a new comp-> Do not repeat.

3.14159 2010-08-16 23:23

The GGNFS is there, but the msieve is not present anywhere on the comp. I guess that was also lost with the 100 GB I suddenly lost.

CRGreathouse 2010-08-16 23:26

[QUOTE=3.14159;225767]The GGNFS is there, but the msieve is not present anywhere on the comp. I guess that was also lost with the 100 GB I suddenly lost.[/QUOTE]

How'd you lose 100 GB?

Msieve is easy enough to replace, but that's only 0.002% of the 100 GB...

3.14159 2010-08-16 23:32

[QUOTE=CRGreathouse]How'd you lose 100 GB?
[/QUOTE]

I honestly have no idea. I had ≈510 GB free, then it suddenly jumped to ≈610 GB.

[QUOTE=CRGreathouse]Msieve is easy enough to replace, but that's only 0.002% of the 100 GB...
[/QUOTE]

True enough, but it was apparently still with the 100 GB I lost.

I'm guessing there must have been 100 GB in Temp files, although it also invaded the documents and erased everything I had there as well.

Something fishy must be going on in there...

science_man_88 2010-08-16 23:34

[QUOTE=3.14159;225771]I honestly have no idea. I had ≈510 GB free, then it suddenly jumped to ≈610 GB.



True enough, but it was apparently still with the 100 GB I lost.

I'm guessing there must have been 100 GB in Temp files, although it also invaded the documents and erased everything I had there as well.

Something fishy must be going on in there...[/QUOTE]


system restore ? this might get it back.

lucky me I have no restore points but I have almost nothing on my main computer drive(under 40 GB) lol

think I might need to clean temp files etc lol over 90 Mb in temp files lol.

3.14159 2010-08-16 23:38

By the way, the c120 I wanted to factor was this:

188405320006744640631171242764576430273162030735049010737242714302730318376659846379082799459410172978103582720000000001

CRGreathouse 2010-08-16 23:54

[QUOTE=3.14159;225771]I honestly have no idea. I had ≈510 GB free, then it suddenly jumped to ≈610 GB. [/QUOTE]

Oh, so you don't know that you lost anything. I could imagine that being temp files, though that's a bit on the large side.

science_man_88 2010-08-16 23:58

I'm doing a virus scan I found files i don't remember and I'd only save 3 Gb or so deleting all my downloads etc. in libraries.

CRGreathouse 2010-08-16 23:59

[QUOTE=3.14159;225771]I'm guessing there must have been 100 GB in Temp files, although it also invaded the documents and erased everything I had there as well.[/QUOTE]

Do you know what "it" is?

3.14159 2010-08-17 00:41

[QUOTE=CRGreathouse]Do you know what "it" is?
[/QUOTE]

To be honest, I have no idea.

3.14159 2010-08-17 00:44

Alright. To get back to the amateur siever. It's going to be a long and complicated script, and I'm afraid my current known commands aren't going to cut it.

CRGreathouse 2010-08-17 00:52

[QUOTE=3.14159;225785]Alright. To get back to the amateur siever. It's going to be a long and complicated script, and I'm afraid my current known commands aren't going to cut it.[/QUOTE]

It should be about 6 lines long.

Maybe later we can work on it. Right now I'm doing other stuff, and I'm sure you're pretty well fried.

3.14159 2010-08-17 01:15

[QUOTE=CRGreathouse]It should be about 6 lines long.

Maybe later we can work on it. Right now I'm doing other stuff, and I'm sure you're pretty well fried.[/QUOTE]

Alright. Notify whenever ready.

Also: I unwittingly discovered this: 254164423 * 3700! + 1 is prime (11607 digits)

CRGreathouse 2010-08-17 01:35

[QUOTE=3.14159;225792]Alright. Notify whenever ready.[/QUOTE]

SWEET, I finished the Gerbicz primorial function. Now if I can just get this :censored: sieve code to work, I'll be good to go... it's only 200 lines long, why does it cause me such trouble?

Radishes, radishes, radishes.

3.14159 2010-08-17 01:45

[QUOTE=CRGreathouse]SWEET, I finished the Gerbicz primorial function. Now if I can just get this :censored: sieve code to work, I'll be good to go... it's only 200 lines long, why does it cause me such trouble?
[/QUOTE]

Ah, another day in the life of the average programmer.. :missingteeth:

An 11607-digit k * n! + 1 happens to be a personal record for primes of that type.

CRGreathouse 2010-08-17 02:40

OK, so funny story.

This project has two main parts: the sieve, which factors numbers into a specialized form, and the end function, which takes 256 bits of sieve data plus the number and determines what value it has (possibly stopping early if it can tell it won't be good enough). I had been over the end function pretty closely, checking it against 'known-good' code, so I was pretty sure the problem was with the sieve. I was having trouble figuring out just where... memory corruption? Bad interactions between the three types of primes it deals with? Etc.

So what was the problem? A tiny (~4 character) section of a line of code checking whether the value was a record or not.

So the first unoptimized version is now running. It's 20 times faster than the compiled script (to 1e8), which is slightly faster than the original script. Now I just need to clean up the code, remove all the testing apparatus, and start optimizing. As written, it will get faster and faster compared to the original code as it goes to higher ranges, but I think I can get another 20% improvement by removing multiples of small squares... it's not hard to prove that, beyond 49, all members of my sequence are squarefree.

3.14159 2010-08-17 03:08

So, Charles: Is work on the sieve I want to construct beginning? I think I can do the forstep loops.

axn 2010-08-17 03:46

[QUOTE=3.14159;225805]So, Charles: Is work on the sieve I want to construct beginning? I think I can do the forstep loops.[/QUOTE]

Do you know how to write pseudocode? Try writing the logic in a language-independent way. Best way to learn programming is by doing it.

3.14159 2010-08-17 13:06

[QUOTE=axn]Do you know how to write pseudocode? Try writing the logic in a language-independent way. Best way to learn programming is by doing it.
[/QUOTE]

Depends on language. I can definitely perform:
"print(x)"

3.14159 2010-08-17 15:14

For the search for k * 4900! + 1; I set it to trial division only: I set it to between 4900 and 10[sup]6[/sup]. I'll only test the numbers that have no factors below 10[sup]6[/sup].
(There are about 20k-30k candidates.)
I figured it would become too slow if I decided to do some deep TF. (I tested it at around the 50M range for the pmax.)

[QUOTE=CRGreathouse]So what was the problem? A tiny (~4 character) section of a line of code checking whether the value was a record or not.
[/QUOTE]

:missingteeth: Need to proofread more often, there.

3.14159 2010-08-17 15:43

Idea:
 
I defined the function em2 to return b-values that are divisible by a user-specified number.

I thought of a new function that gets rid of the b-values divisible by any prime in a range of primes. simply save these to a file, remove every duplicate, remove the b-values from the range that happen to be divisible by p, and test the remainder. It's already defined.

To make it somewhat better: I'm going to need a further command that prints the numbers that are [B]not[/B] in the set of em2 for any of the primes specified. The primelimit is set to 2147483648, so it's going to be somewhat useful.
Excellent idea, amirite?

3.14159 2010-08-17 15:51

The code snippet I scribbled on paper for the next command:

nonmem(a,x,m,b) = {
for(n=a,x,
if(n=!mem(a,x,m,b), print(n))
);
}

(Please tell whether or not there are any errors there.)

For mem:
mem(a,x,m,b) = {
forprime(p=a,x,
print(em2(p,m!,b))
);
}

(Where b = 10[sup]b[/sup]).

CRGreathouse 2010-08-17 15:56

[QUOTE=3.14159;225844]Need to proofread more often, there.[/QUOTE]

I'm sure I scanned that portion of the code at least two or three times, but it wasn't clear that there was anything wrong. (The other parts where I thought the problem was I looked at a dozen times at least... although that did help me optimize those parts.)

In any case that project is running now. It's about 100 times faster than my old version at these sizes, and should be about 1000 times faster as the numbers grow large. I'm still actively looking to optimize the program -- I'm hoping for at least a 20% improvement, maybe a 50% improvement if I missed something big. But compared to the improvements I already have that's peanuts.

3.14159 2010-08-17 15:58

[QUOTE=CRGreathouse]I'm sure I scanned that portion of the code at least two or three times, but it wasn't clear that there was anything wrong. (The other parts where I thought the problem was I looked at a dozen times at least... although that did help me optimize those parts.)
[/QUOTE]

Mistakes can sometimes be right under your nose, and you probably won't notice them until the most random of times.

[QUOTE=CRGreathouse]In any case that project is running now. It's about 100 times faster than my old version at these sizes, and should be about 1000 times faster as the numbers grow large. I'm still actively looking to optimize the program -- I'm hoping for at least a 20% improvement, maybe a 50% improvement if I missed something big. But compared to the improvements I already have that's peanuts.
[/QUOTE]

10000% improvement? Excellent.

CRGreathouse 2010-08-17 16:00

[QUOTE=3.14159;225849]I defined the function em2 to return b-values that are divisible by a user-specified number.

I thought of a new function that gets rid of the b-values divisible by any prime in a range of primes. simply save these to a file, remove every duplicate, remove the b-values from the range that happen to be divisible by p, and test the remainder. It's already defined.

To make it somewhat better: I'm going to need a further command that prints the numbers that are [B]not[/B] in the set of em2 for any of the primes specified. The primelimit is set to 2147483648, so it's going to be somewhat useful.[/QUOTE]

Just make a vector with a member for every number in the range you're considering, and set the value to 314159 if you find a prime that divides the number. Then take all the values that aren't 314159 and test them to see if they're prime.

CRGreathouse 2010-08-17 16:01

[QUOTE=3.14159;225853]10000% improvement? Excellent.[/QUOTE]

Yes, I did more work last night than in the month of calculation I put in earlier.

3.14159 2010-08-17 16:03

[QUOTE=CRGreathouse]Just make a vector with a member for every number in the range you're considering, and set the value to 314159 if you find a prime that divides the number. Then take all the values that aren't 314159 and test them to see if they're prime.
[/QUOTE]

A vector with the smallest k * n! + 1 that's divided by p, for a range of p?

Also: Anything regarding the code snippets I thought up a few minutes ago?

CRGreathouse 2010-08-17 16:10

[QUOTE=3.14159;225856]A vector with the smallest k * n! + 1 that's divided by p, for a range of p?[/QUOTE]

A vector v where v[1] represents k = 1, v[2] represents k = 2, etc. Mark off entries when you know they're bad, and test only the unmarked entries.

[QUOTE=3.14159;225856]Also: Anything regarding the code snippets I thought up a few minutes ago?[/QUOTE]

I don't know exactly how em2 works so I can't say much. But try my idea, it works much better. :razz: Printing is bad, don't do it if you can avoid it.

3.14159 2010-08-17 16:13

[QUOTE=CRGreathouse]I don't know exactly how em2 works so I can't say much. But try my idea, it works much better. Printing is bad, don't do it if you can avoid it.
[/QUOTE]

em2 removes all the k-values divisible by a user-specified number.

3.14159 2010-08-17 16:16

[QUOTE=CRGreathouse]A vector v where v[1] represents k = 1, v[2] represents k = 2, etc. Mark off entries when you know they're bad, and test only the unmarked entries.
[/QUOTE]

A vector of the integers?

CRGreathouse 2010-08-17 16:19

[QUOTE=3.14159;225858]em2 removes all the k-values divisible by a user-specified number.[/QUOTE]

I read that in your post. It doesn't tell me enough that I can comment on code using it.

[QUOTE=3.14159;225859]A vector of the integers?[/QUOTE]

Not really important here. The best of all the easy solutions in Pari is to use a VECSMALL, which is created by vectorsmall just like a VEC is created by vector.

3.14159 2010-08-17 16:37

In the long run, my idea fails, because nonmem fails to work as directed. I think I'm going to have to revert back to the TF switch on PFGW.

Last idea:
if(n=!p*a + lift(Mod(-1,p)/(m!)), print(n)))

3.14159 2010-08-17 16:55

Well, it works, but only for individual divisors. If I add more than one prime, it loops/repeats. I need to edit it to include the and condition a few hundred times.

CRGreathouse 2010-08-17 16:56

[QUOTE=3.14159;225863]In the long run, my idea fails, because nonmem fails to work as directed. I think I'm going to have to revert back to the TF switch on PFGW.[/QUOTE]

As you will. For my recent (ongoing, unfortunately) project I found a huge speedup with sieving vs. trial division: I could remove more composites (higher bounds) in less time with sieving. Actually I found it worthwhile to spend a good fraction of my time sieving because of the amount of effort saved by avoiding primality tests.

CRGreathouse 2010-08-17 16:59

[QUOTE=3.14159;225867]Well, it works, but only for individual divisors. If I add more than one prime, it loops/repeats. I need to edit it to include the and condition a few hundred times.[/QUOTE]

You need to store the results in a vector rather than printing, since your lists will get large. For my small project I had 2 million candidates and 100 million primes; yours may not be as small. (I hoped to finish this yesterday so as to free up cycles for my new project that I've talked about, but no such luck.)

3.14159 2010-08-17 17:03

[QUOTE=CRGreathouse]You need to store the results in a vector rather than printing, since your lists will get large. For my small project I had 2 million candidates and 100 million primes; yours may not be as small. (I hoped to finish this yesterday so as to free up cycles for my new project that I've talked about, but no such luck.)
[/QUOTE]

Vectors? They can only store returns. That would mean I would be forced to sift through the file for every single prime, counting by p to remove a number every p numbers skipped. Dreadfully inefficient, at best.

Ex: Sieving out 509 for k * 360! + 1:
Liftmod(509, 360!) = 474.

Suppose the k-value range is n between 1 and 60k. That would be 117 values removed. Manual removal of values is dreadfully inefficient.

CRGreathouse 2010-08-17 17:07

[QUOTE=3.14159;225873]Vectors? They can only store returns. That would mean I would be forced to sift through the file for every single prime, counting by p to remove a number every p numbers skipped. Dreadfully inefficient, at best.[/QUOTE]

I'm not sure exactly what you mean by "they can only store returns", but I'm pretty sure it's wrong.

There's no need to use an intermediate file, I don't know why you'd suggest that. You keep one vector that starts out all 0s, you sieve, and at the end of the process each remaining 0 corresponds to a candidate which is not divisible by any of the primes you sieved out.

3.14159 2010-08-17 17:09

[QUOTE=CRGreathouse]I'm not sure exactly what you mean by "they can only store returns", but I'm pretty sure it's wrong.
[/QUOTE]

You can't make a vector out of print values (Well, the vector formed is 0, but you get the idea.). The vector is made of return values. I would have to store it in a file, and manually remove all the bad k-values.

CRGreathouse 2010-08-17 17:13

[QUOTE=3.14159;225875]You can't make a vector out of print values (Well, the vector formed is 0, but you get the idea.). The vector is made of return values. I would have to store it in a file, and manually remove all the bad k-values.[/QUOTE]

You can store strings (this is my best guess as to what you mean by "print values") in vectors if you like. But there's no need to do that -- you just need a 0 or a 1 in each entry.

And there's absolutely no reason to store the vector in a file (though Pari could certainly do that).

I still don't know what you mean by return values, or why you think printing has anything to do with any of this.

3.14159 2010-08-17 17:30

[QUOTE=CRGreathouse]You can store strings (this is my best guess as to what you mean by "print values") in vectors if you like. But there's no need to do that -- you just need a 0 or a 1 in each entry.
[/QUOTE]

By that, I was referencing a list of printed b-values. A vector can't be formed of them.

CRGreathouse 2010-08-17 17:59

[QUOTE=3.14159;225878]By that, I was referencing a list of printed b-values. A vector can't be formed of them.[/QUOTE]

OK... so why print them in the first place? Replace print(foo" is bad") with v[foo] = "bad", or v[foo] = 1, or whatever you like.

3.14159 2010-08-17 18:16

[QUOTE=CRGreathouse]OK... so why print them in the first place? Replace print(foo" is bad") with v[foo] = "bad", or v[foo] = 1, or whatever you like.
[/QUOTE]

It is unclear what you mean here.

em2 can't be made a vector.

I think there's simply no way to do it using vectors.

CRGreathouse 2010-08-17 18:18

Your statements are , likewise, unclear to me. (Why are you trying to make em2 a vector?!?) But I know that it can be done since I do this all the time.

3.14159 2010-08-17 18:18

Vectors are inefficient and unnecessary here. em2 and mem were decent advances. em2 and mem were, as I see it, the most progress I ever made.

3.14159 2010-08-17 18:22

[QUOTE=CRGreathouse]Your statements are , likewise, unclear to me. (Why are you trying to make em2 a vector?!?) But I know that it can be done since I do this all the time.
[/QUOTE]

Nevermind that. I'm going to go in the direction I was going in using em2 and mem.

mem needs some fixing in order to avoid the loop repeat: em2 is 100% functional.

CRGreathouse 2010-08-17 18:30

Well, post your functions and maybe we can compare.

kar_bon 2010-08-17 18:34

Not so hard to understand:

You searching for say k*360! + 1,

so set
v[1]=1 (k=1)
v[2]=2 (k=2)
v[3]=3 (k=3)
...
v[n]=n (k=n)

for all k-values you want to search for.

If you find a primefactor of say 123*360!+1, set v[123]=0.

Do this for all primefactors you will test: set the vector[index]=0.

After you've sieved all primefactors, the vector v contains some/many values set to 0, so these indices have a small factor and you do not need to test them.

You can "print" all indices n, where v[n] != 0, -> no primefactor found after sieving -> list of all k-values to test!

CRGreathouse 2010-08-17 18:43

Yes. Though I would set them all to 1 rather than to their own values -- you know that from their location. Of course ideally you'd use just one bit per number rather than a whole word, but for convenience in Pari I usually don't bother.

kar_bon 2010-08-17 18:49

[QUOTE=CRGreathouse;225900]Yes. Though I would set them all to 1 rather than to their own values -- you know that from their location. Of course ideally you'd use just one bit per number rather than a whole word, but for convenience in Pari I usually don't bother.[/QUOTE]

Yes, that's only necessary but to show the relation of factor and index...

And further:

There's no need to divide every candidate by that small factor:

Find the first occurence and the step-width (like in the example from yesterday) and it's a simple for-loop to strike out all candidates with that small factor!

3.14159 2010-08-17 18:50

[QUOTE=Karsten]v[1]=1 (k=1)
v[2]=2 (k=2)
v[3]=3 (k=3)
...
v[n]=n (k=n)[/QUOTE]

v[n] returns : "not a vector", for any n used.

[QUOTE=Charles]Well, post your functions and maybe we can compare.
[/QUOTE]

Look at the code snippets I posted earlier on.

3.14159 2010-08-17 18:54

[QUOTE=Karsten]Find the first occurence and the step-width (like in the example from yesterday) and it's a simple for-loop to strike out all candidates with that small factor!
[/QUOTE]

Fair enough.

Interesting coincidence: 353, 360, and 367 are all 7 units apart.

353 * 360! + 1 is divisible by 367.

CRGreathouse 2010-08-17 19:06

[QUOTE=3.14159;225903]v[n] returns : "not a vector", for any n used.[/QUOTE]

Yeah, I told you half a dozen times how to handle that, including a commentary of the effectiveness of different versions.

[code]v=vector(number_of_k_values_to_test)[/code]

[QUOTE=3.14159;225903]Look at the code snippets I posted earlier on.[/QUOTE]

I have twice asked for the omitted portion, without which I cannot duplicate or even follow your code.

3.14159 2010-08-17 19:09

[QUOTE=CRGreathouse]I have twice asked for the omitted portion, without which I cannot duplicate or even follow your code.
[/QUOTE]

What omitted portion? em2 and mem have nothing missing!

If you're referring to em2:

em2(x,n,a)=forstep(b=lift(Mod(-1,x)/n),10^a,x, print(b))

[QUOTE=CRGreathouse]Yeah, I only told you half a dozen times how to handle that, including a commentary of the effectiveness of different versions.
[/QUOTE]

6? O rly?

CRGreathouse 2010-08-17 19:17

[QUOTE=3.14159;225908]6? O rly?[/QUOTE]

I don't care to go through the thread to count the number of times, but my best off-the-top-of-my-head guess would be 7 or 8. But 6 seemed a safer bet.

CRGreathouse 2010-08-17 19:32

[code]em2(x,n,a)={
forstep(b=lift(Mod(-1,x)/n),10^a,x, print(b))
};

nonmem(a,x,m,b)={
for(n=a,x,
if(n=!mem(a,x,m,b), print(n))
)
};

mem(a,x,m,b) = {
forprime(p=a,x,
print(em2(p,m!,b))
);
};[/code]

So given some x, n, and a, em2 prints a bunch of stuff to the screen and returns nothing. mem then takes this nothing, converts it to a 0, and prints it to the screen. This process repeats once for every prime in [a, x] -- the a and x passed to mem, that is, not those passed to em2. After this loop, mem returns nothing.

nonmem computes this nothing, with no changes, x - a + 1 times, each time checking if n is equal to the nothing, converted to a zero and negated. So all n except for 1 (if it is in the range) are printed.

So calling nonmem causes mem to be called x - a + 1 times, each time calling em2 [TEX]\pi(x)-\pi(a-1)[/TEX] times (total [TEX](x-a+1)(\pi(x)-\pi(a-1))[/TEX] times), which results in em2's inner print statement being called about [TEX]p/10^b[/TEX] times (total very roughly
[TEX]\frac{(x-a+1)(a-x)(\pi(x)-\pi(a-1))^2}{2\cdot10^b}[/TEX]
times).

In short: calling nonmem causes a whole lot of numbers to whiz by on the screen, most of them the same as earlier numbers, mostly because the same calculation is being done that was already done before.

As far as "does it do what it's supposed to do?", I would guess not -- but it's hard to say for sure.

3.14159 2010-08-18 03:40

[QUOTE=CRGreathouse]In short: calling nonmem causes a whole lot of numbers to whiz by on the screen, most of them the same as earlier numbers, mostly because the same calculation is being done that was already done before.

As far as "does it do what it's supposed to do?", I would guess not -- but it's hard to say for sure.[/QUOTE]

Correct. It failed to function properly. As for the latter, em2 does what it is supposed to do.

CRGreathouse 2010-08-18 05:10

If em2 is doing what it's supposed to, then mem is clearly wrong -- it shouldn't expect a return value from a function that doesn't return anything.

3.14159 2010-08-18 13:45

[QUOTE=CRGreathouse]If em2 is doing what it's supposed to, then mem is clearly wrong -- it shouldn't expect a return value from a function that doesn't return anything.
[/QUOTE]

Well, I did say mem needs some fixing.

3.14159 2010-08-18 21:32

Hey: I should get back to the sieve project for the arithmetic progression prime searches. The trial division switch for PFGW just doesn't cut it.

3.14159 2010-08-18 21:34

The most recent idea is to fix mem. I will begin with Liftmodm1, which basically gives lift(Mod(-1,x)/(n)), for any x and any n. Liftmodm1 should be incorporated into mem instead of em2.

Scratch that. Liftmod has too few arguments. I'll pin a return on em2.

3.14159 2010-08-18 21:40

Now that I have pinned a return value instead of printing, I'll see what I can do for mem.

3.14159 2010-08-18 21:42

mem repeatedly loops, and this must be resolved. That means, I'll apply the (and) condition as necessary, so there is no loop. Let's see how this works out.

3.14159 2010-08-18 21:43

Let's try: k * 11! + 1; Apply the and condition for primes 13 through 349..

Scratched: This would also loop and repeat duplicates endlessly.

3.14159 2010-08-18 21:49

Okay: It cannot use vectors and loops, as any method using these is dreadfully inefficient.

The closest to a sieve I can manage is trial-dividing each to 10[sup]6[/sup] and testing those which have no factors below 10[sup]6[/sup].

3814 * p(65)#[sup]40[/sup] + 1 is prime. (≈5115-5117 digits)

3.14159 2010-08-18 23:01

Longest streak of trial-division-detected candidates ever seen by me:
[code]9584 * p(65)#^40 + 1 has factors: 30869
9585 * p(65)#^40 + 1 has factors: 26237
9586 * p(65)#^40 + 1 has factors: 12959
9587 * p(65)#^40 + 1 has factors: 1831
9588 * p(65)#^40 + 1 has factors: 123853
9589 * p(65)#^40 + 1 has factors: 1511
9590 * p(65)#^40 + 1 has factors: 6701
9591 * p(65)#^40 + 1 has factors: 4723
9592 * p(65)#^40 + 1 has factors: 99103
9593 * p(65)#^40 + 1 has factors: 9091
9594 * p(65)#^40 + 1 has factors: 2207[/code]

CRGreathouse 2010-08-19 01:25

Sorry, I've been sick... not quite up to my usual posting routine.

[QUOTE=3.14159;226068]Okay: It cannot use vectors and loops, as any method using these is dreadfully inefficient.[/QUOTE]

Sieving (with vectors) = fast, trial division = slow.

3.14159 2010-08-19 04:21

[QUOTE=CRGreathouse]Sieving (with vectors) = fast, trial division = slow.
[/QUOTE]

Okay: I need a decent script for that; This is well outside of my range.

I'm unsure I could complete it on my own.

CRGreathouse 2010-08-19 04:36

I'll post my recent sieve; maybe you can modify it. It was the work of just a few minutes; I'm sure it could be made much more efficient.

Your sieve is variable-k which is easier to program (but you'll have to make the changes).
[code]\\ Finding terms for A176494
sieve(lim,sz,sm=1)={
my(v=vectorsmall(sz,i,1));
forprime(p=3,lim,
b=znorder(Mod(2,p));
trap(,next,
a=znlog(2293,Mod(2,p),b)
);
if(Mod(2,p)^a!=2293, print("bad at "p);next);
a+=b*ceil((sm-a)/b);
forstep(n=a,sz,b,
v[n]=0
)
);
a=0;
for(i=sm,sz,if(v[i],a++;write("abc.txt", i)));
a
};[/code]

Replace the a=0 and following lines by v (just that one character) if you want to get the vector instead of writing it to a file. This checks for terms with n = sm to n = sz, sieving out the primes up to lim.


Ugh, still sick.

3.14159 2010-08-19 13:07

The only ideas I have for code are the beginning, and the end:

I require 5 arguments, not three.

(k value range; n; and primes to sieve range.)

The sieve needs to be generalized towards any arithmetic progression, I guess.

Also: The code doesn't work (Syntax error.)

Well, I'll be off to try and make the appropriate changes.

3.14159 2010-08-19 13:54

Blah.. This yields no progress. I'll just give up. Endless failed ideas, with many more soon-to-be failed ideas in mind.

Well, I forfeit.

3.14159 2010-08-19 13:57

Now, back to searching for general arithmetic progression primes. The odds will land me something.

(P.S: Found 5358 * 905011[sup]470[/sup] + 1 (≈ 53[sup]2[/sup] digits))

Looking for k * p(125)#^66 + 1 (≈ 19100 digits)

CRGreathouse 2010-08-19 14:12

[QUOTE=3.14159;226139]Also: The code doesn't work (Syntax error.)[/QUOTE]

That's interesting. My version says
[code]znlog(x,g,{o}): return the discrete logarithm of x in (Z/nZ)* in base g. If
present, o represents the multiplicative order of g. If no o is given, assume
that g generate (Z/nZ)*.[/code]
but I see that my Windows version says
[code]znlog(x,g): g as output by znprimroot (modulo a prime). Return smallest
non-negative n such that g^n = x.[/code]
so I guess you'll just have to drop that trailing ,b.

3.14159 2010-08-19 14:14

The odds of finding something:

Normally: 1 in about 44000.

Potential prime factors eliminated: first 125 primes:
Leaving it at about 1 in 3750. (w/no sieving)

CRGreathouse 2010-08-19 14:15

[QUOTE=3.14159;226139]The only ideas I have for code are the beginning, and the end:

I require 5 arguments, not three.

(k value range; n; and primes to sieve range.)[/QUOTE]

Four -- the code should probably just start at 2 or 3 for the prime range. All you need to add in terms of arguments is the n.

[QUOTE=3.14159;226139]The sieve needs to be generalized towards any arithmetic progression, I guess.[/QUOTE]

Changed, not generalized, from variable-n to variable-k.

science_man_88 2010-08-19 14:20

CRG if you're sick take a rest or Questions will make you worse.

CRGreathouse 2010-08-19 14:22

[QUOTE=3.14159;226148]The odds of finding something:

Normally: 1 in about 44000.

Potential prime factors eliminated: first 125 primes:
Leaving it at about 1 in 3750. (w/no sieving)[/QUOTE]

Yes, the only savings of sieving is that it's faster than trial division, so you can either spend the same amount of time and reduce the number of candidates (by removing the first million primes, say) or you can remove just as many, but faster.

Trial division by 125 primes costs 125 modular divisions, at a cost of maybe 1000 cycles each. For a list of N candidates, this costs 1000N cycles in total. With sieving, the first is just as slow as trial division, maybe slightly slower, but the rest cost almost nothing (about 3 cycles in this case), for a total cost of about 1000 + 3N cycles.

CRGreathouse 2010-08-19 14:23

[QUOTE=science_man_88;226151]CRG if you're sick take a rest or Questions will make you worse.[/QUOTE]

Thanks for your concern. :smile:

I'm not entirely better, but I'm almost there. Yesterday I had to take the day off work (well, half the day at least) I was so bad. :yucky:

3.14159 2010-08-19 14:24

[QUOTE=CRGreathouse]Four -- the code should probably just start at 2 or 3 for the prime range. All you need to add in terms of arguments is the n.
[/QUOTE]

The next time around: Please, don't make a sieve script that depends on me holding the "cancel" button to work efficiently.

CRGreathouse 2010-08-19 14:33

[QUOTE=3.14159;226154]The next time around: Please, don't make a sieve script that depends on me holding the "cancel" button to work efficiently.[/QUOTE]

I don't know what this means.

3.14159 2010-08-19 14:36

[QUOTE=CRGreathouse]I don't know what this means.[/QUOTE]

When I leave it be, it works rather slowly; When I hold the cancel command, or the copy command (Ctrl + C) it works like a charm.

CRGreathouse 2010-08-19 14:41

If you break (Ctrl+C) then it stops immediately, not finishing the computation. It's useful if you run a program with the settings too high -- you can stop it, change the settings lower, and re-run.

3.14159 2010-08-19 14:51

[QUOTE=CRGreathouse]If you break (Ctrl+C) then it stops immediately, not finishing the computation. It's useful if you run a program with the settings too high -- you can stop it, change the settings lower, and re-run.
[/QUOTE]

Hey: Can you make the substitutions/modifications or give a hint of where they belong? I'm unable to do this myself, as I posted before, far outside of my command knowledge.

The only substitution I've been able to make is the variables.

science_man_88 2010-08-19 14:59

couldn't you have gettime() called every few calculations and then ask if it's above a limit abort().

CRGreathouse 2010-08-19 15:03

[QUOTE=3.14159;226162]Hey: Can you make the substitutions/modifications or give a hint of where they belong? I'm unable to do this myself, as I posted before, far outside of my command knowledge.

The only substitution I've been able to make is the variables.[/QUOTE]

You should study it to see how it uses the vector, since you seem to have trouble there, then use the code I/we worked out earlier for the variable-k case -- Mod(-1,p)/stuff.

CRGreathouse 2010-08-19 15:04

[QUOTE=science_man_88;226163]couldn't you have gettime() called every few calculations and then ask if it's above a limit abort().[/QUOTE]

I wouldn't want to. What if I need it to run for a long time, e.g. for a few weeks? I'm running a project like that now.

3.14159 2010-08-19 15:12

[QUOTE=CRGreathouse]You should study it to see how it uses the vector, since you seem to have trouble there, then use the code I/we worked out earlier for the variable-k case -- Mod(-1,p)/stuff.
[/QUOTE]

So I should revert back to Liftmodm1/em2/mem?

3.14159 2010-08-19 15:41

Bumped into twin primes: 67787178174290220625980001 and 67787178174290220625979999.

And: 67787178174290220625980000^1 + 1 is prime: 67787178174290220625980000^2 + 1 is also prime!

That leads to n^(2^n)+1 chains/Fermat chains:

Has there been any search on that? I found 11861410^(1, 2, 4, 8, or 16) + 1 are all prime.

CRGreathouse 2010-08-19 15:47

[QUOTE=3.14159;226167]So I should revert back to Liftmodm1/em2/mem?[/QUOTE]

No, but you should put the loop from em2 into my function. (Mine has the appropriate loop for variable-n.) But don't print, store in a vector instead.

science_man_88 2010-08-19 15:57

[QUOTE=3.14159;226170]Bumped into twin primes: 67787178174290220625980001 and 67787178174290220625979999.

And: 67787178174290220625980000^1 + 1 is prime: 67787178174290220625980000^2 + 1 is also prime!

That leads to n^(2^n)+1 chains/Fermat chains:

Has there been any search on that? I found 11861410^(1, 2, 4, 8, or 16) + 1 are all prime.[/QUOTE]

only example I've found is 1 wow who would of thought lol.

3.14159 2010-08-19 16:01

[QUOTE=CRGreathouse]No, but you should put the loop from em2 into my function. (Mine has the appropriate loop for variable-n.) But don't print, store in a vector instead.
[/QUOTE]

From: em2(x,n,a)=forstep(b=lift(Mod(-1,x)/n),10^a,x,print(b))
To: em2(x,n,a)=forstep(b=lift(Mod(-1,x)/n),10^a,x,v[(b)])?

3.14159 2010-08-19 16:02

[QUOTE=science_man_88]only example I've found is 1 wow who would of thought lol.
[/QUOTE]

Stating the obvious: Every power of 1 plus 1 is prime.

2 = The oddest prime.

science_man_88 2010-08-19 16:14

[CODE]for(n=1,100,print(isprime(n^2+1)"," isprime(n^4+1)",",isprime(n^8+1)","isprime(n^16+1)"," isprime(n^32+1)"," isprime(n^64+1)))[/CODE]

figure it out.

3.14159 2010-08-19 16:33

I found this: 703 * p(125)#^66 + 1. (≈ 19100 digits)

CRGreathouse 2010-08-19 17:26

[QUOTE=3.14159;226174]From: em2(x,n,a)=forstep(b=lift(Mod(-1,x)/n),10^a,x,print(b))
To: em2(x,n,a)=forstep(b=lift(Mod(-1,x)/n),10^a,x,v[(b)])?[/QUOTE]

Let's see. (b) evaluates to b, v[b] evaluates to the b-th value in v. If v happens to be a vector, and #v is at least as large as the value of b, then it passes whatever happens to be in that location in the vector to forstep. Forstep ignores the values its given (unlike, say, sum() or prod()), so this code has the following behavior:

* If v is a vector with size at least as large as the final value of b (around 10^a), then do nothing.
* If lift(Mod(-1,x)/n) is greater than 10^a, then do nothing.
* Otherwise, if v is a vector, throw an "index out of bounds" error.
* If v is not a vector, and lift(Mod(-1,x)/n) is <= 10^a, then throw a "_[_]: not a vector" error.


All times are UTC. The time now is 23:20.

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