Back to Frac’

Here’s a second serendipitous fractal:

A serendipitous fractal on a fract-L


It looks like (and is related to) the limestone fractal and I found it similarly serendipitously. This time I was looking at continued fractions, a simple yet subtle and seductive way of representing non-integer numbers like 2/3 and 7/9 (or √2 and π). To generate a continued fraction from a/b < 1, you divide a/b into 1 and take away the integer part. Then you repeat with the remainder until nothing is left (or, as with irrationals like 1/√2 and 1/π, you've calculated long enough for your needs). The integers at each stage are the numbers of the continued fraction. Here is the working for contfrac(2/3), the continued fraction of 2/3:

int(1/(2/3)) = int(3/2) = int(1.5) = 1
3/2 – 1 = 1/2
int(1/(1/2)) = int(2) = 2
2 – 2 = 0

contfrac(2/3) = 1, 2

By working backwards with (1, 2), you can use the continued fraction to reconstruct the original number a/b. Start with a/b = 0/1:

1 / (0/1 + 2) = 1 / ((0+2*1)/2) = 1 / (2/1) = 1/2
1 / (1/2 + 1) = 1 / ((1+2*1)/2) = 1 / (3/2) = 2/3

And here’s the working for contfrac(7/9), the continued fraction of 7/9:

int(1/(7/9)) = int(9/7) = int(1.285714…) = 1
9/7 – 1 = 2/7
int(1/(2/7)) = int(7/2) = int(3.5) = 3
7/2 – 3 = 1/2
int(1/(1/2)) = int(2) = 2
2 – 2 = 0

contfrac(7/9) = 1, 3, 2

And here’s the reconstruction of 7/9 from its continued fraction, starting again with a/b = 0/1:

1 / (0/1 + 2) = 1 / ((0+2*1)/2) = 1 / (2/1) = 1/2
1 / (1/2 + 3) = 1 / ((1+2*3)/2) = 1 / (7/2) = 2/7
1 / (2/7 + 1) = 1 / ((2+7*1)/7) = 1 / (9/7) = 7/9

From that simple algorithm arise subtle and seductive things. Look at some continued fractions, cf(a/b), for a/b in simplest form (giving only the first few reciprocals, 1/b, because cf(1/b) = b). Interesting patterns appear, e.g. when a/b uses adjacent or nearly adjacent Fibonacci numbers:

cf(1/3) = 3 = cf(0.333333333…)
cf(2/3) = 1,2 = cf(0.666666666…)
cf(1/4) = 4 = cf(0.25)
cf(3/4) = 1,3 = cf(0.75)
cf(1/5) = 5 = cf(0.2)
cf(2/5) = 2,2 = cf(0.4)
cf(3/5) = 1,1,2 = cf(0.6)
cf(4/5) = 1,4 = cf(0.8)
cf(5/6) = 1,5 = cf(0.833333333…)
cf(2/7) = 3,2 = cf(0.285714285…)
cf(3/7) = 2,3 = cf(0.428571428…)
cf(4/7) = 1,1,3 = cf(0.571428571…)
cf(5/7) = 1,2,2 = cf(0.714285714…)
cf(6/7) = 1,6 = cf(0.857142857…)
cf(3/8) = 2,1,2 = cf(0.375)
cf(5/8) = 1,1,1,2 = cf(0.625)
cf(7/8) = 1,7 = cf(0.875)
cf(2/9) = 4,2 = cf(0.222222222…)
cf(4/9) = 2,4 = cf(0.444444444…)
cf(5/9) = 1,1,4 = cf(0.555555555…)
cf(7/9) = 1,3,2 = cf(0.777777777…)
cf(8/9) = 1,8 = cf(0.888888888…)
cf(3/10) = 3,3 = cf(0.3)
cf(7/10) = 1,2,3 = cf(0.7)
cf(9/10) = 1,9 = cf(0.9)
cf(2/11) = 5,2 = cf(0.181818181…)
cf(3/11) = 3,1,2 = cf(0.272727272…)
cf(4/11) = 2,1,3 = cf(0.363636363…)
cf(5/11) = 2,5 = cf(0.454545454…)
cf(6/11) = 1,1,5 = cf(0.545454545…)
cf(7/11) = 1,1,1,3 = cf(0.636363636…)
cf(8/11) = 1,2,1,2 = cf(0.727272727…)
cf(9/11) = 1,4,2 = cf(0.818181818…)
cf(10/11) = 1,10 = cf(0.909090909…)
cf(5/12) = 2,2,2 = cf(0.416666666…)
cf(7/12) = 1,1,2,2 = cf(0.583333333…)
cf(11/12) = 1,11 = cf(0.916666666…)
cf(2/13) = 6,2 = cf(0.153846153…)
cf(3/13) = 4,3 = cf(0.230769230…)
cf(4/13) = 3,4 = cf(0.307692307…)
cf(5/13) = 2,1,1,2 = cf(0.384615384…)
cf(6/13) = 2,6 = cf(0.461538461…)
cf(7/13) = 1,1,6 = cf(0.538461538…)
cf(8/13) = 1,1,1,1,2 = cf(0.615384615…)
cf(9/13) = 1,2,4 = cf(0.692307692…)
cf(10/13) = 1,3,3 = cf(0.769230769…)
cf(11/13) = 1,5,2 = cf(0.846153846…)
cf(12/13) = 1,12 = cf(0.923076923…)
cf(3/14) = 4,1,2 = cf(0.214285714…)
cf(5/14) = 2,1,4 = cf(0.357142857…)
cf(9/14) = 1,1,1,4 = cf(0.642857142…)
cf(11/14) = 1,3,1,2 = cf(0.785714285…)
cf(13/14) = 1,13 = cf(0.928571428…)
cf(2/15) = 7,2 = cf(0.133333333…)
cf(4/15) = 3,1,3 = cf(0.266666666…)
cf(7/15) = 2,7 = cf(0.466666666…)
cf(8/15) = 1,1,7 = cf(0.533333333…)
cf(11/15) = 1,2,1,3 = cf(0.733333333…)
cf(13/15) = 1,6,2 = cf(0.866666666…)
cf(14/15) = 1,14 = cf(0.933333333…)
cf(3/16) = 5,3 = cf(0.1875)
cf(5/16) = 3,5 = cf(0.3125)
cf(7/16) = 2,3,2 = cf(0.4375)

After investigating some of those patterns, I wondered what happened when you reversed the continued fraction cf(a/b) and used those reversed numbers backward (that is, used the numbers of cf(a/b) forward) to generate another and different a/b. And a/b will always be different unless cf(a/b) is a palindrome, like cf(5/12) = 2,2,2 or cf(5/13) = 2,1,1,2 or cf(4/15) = 3,1,3. Note that a continued fraction never ends in 1, so that when reversing, say, cf(5/8) = (1, 1, 1, 2), you need an adjustment from (2, 1, 1, 1) to (2, 1, 1+1) = (2, 1, 2). Here’s a little of what happens when you reverse cf(a1/b1) to generate a2/b2:

cf(1/2) = 2 → 2 = cf(1/2)
1/2 = 0.5 : 0.5 = 1/2
cf(1/3) = 3 → 3 = cf(1/3)
1/3 = 0.333333333 : 0.333333333 = 1/3
cf(2/3) = 1, 2 → 2, 1 → 3 = cf(1/3)
2/3 = 0.666666666 : 0.333333333 = 1/3
cf(3/4) = 1, 3 → 3, 1 → 4 = cf(1/4)
3/4 = 0.75 : 0.25 = 1/4
cf(2/5) = 2, 2 → 2, 2 = cf(2/5)
2/5 = 0.4 : 0.4 = 2/5
cf(3/5) = 1, 1, 2 → 2, 1, 1 → 2, 2 = cf(2/5)
3/5 = 0.6 : 0.4 = 2/5
cf(4/5) = 1, 4 → 4, 1 → 5 = cf(1/5)
4/5 = 0.8 : 0.2 = 1/5
cf(5/6) = 1, 5 → 5, 1 → 6 = cf(1/6)
5/6 = 0.833333333 : 0.166666666 = 1/6
cf(2/7) = 3, 2 → 2, 3 = cf(3/7)
2/7 = 0.285714286 : 0.428571428 = 3/7
cf(3/7) = 2, 3 → 3, 2 = cf(2/7)
3/7 = 0.428571429 : 0.285714286 = 2/7
cf(4/7) = 1, 1, 3 → 3, 1, 1 → 3, 2 = cf(2/7)
4/7 = 0.571428571 : 0.285714286 = 2/7
cf(5/7) = 1, 2, 2 → 2, 2, 1 → 2, 3 = cf(3/7)
5/7 = 0.714285714 : 0.428571429 = 3/7
cf(6/7) = 1, 6 → 6, 1 → 7 = cf(1/7)
6/7 = 0.857142857 : 0.142857143 = 1/7
cf(3/8) = 2, 1, 2 → 2, 1, 2 = cf(3/8)
0.375 : 0.375
cf(5/8) = 1, 1, 1, 2 → 2, 1, 1, 1 → 2, 1, 2 = cf(3/8)
0.625 : 0.375
cf(7/8) = 1, 7 → 7, 1 → 8 = cf(1/8)
0.875 : 0.125
cf(2/9) = 4, 2 → 2, 4 = cf(4/9)
0.222222222 : 0.444444444
cf(4/9) = 2, 4 → 4, 2 = cf(2/9)
0.444444444 : 0.222222222

And if you plot x = a1/b1 and y = (a2/b2 * 2) on a fract-L, that is, a graph whose horizontal and vertical arms represent 0 to 1, you get the fractal right at the beginning:

Fract-L for x = a1/b1 and y = (a2/b2 * 2), where a2/b2 is generated from reversed(cf(a1/b1))


You need to use (a2/b2 * 2) because a2/b2 from reversed(cf(a1/b1)) is always <= 0.5, so using raw a2/b2 generates this graph:

Fract-L for x = a1/b1 and y = a2/b2 (i.e. a2/b2 is unadjusted)


Why is it always true that a2/b2 <= 0.5? For two reasons. First, a/b > 0.5 always generate continued fractions that start with 1, like cf(2/3) = 1, 2 or cf(3/4) = 1, 3 or cf(3/5) = 1, 1, 2. Second, as previously mentioned, no continued fraction ends with 1. Therefore a reversed cf(a1/b1), where the final number, n > 1, moves to the beginning, will never begin with 1 and the a2/b2 generated from reversed(cf(a1/b1)) will always be less than 0.5 (or equal to it in the solitary case of cf(1/2) = 2).

Now let's look at the development of the fractal as a1/b1 uses larger and larger denominators:

Fract-L for x = a1/b1 and y = (a2/b2 * 2) for a1/b1 <= 6/7


Fract-L for for a1/b1 <= 14/15


Fract-L for a1/b1 <= 30/31


Fract-L for a1/b1 <= 62/63


Fract-L for a1/b1 <= 126/127


Fract-L for a1/b1 <= 254/255


Fract-L for a1/b1 <= 357/358


Fract-L for a1/b1 <= 467/468


Animated fract-L for x = a1/b1 and y = (a2/b2 * 2) (animated at ezGif)


The fractal changes subtly when you restrict the b1 of a1/b1 in some way, say using multiples of 2, 3, 4, 5…:

Fract-L for x = a1/b1 and y = (a2/b2 * 2) for b1 = n = 2, 3, 4, 5, 6, 7, 8…


Fract-L for b1 = 2n = 2, 4, 6, 8, 10…


Fract-L for b1 = 3n = 3, 6, 9, 12, 15…


Fract-L for b1 = 4n


Fract-L for b1 = 5n


Fract-L for b1 = 6n


Animated fract-L for b1 = 1n..12n (animated at ezGif)


Finally, here are fract-Ls when b1 is a triangular, square, hexagonal or octagonal number:

Fract-L for x = a1/b1 and y = (a2/b2 * 2) for triangular(b1) = 3, 6, 10, 15, 21, 28,…


Fract-L for square(b1) = 4, 9, 16, 25, 36, 49,…


Fract-L for hexagonal(b1) = 6, 15, 28, 45, 66, 91,…


Fract-L for octagonal(b1) = 8, 21, 40, 65, 96, 133,…


Elsewhere Other-Accessible…

Back to Drac’ — a parallel pun for a pre-previous fractal
I Like Gryke — a first look at the limestone fractal
Lime Time — more on the limestone fractal

Fractional Fractal Fract-Ls

This is the surpassingly special Stern-Brocot sequence:

0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, 2, 5, 3, 4, 1, 5, 4, 7, 3, 8, 5, 7, 2, 7, 5, 8, 3, 7, 4, 5, 1, 6, 5, 9, 4, 11, 7, 10, 3, 11, 8, 13, 5, 12, 7, 9, 2, 9, 7, 12, 5, 13, 8, 11, 3, 10, 7, 11, 4, 9, 5, 6, 1, 7, 6, 11, 5, 14, 9, 13, 4, 15, 11, 18, 7, 17, 10, 13, 3, 14, 11, 19, 8, 21, 13, 18, 5, 17, 12, 19, … (A002487 at the Online Encyclopedia of Integer Sequences)


And why is the sequence special? Because if you take successive pairs of the apparently arbitrarily varying numbers, you get every rational fraction in its simplest form exactly once. So 1/2, 2/3, 6/11 and 502/787 appear once and then never again. And so do 2/1, 3/2, 11/6 and 787/502. Et cetera, ad infinitum. If you map the Stern-Brocot sequence against the related Calkin-Wilk sequence, which has the same “all-simplest-fractions-exactly-once” properties, you can create this fractal, which I call a limestone fractal or gryke fractal:

Gryke fractal by mapping Stern-Brocot sequence against Calkin-Wilf sequence


The graph is what I call a Fract-L, because the lines for the x,y coordinates create an L. Each coordinate runs from 0 to 1, with the x set by the fraction from the Stern-Brocot sequence and the y set by the fraction from the Calkin-Wilf sequence (if a > b in a/b, use the conversion 1/(a/b) = b/a). But you can also find interesting patterns by mapping the Stern-Brocot sequence against itself. That is, you use two Stern-Brocot sequences that start in different places. Now, there are complicated ways to create the Stern-Brocot sequence using mathematical trees and sequential algorithms and so on. But there’s also an astonishingly simple way, a formula created by the Israeli mathematician Moshe Newman. If (a,b) is one pair of successive numbers in the sequence, the next pair (a,b) is found like this:

c = b
b = (2 * int(a/b) + 1) * b – a
a = c

This means that you can seed a Stern-Brocot sequence with any (correctly simplified) a/b and it will continue in the right way. If the two SB-sequences for x and y are both seeded with (0,1), you get this 45° line, because each successive a/b for (x,y) is identical:

Stern-Brocot pairs seeded with x ← (0,1) and y ← (0,1)


The further you extend the sequences, the less broken the 45° line will appear, because the points determined by a/b for x and y will get closer and closer together (but the line will never be solid, because any two rationals are separated by an infinity of irrationals). Now try offsetting the SB-sequences for x,y by using different seeds. Different fractal patterns appear, which all appear to be subsets (or fractions) of the limestone fractal above (see animated gif below):

Stern-Brocot pairs seeded with x ← (0,1) and y ← (1,1)


x ← (0,1) and y ← (1,2)


x ← (0,1) and y ← (1,3)


x ← (0,1) and y ← (2,3)


x ← (0,1) and y ← (3,4)


x ← (0,1) and y ← (6,7)


x ← (1,2) and y ← (1,9)


x ← (1,4) and y ← (1,6)


x ← (1,7) and y ← (1,8)


x ← (2,3) and y ← (4,5) — apparently identical to x ← (1,4) and y ← (1,6) above


x ← (26,25) and y ← (1,10)


Gryke fractal compared with Stern-Brocot-pair patterns (animated at ezGif)


And here’s what happens when the seed-fractions for x run from 1/3 to 12/13, while the seed-fraction for y is held constant at 1/23:

x ← (1,13) and y ← (1,23)


x ← (2,13) and y ← (1,23)


x ← (3,13) and y ← (1,23)


x ← (4,13) and y ← (1,23)


x ← (5,13) and y ← (1,23)


x ← (6,13) and y ← (1,23)


x ← (7,13) and y ← (1,23)


x ← (8,13) and y ← (1,23)


x ← (9,13) and y ← (1,23)


x ← (10,13) and y ← (1,23)


x ← (11,13) and y ← (1,23)


x ← (12,13) and y ← (1,23)


Animated gif for x ← (n,13) and y ← (1,23) (animated at ezGif)


Previously Pre-Posted

I Like Gryke — a first look at the limestone fractal
Lime Time — more on the fractal

The Wyrm Ferns

A fern is a fractal, a shape that contains copies of itself at smaller and smaller scales. That is, part of a fern looks like the fern as a whole:

Fern as fractal (source)


Millions of years after Mother Nature, man got in on the fract, as it were:

The Sierpiński triangle, a 2d fractal


The Sierpiński triangle is a fractal created in two dimensions by a point jumping halfway towards one or another of the three vertices of a triangle. And here is a fractal created in one dimension by a point jumping halfway towards one or another of the two ends of a line:

A 1d fractal


In one dimension, the fractality of the fractal isn’t obvious. But you can try draggin’ out (or dragon out) the fractality of the fractal by ferning the wyrm, as it were. Suppose that after the point jumps halfway towards one or another of the two points, it’s rotated by some angle around the midpoint of the two original points. When you do that, the fractal becomes more and more obvious. In fact, it becomes what’s called a dragon curve (in Old English, “dragon” was wyrm or worm):

Fractal with angle = 5°


Fractal 10°


Fractal 15°


Fractal 20°


Fractal 25°


Fractal 30°


Fractal 35°


Fractal 40°


Fractal 45°


Fractal 50°


Fractal 55°


Fractal 60°


Fractal 0° to 60° (animated at ezGif)


But as the angle gets bigger, an interesting aesthetic question arises. When is the ferned wyrm, the dragon curve, at its most attractive? I’d say it’s when angle ≈ 55°:

Fractal 50°


Fractal 51°


Fractal 52°


Fractal 53°


Fractal 54°


Fractal 55°


Fractal 56°


Fractal 57°


Fractal 58°


Fractal 59°


Fractal 60°


Fractal 50° to 60° (animated)


At angle >= 57°, I think the dragon curve starts to look like some species of bristleworm, which are interesting but unattractive marine worms:

A bristleworm, Nereis virens (see polychaete at Wikipedia)


Finally, here’s what the ferned wyrm looks like in black-and-white and when it’s rotating:

Fractal 0° to 60° (b&w, animated)


Fractal 56° (rotating)


Fractal 56° (b&w, rotating)


Double fractal 56° (b&w, rotating)


Previously Pre-Posted (Please Peruse)…

Curvous Energy — a first look at dragon curves
Back to Drac’ — another look at dragon curves

Scout the Routes

Triangles? Yes. Squares? No. If you scout the routes with a triangle, you get a beautiful fractal. If you scout the routes with a square, you don’t. Here’s what you get with a triangle:

A Sierpiński triangle


But how do you scout the routes? (That phrase works best in the American dialects where “scout” rhymes with “route”.) Simple: you mark the final positions reached when a point traces all possible ways of jumping, say, eight times 1/2-way towards the vertices of a polygon. Here’s an animation of a point scouting the routes of eight jumps towards the vertices of a triangle (it starts each time at the center):

Creating a Sierpiński triangle by scouting the routes (animated at Ezgif)


If you scout the routes with a square, you don’t get a fractal. Instead, the interior of the square fills evenly (and boringly) with the end-points of the routes:

Scouting the routes with a square (animated at Ezgif)


But you can create fractals with a square if you out routes as you scout routes. That is, if you exclude some routes and don’t mark their end-points. One way to do this is to compare the proposed next jump-vertex (vertex-jumped-towards) with the previous jump-vertex. For example, if the proposed jump-vertex, jv[t], is the same as the previous jump-vertex, jv[t-1], you don’t jump towards jv[t] or you jump towards it in a different way. The test is jv[t] = jv[t-1] + vi. If vi = 0 and you jump towards the clockwise neighbor of jv when the test is true, you get a fractal looking like this:

vi = 0, action = jv → jv + 1


Here’s the fractal if you jump towards the clockwise-neighbor-but-one when the test is true:

vi = 0, action = jv + 2


Now try varying the vi of the jv[t-1] + vi:

vi = 2, action = jv + 2


vi = 2, action = jv + 1


vi = 3, action = jv + 1


Or what about jumping in a different way towards jv when the test is true? If you jump 2/3 of the way rather 1/2, you get his fractal:

vi = 2, action = jump 2/3


And if you jump 4/3 of the way (i.e., you overshoot the vertex jv), you get this fractal:

vi = 0, action = jump 4/3rds to vertex


vi = 0, jump 4/3 (guide-square removed)


vi = 2, jump 4/3rds (guide-square removed)


And in this fractal the point jumps 2/3 of the way to the center of the square when the test is true:

vi = 2, action = jump 2/3rds of way to center of square


But why apply only one test to jv[1] and use only when one alternative jump? If jv[t] = jv[t-1] + 1 or jv[t] = jv[t-1] + 3, jv[t] becomes jv[t]+1 or jv[t]+3, respectively, you get this fractal:

vi = 1, jv + 1; vi = 3, jv + 3


Here are more fractals created by single and double tests:

vi = 1, jv + 1


vi = 0, jump 2/3


vi = 0, jump towards center 2/3rds


vi = 1, jump-center 2/3


vi = 2, jump 1/3; vi = 3, jump 1/1 (i.e, 1)


vi = 0, jv + 2; vi = 2, jump-center 1/2


vi = 0, jv + 2; vi = 2, jump-center 2/3


vi = 0, jv + 2; vi = 2, jump-center 4/3


vi = 0, jv + 1; vi = 2, jump 2/3


vi = 0, jv + 2; vi = 2, jump 2/3


vi = 0, jump 4/3; vi = 2, jv + 2


vi = 0, jump 2/3; vi = 2, jv + 1


vi = 0, jump 4/3; vi = 1, jv + 2


vi = 0, jump 2/3; vi = 2, jump 1/3


vi =0, jump 1/3; vi = 2, jump 2/3


vi = 0, jump 0/1 (i.e, 0); vi = 2, jump 1/3


Partitional Pulchritude

If you want a good example of how, in math, something very simple can quickly get very deep, just look at partitions. Here are the partitions of 1 to 5, that is, the ways 1 to 5 can be expressed as a sum of integers smaller than or equal to themselves:

1 = 1

numbpart(1) = 1


2 = 2
1 + 1 = 2

numbpart(2) = 2


3 = 3
1 + 2 = 3
1 + 1 + 1 = 3

numbpart(3) = 3


4 = 4
1 + 3 = 4
2 + 2 = 4
1 + 1 + 2 = 4
1 + 1 + 1 + 1 = 4

numbpart(4) = 5


5 = 5
1 + 4 = 5
2 + 3 = 5
1 + 1 + 3 = 5
1 + 2 + 2 = 5
1 + 1 + 1 + 2 = 5
1 + 1 + 1 + 1 + 1 = 5

numbpart(5) = 7


It’s very easy to understand the concept of partitions, but very difficult to understand how partitions behave. For example, here is numbpart(n), the count of partitions for 1, 2, 3,…

1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231, 297, 385, 490, 627, 792, 1002, 1255, 1575, 1958, 2436, 3010, 3718, 4565, 5604, 6842, 8349, 10143, 12310, 14883, 17977, 21637, 26015, 31185, 37338, 44583, 53174, 63261, 75175, 89134, 105558, 124754, 147273, 173525, 204226, … A000041 at the Online Encyclopedia of Integer Sequences, “a(n) is the number of partitions of n (the partition numbers)”

What’s the formula for numbpart(n)? That’s a tricky question. And what’s the formula for the curves produced by counting the various lengths of partitions(n)? That’s another tricky question, but one thing is easy to see. As n gets bigger, the graph of countlen(partitions(n)) acquires a strange, lopsided beauty. Here are the partitions of 8, with the count of how many partitions of a particular length there are:

8 = 8 (1 partition of length 1)
1 + 7 = 8
2 + 6 = 8
3 + 5 = 8
4 + 4 = 8 (4 partitions of length 2)
1 + 1 + 6 = 8
1 + 2 + 5 = 8
1 + 3 + 4 = 8
2 + 2 + 4 = 8
2 + 3 + 3 = 8 (5 of length 3)
1 + 1 + 1 + 5 = 8
1 + 1 + 2 + 4 = 8
1 + 1 + 3 + 3 = 8
1 + 2 + 2 + 3 = 8
2 + 2 + 2 + 2 = 8 (5 of length 4)
1 + 1 + 1 + 1 + 4 = 8
1 + 1 + 1 + 2 + 3 = 8
1 + 1 + 2 + 2 + 2 = 8 (3 of length 5)
1 + 1 + 1 + 1 + 1 + 3 = 8
1 + 1 + 1 + 1 + 2 + 2 = 8 (2 of length 6)
1 + 1 + 1 + 1 + 1 + 1 + 2 = 8 (1 of length 7)
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 8 (1 of length 8)

When counts like that are shown as a graph, the graphs look like this (maximum counts are normalized to the same height):


graph of countlen(partitions(2))



countlen(partitions(3))



countlen(partitions(4))



countlen(partitions(5))



countlen(partitions(6))



countlen(partitions(7))



countlen(partitions(8))



countlen(partitions(9))



countlen(partitions(10))



countlen(partitions(15))



countlen(partitions(20))



countlen(partitions(30))



countlen(partitions(40))



countlen(partitions(50))



countlen(partitions(60))



countlen(partitions(70))



countlen(partitions(80))



countlen(partitions(90))



countlen(partitions(100))



Animated gif of partlen graphs (courtesy EZgif)


The graphs have a long, low right tail because the counts rise to great heights very quick, then fall away again, as you can see with partitions(100):

1 = count(partitions(10),len=1)
50 = count(partitions(10),len=2)
833 = count(partitions(10),len=3)
7153 = count(partitions(10),len=4)
38225 = count(partitions(10),len=5)
143247 = count(partitions(10),len=6)

[…]

10643083 = count(partitions(10),len=16)
11022546 = count(partitions(10),len=17)
11087828 = count(partitions(10),len=18)
10885999 = count(partitions(10),len=19)
10474462 = count(partitions(10),len=20)

[…]

30 = count(partitions(10),len=91)
22 = count(partitions(10),len=92)
15 = count(partitions(10),len=93)
11 = count(partitions(10),len=94)
7 = count(partitions(10),len=95)
5 = count(partitions(10),len=96)
3 = count(partitions(10),len=97)
2 = count(partitions(10),len=98)
1 = count(partitions(10),len=99)
1 = count(partitions(10),len=100)

Deep-Dive Dyadendricity

This simple equation helps you understand a fractal:

1 + 1/2 + 1/4 + 1/8 + 1/16 + 1/32 + … = 2 = Σ(1/2k,k=0..∞)

Now here’s the construction of the H-tree fractal, in which the lines are divided in length by sqrt(2) = 1.41421356237… at each stage. Or multiplied by 0.70710678118… = &sqrt;0.5. This means that, after two divisions, the lines are 1/2 the size. So in the end they create a 1 x &sqrt;2 rectangle:

H-Tree fractal #1


H-Tree fractal #2


H-Tree fractal #3


H-Tree fractal #4


H-Tree fractal #5


H-Tree fractal #6


H-Tree fractal #7


H-Tree fractal #8


H-Tree fractal #9


H-Tree fractal #10


[…]

H-Tree fractal #13


H-Tree fractal #14


H-Tree fractal #15


Here’s an animation:

H-Tree fractal (animated at EZgif)


And here’s the H-tree in black-and-white:

H-Tree fractal #3

H-Tree fractal #6

H-Tree fractal #6

H-Tree fractal #12

H-Tree fractal #15

H-Tree fractal (animated at EZgif)


Because the construction of the H-tree is governed by a string of directions — for example, left-right-right-left-left-left… or 211222… — you can perform tests on that string to create sub-fractals from the super-fractal. Like this:

count(1) = count(2) in string to step 12


count(1) = count(2) in string (omitting lines)


sum(string) = mul(string)


sum(string) > mul(string)


count(1) = 2 or count(2) = 2 after step 2


count(1) < count(2)


count(1) < 3 or count(2) < 3 after step 6


value of string after step 8 > value of string at step 1


value after step 8 > value at step 4


value after step 8 < value step 1


ispalindrome(string) to step 11


ispalindrome(string) to step 18


ispalindrome(string) to step 20


alternating 121… or 212… in string after step 9


ispolygonal(sum(string[i]-1),pol=10)


isprime(sum(string))


sum(string[i]-1) mod 13 = 0


sum(string[i]-1) mod 13 = 1


sum(string[i]-1) mod 16 = 0


sum(string[i]-1) mod 18 = 0


Message from Mater

As any recreational mathematician kno, the Ulam spiral shows the prime numbers on a spiral grid of integers. Here’s a Ulam spiral with 1 represented in blue and 2, 3, 5, 7… as white blocks spiralling anti-clockwise from the right of 1:

The Ulam spiral of prime numbers


Ulam spiral at higher resolution


I like the Ulam spiral and whenever I’m looking at new number sequences I like to Ulamize it, that is, display it on a spiral grid of integers. Sometimes the result looks good, sometimes it doesn’t. But I’ve always wondered something beforehand: will this be the spiral where I see a message appear? That is, will I see a message from Mater Mathematica, Mother Maths, the omniregnant goddess of mathematics? Is there an image or text embedded in some obscure number sequence, revealed when the sequence is Ulamized and proving that there’s divine intelligence and design behind the universe? Maybe the image of a pantocratic cat will appear. Or a text in Latin or Sanskrit or some other suitably century-sanctified language.

That’s what I wonder. I don’t wonder it seriously, of course, but I do wonder it. But until 22nd March 2025 I’d never seen any Ulam-ish spiral that looked remotely like a message. But 22nd May is the day I Ulamed some continued fractions. And I saw something that did look a little like a message. Like text, that is. But I might need to explain continued fractions first. What are they? They’re a fascinating and beautiful way of representing both rational and irrational numbers. The continued fractions for rational numbers look like this in expanded and compact format:

5/3 = 1 + 1/(1 + ½) = 1 + ⅔
5/3 = [1; 1, 2]

19/7 = 2 + 1/(1 + 1/(2 + ½)) = 2 + 4/7
19/7 = [2; 1, 2, 2]

2/3 = 0 + 1/(1 + 1/2)
2/3 = [0; 1, 2] (compare 5/3 above)

3/5 = 0 + 1/(1 + 1/(1 + 1/2))
3/5 = [0; 1, 1, 2]

5/7 = 0 + 1/(1 + 1/(2 + 1/2))
5/7 = [0; 1, 2, 2] (compare 19/7 above)

13/17 = 0 + 1/(1 + 1/(3 + 1/4))
13/17 = [0; 1, 3, 4]

30/67 = 0 + 1/(2 + 1/(4 + 1/(3 + ½)))
30/67 = [0; 2, 4, 3, 2]

The continued fractions of irrational numbers are different. Most importantly, they never end. For example, here are the infinite continued fractions for φ, √2 and π in expanded and compact format:

φ = 1 + (1/(1 + 1/(1 + 1/(1 + …)))φ = [1; 1]

√2 = 1 + (1/(2 + 1/(2 + 1/(2 + …)))
√2 = [1; 2]

π = 3 + 1/(7 + 1/(15 + 1/(1 + 1/(292 + 1/(1 + 1/(1 + 1/(1 + 1/(2 + 1/(1 + 1/(3 +…))))))))))
π = [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3…]

As you can see, the continued fraction of π doesn’t fall into a predictable pattern like those for φ and √2. But I’ve already gone into continued fractions further than I need for this post, so let’s return to the continued fractions of rationals. I set up an Ulam spiral to show patterns based on the continued fractions for 1/1, ½, ⅓, ⅔, 1/4, 2/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6, 2/6, 3/6… (where the fractions are assigned to 1,2,3… and 2/4 = ½, 2/6 = ⅓ etc). For example, if the continued fraction contains a number higher than 5, you get this spiral:

Spiral for continued fractions containing at least number > 5


With tests for higher and higher numbers in the continued fractions, the spirals start to thin and apparent symbols start to appear in the arms of the spirals:

Spiral for contfrac > 10


Spiral for contfrac > 15


Spiral for contfrac > 20


Spiral for contfrac > 25


Spiral for contfrac > 30


Spiral for contfrac > 35


Spiral for contfrac > 40


Spirals for contfrac > 5..40 (animated at EZgif)


Here are some more of these spirals at increasing magnification:

Spiral for contfrac > 23 (#1)


Spiral for contfrac > 23 (#2)


Spiral for contfrac > 23 (#3)


Spiral for contfrac > 13


Spiral for contfrac > 15 (off-center)


Spiral for contfrac > 23 (off-center)


And here are some of the symbols picked out in blue:

Spiral for contfrac > 15 (blue symbols)


Spiral for contfrac > 23 (blue symbols)


But they’re not really symbols, of course. They’re quasi-symbols, artefacts of the Ulamization of a simple test on continued fractions. Still, they’re the closest I’ve got so far to a message from Mater Mathematica.

Fract-L Geometry

Suppose you set up an L, i.e. a vertical and horizontal line, representing the x,y coordinates between 0 and 1. Next, find the fractional pairs x = 1/2, 1/3, 2/3, 1/4, 2/4…, y = 1/2, 1/3, 2/3, 1/4, 2/4… and mark the point (x,y). That is, find the point, say, 1/5 of the way along the x-line, then the points 1/5, 2/5, 3/5 and 4/5 along the y-line, marking the points (1/5, 1/5), (1/5, 2/5), (1/5, 3/5), (1/5, 4/5). Then find (2/5, 1/5), (2/5, 2/5), (2/5, 3/5), (2/5, 4/5) and so on. Some interesting patterns appear in what I call a Frac-L (pronounced “frackle”) or Fract-L:

Frac-L for 1/2 to 21/22


Frac-L for 1/2 to 48/49


Frac-L for 1/2 to 75/76


Frac-L for 1/2 to 102/103


Frac-L for 1/2 to 102/103 (animated)


If the (x,y) point is first red, then becomes different colors as it is repeatedly found, you get these patterns:

Frac-L for 1/2 to 48/49 (color)


Frac-L for 1/2 to 75/79 (color)


Frac-L for 1/2 to 102/103 (color) (animated)


Now try polygonal numbers. The triangular numbers are 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78…, so you’re finding the fractional pairs, say, (1/21, 1/21), (1/21, 3/21, (1/21, 6/21), (1/21, 10/21), (1/21, 15/21), then (3/21, 1/21), (3/21, 3/21, (3/21, 6/21), (3/21, 10/21), (3/21, 15/21), and so on:

Frac-L for triangular fractions


The frac-L for square numbers (1, 4, 9, 16, 25, 36, 49, 64, 81, 100…) is almost identical:

Frac-L for square fractions, e.g. (1/16, 1/16), (1/16, 4/16), (1/16, 9/16)…


So is the frac-L for pentagonal numbers (1, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176, 210, 247, 287, 330…):

Frac-L for pentagonal fractions, e.g. (1/35, 5/35), (1/35, 12/35), (1/35,22/35)…


Here are frac-Ls for tetrahedral and square-pyramidal numbers:

Frac-L for tetrahedral fractions


Frac-L for square pyramidal fractions


But what about prime numbers (skipping 2)? Here the fractional pairs are, say, (1/17, 1/17), (1/17, 3/17), (1/17, 5/17), (1/17, 7/17), (1/17, 11/17), (1/17, 13/17), then (3/17, 1/17), (3/17, 3/17), (3/17, 5/17), (3/17, 7/17), (3/17, 11/17), (3/17, 13/17), and so on:

Frac-L for 1/3 to 73/79 (prime fractions)


Frac-L for 1/3 to 223/227


Frac-L for 1/3 to 307/331


Frac-L for 1/3 to 307/331 (animated)


Frac-L for 1/3 to 73/79 (color) (prime fractions)


Frac-L for 1/3 to 223/227 (color)


Frac-L for 1/3 to 307/331 (color)


Frac-L for 1/3 to 307/331 (color) (animated)


And finally (for now), a frac-L for Fibonnaci numbers, where the fractional pairs are, say, (1/13, /13), (1/13, 2/13), (1/13, 3/13), (1/13, 5/13), (1/13, 8/13), then (2/13, /13), (2/13, 2/13), (2/13, 3/13), (2/13, 5/13), (2/13, 8/13), and so on:

Frac-L for Fibonacci fractions to 14930352/2178309 = fibonacci(36)/fibonacci(37)


Mods and Clockers

To understand clock-arithmetic, simply picture a clock-face with one hand and a big fat 0 in place of the 12. Now you can do some clock-arithmetic. For example, set the hour-hand to 5, then move on 4 hours. You’ve done this sum:

5 + 4 → 9

Now try 9 + 7. The hour-hand is already on 9, so move forward 7 hours:

9 + 7 → 4

Now try 3 + 8 + 1:

3 + 8 + 1 → 0

And 3 * 4:

4 * 3 = 4 + 4 + 4 → 0

That’s clock-arithmetic. But you’re not confined to 12-hour clocks. Here’s a 7-hour clock, where the 7 is replaced with a 0:

3 + 1 → 4
4 + 5 → 2
2 + 4 + 1 → 0
3 * 3 = 3 + 3 + 3 → 2

Another name for clock-arithmetic is modular arithmetic, because the clocks model the process of dividing a number by 12 or 7 and finding the remainder or residue — 12 or 7 is known as the modulus (and modulo is Latin for “by the modulus”).

5 + 4 = 9 → 9 / 12 = 0*12 + 9

(5 + 4) modulo 12 = 9


3 + 8 + 1 = 12 → 12 / 12 = 1*12 + 0

(3 + 8 + 1) modulo 12 = 0


19 / 12 = 1*12 + 7

19 mod 12 = 7


3 + 1 = 4 → 4 / 7 = 0*7 + 4

(3 + 1) mod 7 = 4


2 + 4 + 1 = 7 → 7 / 7 = 1*7 + 0

(2 + 4 + 1) mod 7 = 0


19 / 7 = 2*7 + 5

19 mod 7 = 5


Modular arithmetic can do wonderful things. One small but beautiful example is the way it can uncover hidden fractals in Pascal’s triangle:

Pascal’s Triangle (via Desmos)


How to create Pascal’s triangle (via Wikipedia)


If you color all numbers n mod 2 = 1 (i.e., odd numbers) in the triangle, they create the famous Sierpiński triangle:

The Sierpiński triangle in Pascal’s triangle (via Fractal Foundation)

Pascal’s triangle, n mod 2 = 1 (click for larger)


The Sierpiński triangle appears like this for all n mod 4 = 2 in Pascal’s triangle:

Pascal’s triangle, n mod 4 = 2 (click for larger)


And so on:

Pascal’s triangle, n mod 8 = 4


Pascal’s triangle, n mod 16 = 8


Pascal’s triangle, n mod 32 = 16


Pascal’s triangle, n mod 64 = 32


Pascal’s triangle, n mod 128 = 64


Pascal’s triangle, n mod 256 = 128


Pascal’s triangle, n mod 2,4,8… = 1,2,4… (animated via EzGif)


Post-Performative Post-Scriptum

There’s no need to calculate Pascal’s triangle in full to find the fractals above. The 10th row of Pascal’s triangle is this:

1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1

The 20th row is this:

1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1

And the 29th is this:

1, 29, 406, 3654, 23751, 118755, 475020, 1560780, 4292145, 10015005, 20030010, 34597290, 51895935, 67863915, 77558760, 77558760, 67863915, 51895935, 34597290, 20030010, 10015005, 4292145, 1560780, 475020, 118755, 23751, 3654, 406, 29, 1

But you don’t need to consider those ever-growing numbers in the triangle when you’re finding fractals with modular arithmetic. When the modulus is 2, you just work with 0 and 1, that is, you add the previous numbers in the triangle and find the sum modulo 2. When the modulus is 4, you just work with 0, 1, 2 and 3, adding the numbers and finding the sum modulo 4. When it’s 8, you just work with 0, 1, 2, 3, 4, 5, 6 and 7, finding the sum modulo 8. And so on.