My Math Forum Primes map generator

 Computer Science Computer Science Forum

 August 23rd, 2013, 07:12 AM #1 Newbie   Joined: Aug 2013 From: Netherlands Posts: 7 Thanks: 0 Primes map generator Hopefully I'm posting this in the right (sub-)forum as it overlaps with a few other categories. ----- Anyway, a week ago, after I had watched yet another Numberphile video, I came with the idea to write an algorithm that would create a visual representation, some sort of map, that is, of prime numbers. Currently, this project is capable of quickly generating simple grids, Ulam spirals and even Sacks spirals, while also real-time updating the map to highlight prime k-tuples, and when hovering over a number several pieces of information will be shown, such as its prime factors. I didn't post this to hear from random people "Wow, awesome.". I'd rather hear your comments on what you think could be better, or maybe even functions I've missed, like another type of spiral or a piece of information that could be displayed with a number. The tool can be found here, and it's written in JavaScript (with jQuery). When trying it out, I'd recommend not going any higher than 20.000, while 50.000 and even 100.000 are still doable (but take longer), and even higher has not been tested by me yet. The drawing of a grid and an Ulam spiral take about evenly long, a Sacks spiral takes longer. ----- Tl;dr: What do you think of this tool I wrote?
 August 23rd, 2013, 02:38 PM #2 Global Moderator     Joined: Nov 2006 From: UTC -5 Posts: 16,046 Thanks: 938 Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms Re: Primes map generator Neat. I haven't looked through the code yet; does it update the primes individually or just once for each sieving prime?
 August 24th, 2013, 11:53 AM #3 Newbie   Joined: Aug 2013 From: Netherlands Posts: 7 Thanks: 0 Re: Primes map generator It first draws all the squares and gives every one of them the 'prime' class and colours. Once it has done that, it checks for every single number whether it is a prime, and then it changes the class and colours to 'composite'. Try a range of 1 to 20.000 or even to 50.000, and you can clearly see the process of sieving. The sieving function is called 'sieve', in case you'd decide to take a look.
 August 24th, 2013, 03:12 PM #4 Math Team   Joined: Apr 2010 Posts: 2,780 Thanks: 361 Re: Primes map generator Did you watch this video? I like the tool as it is but perhaps if you want to add functions to it you might want to consider to add a function that draws the lines with more primes than generally or one that shows the sieving more slowly, by some delay between two checks.
August 24th, 2013, 04:29 PM   #5
Newbie

Joined: Aug 2013
From: Netherlands

Posts: 7
Thanks: 0

Re: Primes map generator

Quote:
 Originally Posted by Hoempa Did you watch this video?
That is indeed the video that inspired me to write this tool!

-----
Quote:
 Originally Posted by Hoempa I like the tool as it is but perhaps if you want to add functions to it you might want to consider to add a function that draws the lines with more primes than generally or one that shows the sieving more slowly, by some delay between two checks.
Sounds like a neat idea, and not even hard to implement (could be done in a day or so). I could even add buttons to go to the next step of sieving, though the biggest problem with that is that I think the menu is already quite full of stuff, so I wouldn't know where to place them

August 25th, 2013, 03:13 AM   #6
Math Team

Joined: Apr 2010

Posts: 2,780
Thanks: 361

Re: Primes map generator

Quote:
 Originally Posted by Waflix That is indeed the video that inspired me to write this tool!
Ah cool than you know about these lines.
Quote:
 Originally Posted by Waflix Sounds like a neat idea, and not even hard to implement (could be done in a day or so). I could even add buttons to go to the next step of sieving, though the biggest problem with that is that I think the menu is already quite full of stuff, so I wouldn't know where to place them
Maybe you could put the options for the lines next to the choice for the mapstyle, like
, for example only shown when a particular style is selected.
Options for delay perhaps in Standard? More space there, even after data are shown, and it applies to all Map Styles.
Quote:
 Originally Posted by your site A prime triplet is a set of three primes of which the difference is p, then p + 2 or p + 4 and then p + 6.
I believe that is not what you want. A prime triplet is a set of three primes p, p + 2 or p + 4, p + 6. Or are you indicating the lines from the video?

August 25th, 2013, 03:55 AM   #7
Newbie

Joined: Aug 2013
From: Netherlands

Posts: 7
Thanks: 0

Re: Primes map generator

Quote:
Originally Posted by Hoempa
Quote:
 Originally Posted by Waflix Sounds like a neat idea, and not even hard to implement (could be done in a day or so). I could even add buttons to go to the next step of sieving, though the biggest problem with that is that I think the menu is already quite full of stuff, so I wouldn't know where to place them
Maybe you could put the options for the lines next to the choice for the mapstyle, like
(image), for example only shown when a particular style is selected.
Whoops, I actually read over the part where you spoke of those lines and just read the part about the delay. But I indeed do know of those lines.
So you'd propose marking the primes with perhaps another colour if it's on a certain line? If that's the case, I could either choose for a few set lines from which the user can choose, or I could write a whole interpreter to turn the entered string into an equation. However, I've never really written an interpreter before, except for the extremely simple interpreter that reads the custom prime k-tuple.

Quote:
 Originally Posted by Hoempa Options for delay perhaps in Standard? More space there, even after data are shown, and it applies to all Map Styles.
Let me think. I'll need a button to toggle the delay, and maybe somewhere the delay should be set? How about putting the toggle under standard, and the delay itself under advanced settings?

Quote:
Originally Posted by Hoempa
Quote:
 Originally Posted by your site A prime triplet is a set of three primes of which the difference is p, then p + 2 or p + 4 and then p + 6.
I believe that is not what you want. A prime triplet is a set of three primes p, p + 2 or p + 4, p + 6. Or are you indicating the lines from the video?
With a prime triplet I meant that there are two possibilities: it is either of the form (p, p + 2, p + 6) or of the form (p, p + 4, p + 6). You should read the explanation on my site as that a prime triplet is of the form (p, (p + 2 or p + 4), p + 6).

August 25th, 2013, 07:46 AM   #8
Math Team

Joined: Apr 2010

Posts: 2,780
Thanks: 361

Re: Primes map generator

Quote:
 Originally Posted by Waflix So you'd propose marking the primes with perhaps another colour if it's on a certain line? If that's the case, I could either choose for a few set lines from which the user can choose, or I could write a whole interpreter to turn the entered string into an equation. However, I've never really written an interpreter before, except for the extremely simple interpreter that reads the custom prime k-tuple.
Do you want such an interpreter? Personally, I'd try to minimize required users input. Sure, you can change things the way you want but if you don't change anything and press start, then you still get such a graph for settings you, the programmer choose. You could check all these lines, find that on average ther are, say 4% prime. Some lines contain over 10% primes for which the primes could be marked than. This doesn't require user-input at all but if you want some, you could have user change percentages or so. I think that would be easier to interpret.

Quote:
 Originally Posted by Waflix Let me think. I'll need a button to toggle the delay, and maybe somewhere the delay should be set? How about putting the toggle under standard, and the delay itself under advanced settings?
Yes, I like the idea, also where you place the options. Do you drop buttons to go to the next step of sieving? I just want to share ideas, not really tell you what to do.

Quote:
 Originally Posted by Waflix With a prime triplet I meant that there are two possibilities: it is either of the form (p, p + 2, p + 6) or of the form (p, p + 4, p + 6). You should read the explanation on my site as that a prime triplet is of the form (p, (p + 2 or p + 4), p + 6).
Ah, I see what you mean. I read it like such a triplet could be 5, 7, 11, 19. They have differences of the form p, p + 2, p + 6 where p = 2, but that's four primes instead of three but three differences. p itself needn't be prime, it's just (a term from) the differences. p = 4 gives 3, 7, 13, 23 as an option. But we want just 3 primes.
3, 7, 13 all have differences of the form p, p + 2, p + 6; 7 - 3 = p = 4, 13 - 7 = p + 2, 13 - 3 = p + 6. If p must be prime then 7, 11, 13. The word difference confused me there but I get it with your explanation.

August 25th, 2013, 08:01 AM   #9
Newbie

Joined: Aug 2013
From: Netherlands

Posts: 7
Thanks: 0

Re: Primes map generator

Quote:
Originally Posted by Hoempa
Quote:
 Originally Posted by Waflix So you'd propose marking the primes with perhaps another colour if it's on a certain line? If that's the case, I could either choose for a few set lines from which the user can choose, or I could write a whole interpreter to turn the entered string into an equation. However, I've never really written an interpreter before, except for the extremely simple interpreter that reads the custom prime k-tuple.
Do you want such an interpreter? Personally, I'd try to minimize required users input. Sure, you can change things the way you want but if you don't change anything and press start, then you still get such a graph for settings you, the programmer choose. You could check all these lines, find that on average ther are, say 4% prime. Some lines contain over 10% primes for which the primes could be marked than. This doesn't require user-input at all but if you want some, you could have user change percentages or so. I think that would be easier to interpret.
The formula for the amount of lines that can be drawn is 2 + 4(n - 1), where n is the width/height (whichever is higher) of the spiral. Would I be to draw a 200 by 200 grid, I'd have 798 lines to draw. To draw a line, I need to create a formula for that specific line (which I need to automate, so like a general formula that creates formulae), and then count the total amount of primes on that line. I think the hardest part mathematically is finding that general formula, and after I've managed that I'll also have to see whether the amount of calculations (and their severity) is even reasonable.

Quote:
 Originally Posted by Waflix Let me think. I'll need a button to toggle the delay, and maybe somewhere the delay should be set? How about putting the toggle under standard, and the delay itself under advanced settings?
Yes, I like the idea, also where you place the options. Do you drop buttons to go to the next step of sieving? I just want to share ideas, not really tell you what to do.[/quote]
I think I'll put a small button inside the progress bar that says "next" to go to the next factor. But currently I'm playing Skyrim. :P

 August 28th, 2013, 02:27 AM #10 Math Team   Joined: Apr 2010 Posts: 2,780 Thanks: 361 Re: Primes map generator I've been a bit busy too last days, other things around here and the beach and the like. The numbers on the lines, at least from bottom left to upper right seem to lie on one or two quadratics, ax^2+bx+c. The diagonal has 1, the others 2. They seem pretty similar, having a = 4. I haven't found them all though, didn't try. Are you still working on this?

 Tags generator, map, primes

### sacks spiral generator

Click on a term to search for related topics.
 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post caters Number Theory 67 March 19th, 2014 04:32 PM ungeheuer Algebra 4 November 13th, 2013 09:41 AM krausebj0 Number Theory 1 June 22nd, 2013 01:42 AM asoracc Abstract Algebra 2 February 27th, 2011 07:03 PM jhoffma4 Advanced Statistics 0 September 11th, 2009 06:22 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top