Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#126 2013-04-09 04:09:14

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

What is the way that you are generating yours and what are you using as a language?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#127 2013-04-09 04:21:10

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

Python(ya, its slow)
I am doing it this way

1. Load the previous list of primes(which I made six months ago)
2. Define the miller-rabin with k=7
3. Define the primality test which says whether or not a number is prime by checking whether it is divisible by all the primes which are in the list of primes upto the square root of the given number
4. Let n = the last prime in the list loaded
5. If n = 9999999999, terminate
6. Increment n by 1
7. If miller-rabin claims  n to be prime, proceed to 8, otherwise goto 5
8. If the real primality test claims n to be prime, proceed to 9, otherwise goto 5
9. Write n in the file, goto 5

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#128 2013-04-09 04:28:08

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

There are a couple of possible bottlenecks there.

First how fast is line 8? What method is being used?

Line 6, should be increment by 2.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#129 2013-04-09 04:30:49

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

Ya, thats a. Good point

For 8, reffer 3


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#130 2013-04-09 04:32:43

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

Two tests for primality are redundant.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#131 2013-04-09 04:39:15

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

But the Miller rabin is done at first so as to save time


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#132 2013-04-09 04:43:18

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

Yes but is it really saving time? I would totally go with the Miller - Rabin.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#133 2013-04-09 04:54:16

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

If you would totally go with the miller-rabin, then how would you be sure whether the number you're going through is prime or not?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#134 2013-04-09 05:02:05

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

There are things that are almost certainly true. They are so rare as to be impossible.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#135 2013-04-09 05:10:42

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

bobbym wrote:

Okay, with k = 7 there was less than one chance in 16384 that it was making a mistake.

The risk is not worth it.
I am making a lot more primes than 16384


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#136 2013-04-09 05:17:48

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

Supposing you doubled k? What do you think will happen?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#137 2013-04-09 05:22:51

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

But still, what if I am one of those unlucky guys out of 100000000 who get a wrong result?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#138 2013-04-09 05:27:55

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

By the way, last day at 12:30 at night I told Alokananda that her phone number is the sum of two primes. Than I told her that there are more than 113274 ways of representing that

She was perhaps shocked and said something which translates like "You do such things at night? Are you mad?"
Then she said, "Had it been any other girl, you would have driven them mad. Only because I am Alokananda, I am still not mad"


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#139 2013-04-09 05:29:06

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

If you chose k = 14 then and if you generated 250 000 000 primes you should expect to only have 1 false prime in the list!

If you chose k = 21 you would need to generate 4 billion primes to expect to have 1 wrong!

But still, what if I am one of those unlucky guys

Do you know that you take a gamble like that everyday? You do not get unlucky.

Isn't it better to generate your list knowing there is an extremely tiny chance that one of them is false rather than generating no list that is perfect!


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#140 2013-04-09 05:36:11

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

If I choose k=22, how much time would it take to complete upto 9999999999(10 digits)?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#141 2013-04-09 05:42:57

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

how much time would it take to complete

That is another question. Right now we are dealing with mathematics and Agnishom's mind.

I would use k = 24 and it is extremely unlikely that there will be a false prime in your list.
Anyways, there are ways to now make sure there are no errors.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#142 2013-04-09 05:52:45

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

What are they?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#143 2013-04-09 05:55:10

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

There are 455052511 primes less than 10 000 000 000. Your list is checked to see if it has that many, then you know there are no errors!

Now we can get to your last line which is possibly another error.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#144 2013-04-09 07:47:55

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

Error? Its my loop!


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#145 2013-04-09 07:50:26

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

Excuse me, I meant 9.

Do you understand what I am saying about generating the primes?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#146 2013-04-09 07:52:45

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

9 says Write n to file, goto 5


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#147 2013-04-09 07:53:40

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

Okay, hold that for a second. Are you clear why you need only one test? Miller - Rabin will be enough?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#148 2013-04-09 07:59:14

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

Ya because at last we can check whether it has the required number of primes or not. And moreover, the number of primes can be less but NEVER more because if it says that a number is composite it definately is


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#149 2013-04-09 08:02:44

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematics jokes

Okay, so we have sped it up already because you are no longer using trial division, which is slow.

Let's talk about the list itself. 455 million primes is a very, very big list. There is no list like that on the internet and for good reason. It is going to be a gigabyte or more.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#150 2013-04-09 08:04:37

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematics jokes

Okay! A gigabite?

That's quite huge

Last edited by Agnishom (2013-04-09 08:05:04)


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

Board footer

Powered by FluxBB