mersenneforum.org Strange formula
 Register FAQ Search Today's Posts Mark Forums Read

 2018-12-12, 10:05 #1 Godzilla     May 2016 2428 Posts Strange formula Good morning , I am testing this formula and I believe it produces many prime numbers when the result is an odd number. I can not find any logical relationship with this formula in general but interesting to show. $ f_{n+1}=\frac{\pi*2^{\pi}*n}{\sqrt{\pi*2^{\pi}*(n*5)}}$ P.S. especially if $n$ is a prime number .
 2018-12-12, 15:27 #2 Batalov     "Serge" Mar 2008 Phi(4,2^7658614+1)/2 962910 Posts 'When all you have is a screwdriver, everything looks like a nail to you' ...or something like that.
2018-12-13, 02:35   #3
CRGreathouse

Aug 2006

3×1,993 Posts

Quote:
 Originally Posted by Godzilla I am testing this formula and I believe it produces many prime numbers when the result is an odd number. I can not find any logical relationship with this formula in general but interesting to show. $ f_{n+1}=\frac{\pi*2^{\pi}*n}{\sqrt{\pi*2^{\pi}*(n*5)}}$
In general the result won't be an integer. I'll assume you round in some consistent way (down, to nearest, or up).

It can be proven that the rounded value of $$f_n$$ is asymptotically almost surely composite, whether n is taken odd or even. That is, the probability that $$f_n$$ is composite is, in the limit, 100%.

2018-12-13, 09:06   #4
Godzilla

May 2016

2×34 Posts

Quote:
 Originally Posted by CRGreathouse That is, the probability that $$f_n$$ is composite is, in the limit, 100%.
The curiosity is that the function finds for certain values n the same prime number (f rounded). In proportion more n increases and more f has the same value.

Program.py
Code:
ii=1
i2=0
GG=0
FF=0
VV =0
e = 0
AA=0
c = 1
a =1
bb=0
dd=0
I=1
II=0
i=1
i1=0
#b=5*a
d=5
e=1

bb=input('Inserire numero: ')

while c<=bb:
b=5*a
#e=5*a
#d=e//5
funzione=(3.14*2**3.14*a)//((3.14*2**3.14*(5*a))**(1/2.0))
#e=5*a
#d=e//5
#b=5*a
#d=funzione
#d=d*3+1
b=funzione
print(' N= ---->' , a)
print('Funzione---',funzione)
#if a==1 or 2:

#print('A un numero primo ',a)

while I<=funzione:

I=I*1
I=I+1
if funzione == I:

print(' F is a prime number -----', funzione)
AA=AA+1
break

if funzione % I == 0 :

break

I=1
a=a+1
c=c+1

print('\n\n\nTOTALE PRIME NUMBER FOUND : ',AA)

For example prime number 73 there is from n = 963 to n = 989 ( or equal from n = 963*5 to n = 989*5)

Code:
(' N= ---->', 963)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 964)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 965)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 966)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 967)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 968)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 969)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 970)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 971)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 972)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 973)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 974)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 975)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 976)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 977)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 978)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 979)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 980)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 981)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 982)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 983)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 984)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 985)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 986)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 987)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 988)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)
(' N= ---->', 989)
('Funzione---', 73.0)
(' F is a prime number -----', 73.0)

2018-12-13, 14:59   #5
Dr Sardonicus

Feb 2017
Nowhere

514410 Posts

Quote:
 Originally Posted by CRGreathouse In general the result won't be an integer. I'll assume you round in some consistent way (down, to nearest, or up). It can be proven that the rounded value of $$f_n$$ is asymptotically almost surely composite, whether n is taken odd or even. That is, the probability that $$f_n$$ is composite is, in the limit, 100%.
If I'm reading that formula right, it's of the form C*sqrt(n) for a positive constant C. The values of, e.g. the integer floor will include every "sufficiently large" integer, and the number of repetitions of each value of the floor will increase without bound as n increases. (The same will hold for the integer ceiling, or the nearest integer.) For the C in this case, "sufficiently large" is probably 2 or 3.

2018-12-14, 06:51   #6
CRGreathouse

Aug 2006

3·1,993 Posts

Quote:
 Originally Posted by Dr Sardonicus If I'm reading that formula right, it's of the form C*sqrt(n) for a positive constant C. The values of, e.g. the integer floor will include every "sufficiently large" integer, and the number of repetitions of each value of the floor will increase without bound as n increases. (The same will hold for the integer ceiling, or the nearest integer.) For the C in this case, "sufficiently large" is probably 2 or 3.
Correct! Thus my a.a.s. result.

2018-12-14, 13:31   #7
Dr Sardonicus

Feb 2017
Nowhere

10100000110002 Posts

Quote:
 Originally Posted by CRGreathouse In general the result won't be an integer. I'll assume you round in some consistent way (down, to nearest, or up).
Let's see what using the integer floor gives. If

m <= c*sqrt(n) < (m+1) then

m^2 <= c^2 * n < (m+1)^2, so that

m^2/c^2 <= n < (m+1)^2/c^2.

This places n in an interval of length (2*m + 1)/c^2.

Now, let's see what rounding gives. If

m - 1/2 <= c*sqrt(n) <= m + 1/2, then

(m - 1/2)^2 <= c^2 * n <= (m + 1/2)^2, so that

(m - 1/2)^2/c^2 <= n <= (m + 1/2)^2/c^2.

This places n in an interval of length 2*m/c^2.

In either case, we have a pretty good handle on how many values of n produce a given value of m, because the length of an interval is, pretty nearly, the number of integers it contains.

And now, a trip to Fallacy Land.

Looking at the formulas, we see that the interval lengths for the two methods are different. The interval for the floor is consistently longer than the interval for rounding. So, using the integer floor will always give at least as many n-values producing a given m as rounding. An excess will inexorably build up. But that means the two methods will eventually produce different counts of the number of integers up to the same point!

Oh, dear! What are we going to do???

 2018-12-14, 16:30 #8 CRGreathouse     Aug 2006 3×1,993 Posts Not that it fundamentally changes the analysis, but the OP's second post clarified two things: the function is rounded down (not to nearest or closest or something funny) and the value used is not $$\pi$$ but 3.14, which changes the 989th value (mentioned in said post) from 74 to 73.
2018-12-15, 02:42   #9
LaurV
Romulan Interpreter

"name field"
Jun 2011
Thailand

100110010100002 Posts

Quote:
 Originally Posted by CRGreathouse the value used is not $$\pi$$ but 3.14, which changes the 989th value (mentioned in said post) from 74 to 73.
You made my day, hehe... One more prime than expected! So I can pick any float constant I like, and make my own formula?

Can I pick Mills' constant? As far as we can go, that only generates primes...

@OP: Joking apart, this formula does not produce more primes than expected. Think about it, prime numbers are very dense, especially when small, which makes this type of fallacies very common. Under 100, there are 25 primes. And if you limit it to odd numbers only, then half of the odd numbers under 100 are primes. Under a thousand, more than a third of the odd numbers are prime (there are 168 primes under 1000). So, this algorithm generates a lot of prime numbers: "take a coin and throw it up 50 times, count the number of heads, multiply by 2 and add 1. Write down the result." You will, for sure, see a lot of primes. Do it to 500. You will see a lot of primes too. But when you count them, they will not be more than half (or respectively a third) of the total numbers.

Take a dice, throw it out 31 times, add the numbers together, multiply by 6 (why? because the dice has 6 faces ), then if either result-1 or result+1 or result-5 or result+5 or result-7 or the result+7 is prime, you got a success, otherwise you got a fail. This "formula" generates ONLY prime numbers (successes).

Now take your formula and make it print few 100-digits numbers. See how many of them are prime. If you get half of them prime, then we talk. But even then, you may get none at 1000 digits...

Last fiddled with by LaurV on 2018-12-15 at 03:50

2018-12-15, 04:07   #10
Batalov

"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

9,629 Posts

Quote:
 Originally Posted by Godzilla funzione=(3.14*2**3.14*a)//((3.14*2**3.14*(5*a))**(1/2.0))
So this formula generates more or less all numbers.
How is it better than
f(n)=n ?
I would say f(n)=n is way better. It generates only primes, especially when n is prime!

Quote:
 Originally Posted by Godzilla P.S. especially if $n$ is a prime number
Exactly!!

2018-12-15, 13:16   #11
Dr Sardonicus

Feb 2017
Nowhere

23·643 Posts

Quote:
 Originally Posted by CRGreathouse Not that it fundamentally changes the analysis, but the OP's second post clarified two things: the function is rounded down (not to nearest or closest or something funny) and the value used is not $$\pi$$ but 3.14, which changes the 989th value (mentioned in said post) from 74 to 73.
It also changes the 26th value from 12 to 11 .
? n1=floor(sqrt(Pi*2^Pi*26/5));n2=floor(sqrt(3.14*2^3.14*26/5));print(n1);print(n2)
12
11

This is the first value of n for which the nth values differ. Of course, the two functions differ for every sufficiently large n; and by an ever-increasing amount.

 Similar Threads Thread Thread Starter Forum Replies Last Post Uncwilly Lounge 29 2013-05-05 16:12 Prime95 Data 18 2012-02-12 18:07 meeztamike Miscellaneous Math 11 2010-07-18 04:13 hoca Math 7 2007-03-05 17:41 pacionet Miscellaneous Math 15 2005-12-08 08:00

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

Tue Dec 7 23:56:21 UTC 2021 up 137 days, 18:25, 0 users, load averages: 1.96, 2.22, 2.19

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.