Sign up ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

This is a double question...

  1. I would like to see a plot of primes such that there are concentric circles, with each circle representing a prime and having its number represented as evenly placed points around the circle. For example,

    • r=2: two dots 180 degrees apart,
    • r=3: three dots 120 degrees apart,
    • r=4: five dots 72 degrees apart.

    Surely someone has plotted this before but I can't google it and I don't recognise it if I've already seen it. Can someone link to one?

  2. If I need to graph it myself, how can I express this on Wolframalpha or something?

Note: absolute math noob, if it's not obvious!

share|cite|improve this question
you mention the Ulam spiral, you may enjoy this discussion…, the only software you need to reproduce the results is LaTeX. – PatrickT Feb 16 '14 at 17:01
How much of the "flavour" of this plot is just odd numbers? What does the plot of all odd numbers look like? – Mark Hurd Feb 17 '14 at 0:06

3 Answers 3

up vote 17 down vote accepted

Here is a Mathematica function that should do what you want:

PrimeCircles[n_] :=
 Show[Table[Graphics[Circle[{0, 0}, k]], {k, 1, n}], Table[Table[
 Graphics[{PointSize[Large], Point[{k Cos[2 Pi j/Prime[k]], 
 k Sin[2 Pi j/Prime[k]]}]}], {j, 0, Prime[k] - 1}], {k, 1, n}]]

So for example, PrimeCircles[5] produces

enter image description here

Unfortunately, the ability to use something like this is not available in Wolfram Alpha.

Here is an animation of PrimeCircles[n] for n from 1 to 20:

enter image description here

Or, if you prefer the sizes of the circles to remain constant in the animation,

enter image description here

share|cite|improve this answer
That's it! I don't have any math tools. This is just a curiosity of mine. Can you show a higher density graph with more numbers please??? – bluedog Feb 16 '14 at 7:45
These are awesome answers guys. I am curious to see this for much larger numbers though - like for the Ulam Spiral on the Wikipedia page ( Perhaps, leaving out the circles themselves, and just showing the dots? – bluedog Feb 16 '14 at 7:53

Here is a version without the circles.

You can see it better here:

Made with

enter image description here

share|cite|improve this answer
Let me know if you want even larger versions, but the field gets pretty uniform (i.e., dull). – Matthew Conroy Feb 16 '14 at 8:01
Awesome. Since the quadrants are copies of each other, is it better to - somehow - spread one quadrant around the circle and ignore the other three? EDIT - Or perhaps, to effectively zoom in on one quadrant might be more logical and meanignful. – bluedog Feb 16 '14 at 8:04
@bluedog The quadrants aren't copies of each other - the half-planes are (there's a symmetry about the $x$ axis), but there's a fundamental asymmetry about the $y$ axis. – Steven Stadnicki Feb 16 '14 at 16:21
I want this as a poster. – J.R. Feb 16 '14 at 17:53

If you want to plot it using wolfram alpha, find the roots of $$ (x^2-1)(x^3-1)(x^5-1)(x^7-1) \cdots $$ See my attempt at^2-1%29*%28x^3-1%29*%28x^5-1%29%29

If you want to plot it yourself, then the points for any prime $p$ are at $$ (1,0) \\ (\cos(\theta), \sin(\theta)) \\ (\cos(2 \theta), \sin(2 \theta)) \\ (\cos(3\theta), \sin(3\theta)) \\ \cdots \\ (\cos((p-1)\theta), \sin((p-1)\theta))$$ where $\theta = 2 \pi/p$.

If you use octave or something similar, then it is just a nested loop. You may also want to vary the radius by the magnitude of the prime;

Added in response to OP's question: Here is a program I wrote in octave

hold off;
plot(0,0); % clear the plot
hold on;
for k=1:length(pr)
plot(r*cos(t*theta), r*sin(t*theta), 'o');
hold off;
print('-djpeg', 'primes.jpg');

The above program produced the following plot: enter image description here

share|cite|improve this answer
Yes, I would really like to see the radius increase by one for each circle. – bluedog Feb 16 '14 at 7:37
By the way, octave is a free program. I would highly recommend it. – user44197 Feb 16 '14 at 8:38
If you want the radius increase by one, you can plot the roots of $(x^2-1^2)(x^3-2^3)(x^5-3^5)(x^7-4^7)...$ – Casey Chu Feb 16 '14 at 9:13
Finding the roots of giant polynomials seems like a terrible way of plotting these points - rootfinding routines will only give approximations unless your CA system is smart enough to recognize the exact factorization, and these approximations are notoriously inaccurate near linearly-dependent roots (which these are). Alpha does okay with it because it's smart enough to find the roots of each factor individually, but for more than a handful of rings this is pretty messy. – Steven Stadnicki Feb 16 '14 at 16:29
@StevenStadnicki I agree but Wolfram alpha is free but Mathematic is not. I could not think of any other way to do it in Wolfram. I don't think too many have access to expensive software such as Mathematica or Matlab outside the school. I am not sure how else to do it in Wolfram Alpha – user44197 Feb 16 '14 at 17:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.