mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2010-08-17, 19:17   #639
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
6? O rly?
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 is offline   Reply With Quote
Old 2010-08-17, 19:32   #640
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

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))
	);
};
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 \pi(x)-\pi(a-1) times (total (x-a+1)(\pi(x)-\pi(a-1)) times), which results in em2's inner print statement being called about p/10^b times (total very roughly
\frac{(x-a+1)(a-x)(\pi(x)-\pi(a-1))^2}{2\cdot10^b}
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.

Last fiddled with by CRGreathouse on 2010-08-17 at 19:44
CRGreathouse is offline   Reply With Quote
Old 2010-08-18, 03:40   #641
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by 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.
Correct. It failed to function properly. As for the latter, em2 does what it is supposed to do.
3.14159 is offline   Reply With Quote
Old 2010-08-18, 05:10   #642
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

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.
CRGreathouse is offline   Reply With Quote
Old 2010-08-18, 13:45   #643
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by 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.
Well, I did say mem needs some fixing.
3.14159 is offline   Reply With Quote
Old 2010-08-18, 21:32   #644
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

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.

Last fiddled with by 3.14159 on 2010-08-18 at 21:32
3.14159 is offline   Reply With Quote
Old 2010-08-18, 21:34   #645
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

32208 Posts
Default

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.

Last fiddled with by 3.14159 on 2010-08-18 at 21:40
3.14159 is offline   Reply With Quote
Old 2010-08-18, 21:40   #646
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Now that I have pinned a return value instead of printing, I'll see what I can do for mem.
3.14159 is offline   Reply With Quote
Old 2010-08-18, 21:42   #647
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

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.

Last fiddled with by 3.14159 on 2010-08-18 at 21:42
3.14159 is offline   Reply With Quote
Old 2010-08-18, 21:43   #648
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

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

Scratched: This would also loop and repeat duplicates endlessly.

Last fiddled with by 3.14159 on 2010-08-18 at 21:49
3.14159 is offline   Reply With Quote
Old 2010-08-18, 21:49   #649
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

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 106 and testing those which have no factors below 106.

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

Last fiddled with by 3.14159 on 2010-08-18 at 21:56
3.14159 is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

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


Fri Aug 6 23:03:55 UTC 2021 up 14 days, 17:32, 1 user, load averages: 3.59, 3.88, 3.93

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.