mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Miscellaneous Math

Reply
 
Thread Tools
Old 2010-07-22, 18:32   #144
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
This code shows that there is some Goldbach partition for some even number up to 400000, not that every even number up to 400000 has a Goldbach partition. It's faster by doing far less.
I realize that now lol in fact it only proves one.
science_man_88 is offline   Reply With Quote
Old 2010-07-22, 18:48   #145
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Also: If 6n+1, 12n+1, and 18n+1 are prime, (6n+1)(12n+1)(18n+1) = Carmichael number.

My best guess:

(6n+1)(12n+1) = 72n^2 + 6n + 12n + 1 = 72n^2 + 18n + 1

(18n+1)(72n^2 + 18n + 1) = 1296n^3 + 72n^2 + 324n^2 + 18n + 18n + 1

That = 1296n^3 + 396n^2 + 36n + 1
Pari can do that for you if you'd like:

Code:
>(6*n+1)*(12*n+1)*(18*n+1)
time = 0 ms.
%1 = 1296*n^3 + 396*n^2 + 36*n + 1
Quote:
Originally Posted by 3.14159 View Post
I need a bit of assistance here..

Code:
(13:20) gp > b(n) = {
for(n = 10^3, 3*10^3,(1296*n^3 + 396*n^2 + 36*n + 1,
if(numdiv(1296*n^3 + 396*n^2 + 36*n + 1) == 8, print(n)));
}
Code:
***   syntax error, unexpected ')', expecting KPARROW or ',': ...*n^2+36*n+1)==8,print(n)));
The error says that your parentheses don't match. If I just delete the portion "(1296*n^3 + 396*n^2 + 36*n + 1," which has the unmatched parenthesis, it works.

You shouldn't take n as a parameter, though, since you don't use it. Doubly so since your loop variable is n and it looks confusing. You may want to take a variable that says how high to go, though -- I usually call such variables "lim". So:
Code:
b(lim)={
	for(n = 10^3, lim,
		if(numdiv(1296*n^3 + 396*n^2 + 36*n + 1) == 8, print(n))
	);
};
But this is inefficient in the extreme: instead of doing a primality test on three numbers around n, you factor a number around n^3. Do this:
Code:
b(lim)={
	for(n = 10^3, lim,
		if(isprime(6*n+1)&isprime(12*n+1)&isprime(18*n+1), print(n))
	);
};
This way:
* You're doing isprime() instead of factoring a number, which is vastly faster;
* You can exit the loop early if any one of the tests fails.
CRGreathouse is offline   Reply With Quote
Old 2010-07-23, 00:17   #146
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

I once again search for generalized Fermat primes (Exponent = 256), and for misc. primes. (Factorial-based, etc.). So far, the largest Generalized Fermat I have ever found is also the second-largest prime number I have ever found. (13050 digits)

Last fiddled with by 3.14159 on 2010-07-23 at 01:01
3.14159 is offline   Reply With Quote
Old 2010-07-23, 01:26   #147
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
I once again search for generalized Fermat primes (Exponent = 256), and for misc. primes. (Factorial-based, etc.). So far, the largest Generalized Fermat I have ever found is also the second-largest prime number I have ever found. (13050 digits)
Does GFN mean "of the form b^{2^n}"? Because in that case all 256-GFNs are Fermat numbers...
CRGreathouse is offline   Reply With Quote
Old 2010-07-23, 01:30   #148
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Does GFN mean "of the form b2[sup]n[/sup] "? Because in that case all 256-GFNs are Fermat numbers...
No: I meant, n256+1. I did not use base 256, and yes: Generalized Fermats are of the form b2[sup]n[/sup], where b does not have to be 2 or any of its powers.

Last fiddled with by 3.14159 on 2010-07-23 at 01:35
3.14159 is offline   Reply With Quote
Old 2010-07-23, 03:07   #149
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

PrimeForm is usually the best exploratory tool for primes like that, though if you have a 13 kilodigit under your belt I suppose you don't need any advice.
CRGreathouse is offline   Reply With Quote
Old 2010-07-23, 11:43   #150
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
PrimeForm is usually the best exploratory tool for primes like that, though if you have a 13 kilodigit under your belt I suppose you don't need any advice.
It's the second-largest. The definite largest is 59991 * 291360 + 1 (27507 digits)
3.14159 is offline   Reply With Quote
Old 2010-07-23, 16:17   #151
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

a=0;forstep(n=2,400,[2],forprime(x=2,n/2,if(isprime(floor((.5*n-x)+(.5*n))),print(x","floor((.5*n-x)+(.5*n))","n));a=a+1;if(a>0,break()))) this is the best I could do for what I pm'd you but it only seems to work once.
science_man_88 is offline   Reply With Quote
Old 2010-07-23, 16:32   #152
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
a=0;forstep(n=2,400,[2],forprime(x=2,n/2,if(isprime(floor((.5*n-x)+(.5*n))),print(x","floor((.5*n-x)+(.5*n))","n));a=a+1;if(a>0,break()))) this is the best I could do for what I pm'd you but it only seems to work once.
Please use [code] tags and format your code! It's hard to read all bunched up like that.

Code:
a=0;
forstep(n=2,400,[2],
	forprime(x=2,n/2,
		if(isprime(floor((.5*n-x)+(.5*n))),
			print(x","floor((.5*n-x)+(.5*n))","n)
		);
		a=a+1;
		if(a>0,break())
	)
)
There's no reason to give the step size as a vector if there's only one element, so I'll remove that. I also see that you use floor((.5*n-x)+(.5*n)) twice, so let's save that in a variable. (In this case it doesn't make the code any faster, really, but it's much more readable.) Also, "a=a+1" can be rewritten as "a+=1" (add 1 to a) or, even shorter, as "a++" in the particular case of adding exactly one.
Code:
a=0;
forstep(n=2,400,2,
	forprime(x=2,n/2,
		f=floor((.5*n-x)+(.5*n));
		if(isprime(f),
			print(x","f","n)
		);
		a++;
		if(a>0,break())
	)
)
Now you can see that you add one to a then immediately test if it's greater than zero; you can simply replace the test and use of a with an unconditional break.
Code:
forstep(n=2,400,2,
	forprime(x=2,n/2,
		f=floor((.5*n-x)+(.5*n));
		if(isprime(f),
			print(x","f","n)
		);
		break()
	)
)
Now you can see that you're breaking out after only testing to see if (n/2-2)+(n/2) = n-2 is prime. Of course it's only showing one... this can happen only if n-2 is an even prime.

The best way to fix it is to break out that portion as its own function:
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))
Of course the 'right' way is to have the function return the prime it finds and have the print statement in your forstep code, so that you can do other things with the result beside print it. For example, maybe you want to look only for large values?

Last fiddled with by CRGreathouse on 2010-07-23 at 16:34
CRGreathouse is offline   Reply With Quote
Old 2010-07-23, 17:04   #153
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

22·727 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Code:
forstep(n=2,400,2,
	forprime(x=2,n/2,
		f=floor((.5*n-x)+(.5*n));
		if(isprime(f),
			print(x","f","n)
		);
		break()
	)
)
f = .5*n-x + .5*n ???

So f = n-x !?

I think the original form was like :
Code:
if(isprime(.5*c+n) && isprime(.5*c-n)
So assuming this was meant:
If I'm understand this correct (not yet coded with PARI), the forstep-loop chooses only even values of n. Correct?

And to calculate the value f it uses 2-times the expression '.5*n'.

So why not using all n-values and check for isprime(c+n) && isprime(c-n).
Should be much faster without two multiplications.

The output has to be changed then, too.
kar_bon is offline   Reply With Quote
Old 2010-07-23, 17:13   #154
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

597910 Posts
Default

Quote:
Originally Posted by kar_bon View Post
f = .5*n-x + .5*n ???

So f = n-x !?
You'll have to take that up with science_man_88. I keep suggesting things like that, but he likes the 0.5*n forms because of some connection with the interpretation of equally-spaced primes from 0.5*n. (sm88: if you do n/2 rather than 0.5*n you can avoid using floor().)

You can see his original code in post #151; I'm just cleaning it up.

Quote:
Originally Posted by kar_bon View Post
If I'm understand this correct (not yet coded with PARI), the forstep-loop chooses only even values of n. Correct?
Right.

Quote:
Originally Posted by kar_bon View Post
And to calculate the value f it uses 2-times the expression '.5*n'.

So why not using all n-values and check for isprime(c+n) && isprime(c-n).
Should be much faster without two multiplications.
Yep. Been there, done that; see post #62.

Last fiddled with by CRGreathouse on 2010-07-23 at 17:13
CRGreathouse is offline   Reply With Quote
Reply



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:09 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.