Thursday, October 13, 2016

some familiar spirals in Desmos

I am revisiting some favorite spirals, plotting them in Desmos - for each below, try following the link to play with the graph yourself.

start with a circle

The basic approach to drawing these spirals (and other things, like these curves), is to start with a circle defined using parametric equations. (graph here)


By playing with this simple equation, often by just adjusting the r and t values, we can make a number of spirals. In many cases we are going to make spirals out of points, so we'll just be replacing r and t with integer sequences.

Phyllotaxis-ish spirals

These spirals are easy to create, and are a perennial favorite (pun intended: the sunflower connection). I've plotted these in Fathom/Tinkerplots, Processing, and more recently in R (its not only for stats, just mostly). If you haven't plotted these yet in your favorite graphical programming environment, you should.

The Desmos version animates nicely - you can grow and shrink the spiral, and play with the angle at the same time.

Some phyllotaxis-like spirals (graph here)

To create these, take the basic equation mentioned with this definition for the two sequences



Quadratic number spirals
I first saw quadratic number spirals at numberspiral.com. A quadratic spiral also fits into the basic spiral form mentioned above (graph here)/


It doesn't look much like a spiral, but you can see that it is when you connect the dots.

plain ol' quadratic spiral (graph here)

With every element in the sequences included, this spiral does not look so interesting. But we can "plot" another integer sequence on top of the spiral, some interesting patterns can emerge.


Primes on quadratic number spiral
numberspiral.com discusses the interesting patterns that seem to show up when you plot the prime numbers on the number spiral. You get an effect similar to the better-known Ulam spiral - the primes seem to cluster and line up along certain trajectories. What you are really seeing are certain prime producing quadratics, not a set of patterns that holds generally for primes. (Other number spiral fun here).

In Desmos, you can paste in a list of primes and plot them nicely on the spiral. I went up to 201 primes:

p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229]

We take these and insert them into our existing quadratic spiral formula.

And get this sequence (in blue) shown on top of the full quadratic spiral (graph here).


Can you see those intriguing looking lines of points where the primes seem to line up?

Polygonal numbers on quadratic numbers spiral

If you can plot primes on the number spiral, why not other sequences? A nice family of sequences are the polygonal numbers. You've heard of square numbers (1, 4, 9, ...)? Well, there are triangular, pentagonal, hexagonal, and others, and each number in those sequences can be arranged in a particular way to look like the polygon for which the sequence is named. It's true. One way to define the k-polygonal numbers is:


Those lines above make two interesting statements about polygonal numbers. First, any polygonal number can be broken up into triangular numbers (one big n-sized triangular number, and k-3 smaller triangular numbers). Second, triangular numbers correspond to the second column of Pascal's triangle. Two neat things.

A while back I plotted various polygonal numbers on quadratic spirals. Each type of polygonal number has its own characteristic spiral pattern. Redoing it in Desmos, I took advantage of the combinations function to generate polygonal numbers, and then plot them on the number spiral. To connect the dots, I have found it necessary to convert the plot to a table. Here we have the triangular numbers (= 3):

triangular number spiral (graph here)

This is just from composing the polygonal number formula with the quadratic spiral formula:

Choosing different values for k gives you different polygonal numbers, and different spirals. For k =12 we get the spiral below:
dodecagon number spiral (graph here)


Archimedean spiral
If this post had a logical order, the Archimedian spiral should have probably led off the list.

Archimedian spiral (graph here)

If you are going to try plotting these, you may want to try the variations on the Archimedian spiral mentioned on the wikipedia page.

Logarithmic spiral
Of all the spirals on this page, the one most likely to end up on the "tattoo ideas" pinterest board is the logarithmic spiral. Again, it is a variation on the basic formula:

Logarithmic spiral (graph here)


Euler spirals
Let's finish with something weird. Our last spiral of the day will be a family of spirally things known as Euler spirals. An earlier post that describes these spirals is here.

Like the "brain and propeller" curves from this post, these are also based on the parametric equation of a circle, but not in the same way as the curves listed above. In other software, I had drawn these using a recursive formula. Since I don't know how (if?) this can be done in Desmos, a non-recursive formula was required. For both m and d positive real numbers, we define x and y for each n:


The results are very sensitive to the choice for d, and give a menagerie of beasties:

A Euler spiral (graph here)

And some that look like coils of rope, thanks to the overlapping dots:

Eulerian Coils (graph here)


As for the polygonal number spirals above, to connect the dots, I found that I had to choose a particular set value for the plotted points, convert them to a table, and then connect them.

Update: I have since learned how to connect the dots in Desmos, see this post for details.

No comments:

Post a Comment