Prime Phyllotaxis Spirals

March 18, 2012

The phyllotaxis spiral is one of the classical forms of mathematics, and there is a wonderland of resources available online both images and explanations. The basic idea is to put points round in a spiral with the same angle between each point. This gives a family of forms:

Note that, as the angle changes the dots sometimes pack in better than others, this can actually be studied and the best packing is related to the golden ratio. The points in this spiral are placed down in order, so we can associate each to a whole number:

Now when I see a lit of numbers like this, I want to pull out the primes, see what pattern they make:

There are some hints at patterns, lets expand out, and look just at dots:

There seem to be spiral arms which are richer in prime numbers than others. We can analyse things further by colouring each number depending on its prime factors. The more prime factors the lighter the number, giving the image for the start of this post:

Now there is a clear pattern, light and dark arms spiraling out. Can we understand this pattern?

Think about the construction of a phyllotaxis pattern we turn the same angle every time, that means within a particular pattern we can find other phyllotaxis patterns. The one at twice the speed, three times the speed and so on.  For example we could dive our pattern into two patterns each with twice the rotation angle. This gives:

All prime number (other than 2) are odd, so they must lie on the subspiral corresponding to the odd numbers. In addition it turns out that the spiral arms that we see are related to the Fibonacci numbers (themselves closely linked to the Golden Ratio). The particular curves we see relate to 144. Here is the spiral given by multiples of 144, pulling out just one such curve:

Note that in the prime factor picture this curve gives a very light line as every number in it is a multiple of 144, and 144 itself has 6 prime factors (three twice and two four times). Taking the multiples of 6 instead of 144 (which gives us several of these curves as 6 divides 144) we see another pattern of lines that are light in the image:

More importantly the curves next to these ones give numbers one more or less than a multiple of six. Every prime number has this form (all other numbers are multiples of 2 or 3 or both). This gives the curves of prime numbers we saw.

So by considering the construction of the initial image it begins to reveal its secrets. Yet, just as with the primes on their own there seems to be plenty of mystery left for investigation…


2+2 = 1? Patterns in Modular arithmetic

November 20, 2011

When someone is talking about the absolute truth of mathematics and declares that once you have defined 2 and +, then 2+2 must equal 4, there is a slightly glib response:

but 2+2 = 1…Mod 3

Despite this surprise, we actually all use modular arithmetic regularly, quite literally on a daily basis. When we consider six hours after 8am, the answer is not 14, but 2pm. Well you could argue for using a 24 hour clock, but no one would claim that 3am on a Tuesday morning is really 27:00 on Monday (well apparently some do, thanks to kuromagi on reddit for ref) In these cases we are not counting as we usually do, but counting on a circle mod 12 or 24. It is not hard to see that we could do this with other numbers. if we do decide that 2+1 is 0, and not 3 we are now working mod 3. In this case 2+2 is 1, as is 2*2. We can put together a small table:

+ 0 1 2
0 0 1 2
1 1 2 0
2 2 0 1

Showing what happens when the values for the column and row are added together. We can make the same table for multiplication:

x 0 1 2
0 0 0 0
1 0 1 2
2 0 2 1

I have to admit these table are a little boring, we can make things more interesting by replacing the numbers by colours. As we are working with modular arithmetic we know that the range of numbers we will come across, lies between 0 and the value we are using for modulus, so we can map these onto some circle of colours. So work mod 151 we get a new table for addition:

Using the same system of colours we can do the same thing for multiplication:

Which is starting to get interesting. We do not need to stop there, we can produce an image where the row number is taken to the power of the column:

This looks a little jumbled, in fact it seems to have very little structure at all. This is not very useful if our goal is to make pretty images, and on this blog that is normally the goal, but it other areas it turns out to be incredibly useful. The process of modular exponentiation is an essential part of public key cryptography, one of the technologies that allows secure communication over the internet. The jumble and lack of pattern that we can see is a sign that modular exponentiation is a good method to use to jumble things up. if there were structure that could be used to help decrypt the messages!

Returning to images, lets make a big version of the multiplication image, mod 1583 (you need to click it to get the full effect, scaling the image down blurs out a lot of structure):

Another option is to make an animation. what happens as we move the modulus value:

There is plenty to study in these images, for example, the curves that can be seen are approximately hyperbolae as they occur when x*y is some fixed value. The central star point occurs in the middle of the image, and there are further stars at 1/3, 2/3, 1/4, 3/4 etc. Can you work out why?

The appearance of hyperbolae perhaps implies that other curves might be possible. What happens if we consider x^2 + y^2? An obvious guess from this formula would be circles and we indeed get (for 151):

Playing around a little further this image comes from x^2 - y^2 +3 x y:

These images are certainly worth repeating for 1583 (again the details get blurred out, so click the images to see the full detail):

To finish let us consider something even simpler. Taking the value of a square to be \frac{x \mod y}{y} this will always give a value between 0 and 1. We can then colour again, and animate with \frac{x \mod Q y}{y} and Q going from 5 to 0:

I first came across these patterns in the December Issue of notices of the AMS, I have always been surprised how little they have been explored. This post is my attempt to do a little to correct that.


Hyperboloid lighting

November 6, 2011

The hyperboloid of one sheet is a fascinating shape that turns up in many places. It was therefore a great example to take for a test of thearender which I recently purchased. This shows off its double ruled nature:


CAMel

September 29, 2011

CAMel is a project to develop Rhino Grasshopper components for CAM (Computer Aided Manufacturing). Hence the silly name. It is very much work in progress, but if you are brave enough, here is a first release. All images and the video on this page are of a machine running GCode generated by CAMel.

Download CAMel 0.12
Download Rhino file (only needed if you want to see the example setup).

At present the components are just clusters with scripted components written within Grasshopper. The next major step will be to convert this into a proper grasshopper plug-in. This release has a grasshopper component with some documentation (there is a little more inside the clusters). All the code is CC-BY-SA licensed, and of course it should be noted that this is very much “use at your own risk”! My belief is that Grasshopper provides a natural environment to experiment with creating your own toolpaths. The purpose of CAMel is to make this process as easy as possible by giving the tools to convert simple toolpath ideas into usable paths and then exporting the GCode that will drive a machine.

The main components are as follows:

  • GCode Writer: Converts lists of points, vectors and feed rates into GCode for the machine.
  • GCode Checker: Reads GCode and checks and optimises it. For example a 5-axis machine can usually obtain any tool angle in two different ways. This selects the better angle. It will also give warnings of undesirable behavior in the GCode.
  • Surfacing: Creates a toolpath to cut an arbitrary surface (very rough version, designed to test others)
  • Swarf cutting: Creates toolpath from information about the movement of the tip of the tool and the point in which the tool enters the surface. For a 5-axis machine these paths can be quite different.

The code is currently set up for a single machine, I am happy to try to help adapt it to other machines (other commitments allowing) so get in touch if you are interested.

These components and code were developed with Santiago R Perez 21st Century Chair of Integrated Practice at the Fay Jones School of Architecture, University of Arkansas. I work in the Mathematics Department at the same university.

Earlier experiments with swarf cutting.


Follow

Get every new post delivered to your Inbox.

Join 213 other followers