mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Miscellaneous Math

Reply
 
Thread Tools
Old 2010-07-25, 01:00   #166
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Please post both scripts so I can compare!
Code:
Goldbach(n)={
	my(nn=n+n);
	forprime(x=2,n,if(isprime(nn-x),return(x)));
	0
};
GoldbachMax(n)={
	my(nn=n+n);
	forprime(x=2,default(primelimit),if(isprime(nn-x),return(x)));
	error("Ran out of primes at "n)
};
test(lim,startAt=2)={
my(breakpoint=min(lim\2,default(primelimit)));
startAt=floor(startAt);
for(n=startAt,breakpoint,
if(Goldbach(n),print1(2*n,","))
);
for(n=max(startAt,breakpoint+1),lim\2,
if(GoldbachMax(n),print1(2*n,","))
)
};
took 24000 by the way if it prints everything.

Code:
Gold(n)={
	forprime(x=2,n/2,
		f=floor((.5*n-x)+(.5*n));
		if(isprime(f),
			print(x","f","n);
			return();
		);
	)
};

forstep(n=2,400,2,Gold(n))
if i did math right took more

and

mine = for(c=2,500,for(n=0,c-3,if(isprime(c-n) && isprime(c+n),print(c","n);break()))) originally from what I just posted on.

and my best improvement is:

for(c=2,500,if(c%2==0,forstep(n=1,c-3,[2],if(isprime(c-n) && isprime(c+n),print(c","n);break())));if(c%2==1,forstep(n=2,c-3,[2],if(isprime(c-n) && isprime(c+n),print(c","n);break()))))<- double checking the time for.
I messed it up as I swear it said 4000 last time but it says 50,000 now anyone willing to test it ?

Last fiddled with by science_man_88 on 2010-07-25 at 01:08
science_man_88 is offline   Reply With Quote
Old 2010-07-25, 01:08   #167
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Printing takes a lot of time -- remove the print statements if you want to compare!

The second piece of code you posted, Gold(n), is just my cleaned-up version of your code; it's not fast. The first one, apart from the print instructions, is fast. In my test it's more than ten times faster than yours -- 2.7 seconds to get to a million vs. 47 seconds for your old version or 40 seconds for your new version.

Code:
Goldbach(n)={
	my(nn=n+n);
	forprime(x=2,n,if(isprime(nn-x),return(0)));
	1
};
GoldbachMax(n)={
	my(nn=n+n);
	forprime(x=2,default(primelimit),if(isprime(nn-x),return(0)));
	error("Ran out of primes at "n)
};
test(lim,startAt=2)={
	my(breakpoint=min(lim\2,default(primelimit)));
	startAt=floor(startAt);
	for(n=startAt,breakpoint,
		if(Goldbach(n),print1(2*n,","))
	);
	for(n=max(startAt,breakpoint+1),lim\2,
		if(GoldbachMax(n),print1(2*n,","))
	)
};


sm88(lim)={
	for(c=2,lim,for(n=0,c-3,if(isprime(c-n)&&isprime(c+n),break)))
};


sm88a(lim)={
	for(c=2,lim,
		if(c%2==0,
			forstep(n=1,c-3,[2],if(isprime(c-n) && isprime(c+n),break))
		);
		if(c%2==1,
			forstep(n=2,c-3,[2],if(isprime(c-n) && isprime(c+n),break))
		)
	)
};

Last fiddled with by CRGreathouse on 2010-07-25 at 01:16
CRGreathouse is offline   Reply With Quote
Old 2010-07-25, 01:53   #168
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

32208 Posts
Default

Cheesehead. Do you also visit the kook section regularly?

Last fiddled with by 3.14159 on 2010-07-25 at 01:54
3.14159 is offline   Reply With Quote
Old 2010-07-25, 03:40   #169
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Red face

Actually, the numbers I posted above were bad (comparing the wrong things). Running my test to 2e6 is the proper comparison to running yours to 1e6, so my time is 5.9 seconds; 6 or 7 times faster than yours, not "more than 10 times".
CRGreathouse is offline   Reply With Quote
Old 2010-08-08, 21:19   #170
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Actually, the numbers I posted above were bad (comparing the wrong things). Running my test to 2e6 is the proper comparison to running yours to 1e6, so my time is 5.9 seconds; 6 or 7 times faster than yours, not "more than 10 times".
well any combination of 6n-1,6n+1 will give a even number so it comes down to the probability of 2 aligning within x-3 either side of the given number such that both are prime.
science_man_88 is offline   Reply With Quote
Old 2010-08-09, 11:57   #171
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Code:
for(x=4,2^30,if(isprime(x) && nextprime(x)-x>(x-3),print(x)))
my way to check for one that would break Goldbach's conjecture is there a faster way to find out when the gap between primes is x-3 for a given x ?

Last fiddled with by science_man_88 on 2010-08-09 at 12:27
science_man_88 is offline   Reply With Quote
Old 2010-08-09, 12:47   #172
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

175B16 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
Code:
for(x=4,2^30,if(isprime(x) && nextprime(x)-x>(x-3),print(x)))
my way to check for one that would break Goldbach's conjecture is there a faster way to find out when the gap between primes is x-3 for a given x ?
For x >= A104272(2) + 1 = 12, nextprime(x) - x <= x-3. Numerical verification shows it holds for x > 2. So you don't need to test this one.

Ramanujan proved this in 1919 and possibly earlier.

Last fiddled with by CRGreathouse on 2010-08-09 at 13:05
CRGreathouse is offline   Reply With Quote
Old 2010-08-09, 13:09   #173
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
For x >= A104272(2) + 1 = 12, nextprime(x) - x <= x-3. Numerical verification shows it holds for x > 2. So you don't need to test this one.

Ramanujan proved this in 1919 and possibly earlier.
theres only one in my image that skips any 6n+1 6n-1 numbers at all from the first one below I don't get why it couldn't have been solved.
science_man_88 is offline   Reply With Quote
Old 2010-08-09, 13:24   #174
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

597910 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
theres only one in my image that skips any 6n+1 6n-1 numbers at all from the first one below I don't get why it couldn't have been solved.
I don't understand your post. My only point was to show that the code
Code:
for(x=4,N,if(isprime(x) && nextprime(x)-x>(x-3),print(x)))
will not print anything, regardless of the value of N used.
CRGreathouse is offline   Reply With Quote
Old 2010-08-09, 13:31   #175
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
I don't understand your post. My only point was to show that the code
Code:
for(x=4,N,if(isprime(x) && nextprime(x)-x>(x-3),print(x)))
will not print anything, regardless of the value of N used.
I know that's what you meant as only one part of my image doesn't hit every 6n+1/-1 number either direction last I checked it should be simple to prove Goldbach's conjecture
science_man_88 is offline   Reply With Quote
Old 2010-08-09, 14:16   #176
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
I know that's what you meant as only one part of my image doesn't hit every 6n+1/-1 number either direction last I checked it should be simple to prove Goldbach's conjecture
I don't understand the first part of your post. For the second part, I don't think that it is simple to prove the GC.
CRGreathouse is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Goldbach Conjecture MattcAnderson MattcAnderson 4 2021-04-04 19:21
Factorial and Goldbach conjecture. MisterBitcoin MisterBitcoin 17 2018-01-29 00:50
Goldbach's weak conjecture MattcAnderson MattcAnderson 19 2017-03-21 18:17
Goldbach's conjecture Citrix Puzzles 3 2005-09-09 13:58

All times are UTC. The time now is 04:47.


Fri Aug 6 04:47:12 UTC 2021 up 13 days, 23:16, 1 user, load averages: 2.62, 2.40, 3.11

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.