Pi’s Guys

3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15, 3, 13, 1, 4, 2, 6, 6, 99, 1, 2, 2, 6, 3, 5, 1, 1, 6, 8, 1, 7, 1, 2, 3, 7, 1, 2, 1, 1, 12, 1, 1, 1, 3, 1, 1, 8, 1, 1, 2, 1, 6, 1, 1, 5, 2, 2, 3, 1, 2, 4, 4, 16, 1, 161, 45, 1, 22, 1, 2, 2, 1, 4, 1, 2, 24, 1, 2, 1, 3, 1, 2, 1, …

The first 5821569425 terms were computed by Eric W. Weisstein on Sep 18 2011.
The first 10672905501 terms were computed by Eric W. Weisstein on Jul 17 2013.
The first 15000000000 terms were computed by Eric W. Weisstein on Jul 27 2013.
The first 30113021586 terms were computed by Syed Fahad on Apr 27 2021.
The first 653520000000 terms were computed by Max Frank, Nov 01 2025.

A001203 Simple continued fraction expansion of Pi.

The Madness of Mathness

Let us grant that the pursuit of mathematics is a divine madness of the human spirit, a refuge from the goading urgency of contingent happenings. When we think of mathematics, we have in our mind a science devoted to the exploration of number, quantity, geometry, and in modern times also including investigation into yet more abstract concepts of order, and into analogous types of purely logical relations. The point of mathematics is that in it we have always got rid of the particular instance, and even of any particular sorts of entities. So that for example, no mathematical truths apply merely to fish, or merely to stones, or merely to colours. So long as you are dealing with pure mathematics, you are in the realm of complete and absolute abstraction. All you assert is, that reason insists on the admission that, if any entities whatever have any relations which satisfy such-and-such purely abstract conditions, then they must have other relations which satisfy other purely abstract conditions.

• Alfred North Whitehead, Science and the Modern World (1925), chapter II, “Mathematics as an Element in the History of Thought”

Worms in Terms of Perms

If you go back far enough, we’re all worms. All us animals, that is. But in a subtler sense, all life is vermiform — animals, plants, fungi, bacteria. DNA is a kind of worm, a string of chemicals encoding the recipe for an animal, plant, fungus or bacterium. And the worms of DNA can be turned into numbers, just as some numbers can be turned into worms:

3/7 = 0·0.428571428571428571428571…
154/183 = 0.841530054644808743169398907…
√2 = 1.414213562373095048801688…
π = 3.1415926535897932384626433…

Those are decimals, but there’s another kind of worm for such numbers. It’s called a continued fraction:

contfrac(3/7) = [0,2,3]
contfrac(154/183) = [0,1,5,3,4,2]
contfrac(√2) = [1,2,2,2,2,2…]
contfrac(π) = [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15…]

Extracting and enacting continued fractions is very simple. Here’s the extracting:

3/7 → 1/(3/7) = 7/3 = 2+1/3 – 2 = 1/3 → 1(1/3) = 3, ∴ contfrac(3/7) = [0,2,3]
154/183 → 1/(154/183) = 183/154 = 1 + 29/154 – 1 = 29/154 → 1/(29/154) = 154/29 = 5 + 9/29 – 5 = 9/29 → 1/(9/29) = 29/9 = 3 + 2/9 – 3 = 2/9 → 1/(2/9) = 9/2 = 4 + 1/2 – 4 = 1/2 → 1/(1/2) = 2 – 2 = 0, ∴ contfrac(154/183) = [0,1,5,3,4,2]

And here’s the enacting:

[0,2,3] → 3 → 1/3 → 1/3 + 2 = 7/3 → 1/(7/3) = 3/7
[0,1,5,3,4,2] → 2 → 1/2 → 1/2 + 4 = 9/2 → 2/9 + 3 = 29/9 → 9/29 + 5 = 154/29 → 29/154 + 1 = 183/154 → 1/(183/154) = 154/183

Once you’ve got the worm of a continued fraction, you can perm the worm, as it were, generating different fractions like this (I’m dropping the initial [0,…] of the contfracs):

[2,3,4] = contfrac(13/30)
[2,4,3] → 13/29
[3,2,4] → 09/31
[3,4,2] → 09/29
[4,2,3] → 07/31
[4,3,2] → 07/30

Reversing a continued fraction is a kind of permutation, so the fractal below represents one kind of worms in terms of perms:

Variant of a limestone fractal or gryke fractal


I call that graph a fract-L, because it’s shaped like an L and the x axis represents the simplified fractions 1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5…, while the y axis represents the fractions you get by reversing the continued fractions of 1/2, 1/3, 2/3…:

contfrac(1/2) = [2] → 1/2
contfrac(1/3) = [3] → 1/3
contfrac(2/3) = [1,2] → 1/3
contfrac(1/4) = [4] → 1/4
contfrac(3/4) = [1,3] → 1/4
contfrac(1/5) = [5] → 1/5
contfrac(2/5) = [2,2] → 2/5
contfrac(3/5) = [1,1,2] → 2/5
contfrac(4/5) = [1,4] → 1/5
contfrac(1/6) = [6] → 1/6
contfrac(5/6) = [1,5] → 1/6
contfrac(1/7) = [7] → 1/7
contfrac(2/7) = [3,2] → 3/7
contfrac(3/7) = [2,3] → 2/7
contfrac(4/7) = [1,1,3] → 2/7
contfrac(5/7) = [1,2,2] → 3/7
contfrac(6/7) = [1,6] → 1/7
contfrac(1/8) = [8] → 1/8
contfrac(3/8) = [2,1,2] → 3/8
contfrac(5/8) = [1,1,1,2] → 3/8
contfrac(7/8) = [1,7] → 1/8
contfrac(1/9) = [9] → 1/9
contfrac(2/9) = [4,2] → 4/9
contfrac(4/9) = [2,4] → 2/9
contfrac(5/9) = [1,1,4] → 2/9
contfrac(7/9) = [1,3,2] → 4/9
contfrac(8/9) = [1,8] → 1/9
[…]

If you perm the worm in other ways, you get other shapes on the fract-L. I looked at continued fractions of fixed length, 4, 5 and 6, and permed them using one of the permutations of [1,2,3,4], [1,2,3,4,5] and [1,2,3,4,5,6]. Here’s a graph for fractions, a/b, and permed fractions, perm(a/b), where length(contfrac(a/b)) = 4:

x = a/b when length(contfrac(a/b)) = 4, y = fraction from contfrac(a/b) permed with [1,3,2,4]


The x axis represents simplified fractions, a/b, when len(cf(a/b)) = 4. The y axis represents the fractions found by applying the perm [1,3,2,4] to contfrac(a/b). That is, the first number of the contfrac stays where it is, the third number moves to position 2, the second number moves to position 3 and the fourth number stays where it is. In short, you simply swap the middle two numbers of contfrac(a/b). Here’s an example:

contfrac(9/43) = [4,1,3,2] → [4,3,1,2] → 11/47, because contfrac(11/47) = [4,3,1,2]

Here are more fract-Ls representing worms in terms of perms:

fract-L for contfrac(a/b) permed by [2,1,3,4]


fract-L for contfrac(a/b) permed by [3,2,1,4]


fract-L for contfrac(a/b) permed by [1,4,2,3,5] (i.e. a/b where len(contfrac(a/b)) = 5)


fract-L for contfrac(a/b) permed by [1,5,3,4,2]


fract-L for contfrac(a/b) permed by [2,1,4,3,5]


fract-L for contfrac(a/b) permed by [3,4,1,2,5]


fract-L for contfrac(a/b) permed by [4,2,3,1,5]


fract-L for contfrac(a/b) permed by [4,2,5,3,1]


fract-L for contfrac(a/b) permed by [4,3,2,1,5]


fract-L for contfrac(a/b) permed by [5,3,4,2,1]


fract-L for contfrac(a/b) permed by [2,1,4,3,5,6] (i.e. a/b where len(contfrac(a/b)) = 6)


fract-L for contfrac(a/b) permed by [2,1,5,4,3,6]


fract-L for contfrac(a/b) permed by [3,2,1,4,5,6]


fract-L for contfrac(a/b) permed by [3,2,1,5,4,6]


fract-L for contfrac(a/b) permed by [3,5,1,4,2,6]


fract-L for contfrac(a/b) permed by [4,2,5,1,3,6]


fract-L for contfrac(a/b) permed by [4,3,2,1,5,6]


fract-L for contfrac(a/b) permed by [4,5,2,3,1,6]


fract-L for contfrac(a/b) permed by [1,3,2,6,5,4,7] (i.e. a/b where len(contfrac(a/b)) = 7)


fract-L for contfrac(a/b) permed by [1,5,2,6,3,4,7]


fract-L for contfrac(a/b) permed by [5,6,3,7,4,1,2]


fract-L for contfrac(a/b) permed by [6,2,3,5,4,1,7]


fract-L for contfrac(a/b) permed by [6,2,5,4,7,3,1]


Post-Performative Post-Scriptum

Much as I hate the phrase “in terms of”, I was happy to use it in the title of this post. After all, it isn’t ugly but assonant there. And it began life in mathematics, where it still has its proper meaning rather than being pretentious and prolix:

How did this complex preposition come into being? The OED [Oxford English Dictionary] reveals that it has been in use since the mid-18c. as a mathematical expression “said of a series…stated in terms involving some particular (my emphasis) quantity”, and illustrates this technical usage by citing examples from the work of Herbert Spencer (1862), J. F. W. Herschel (1866), and other writers. From this technical use came at first a trickle and, after the 1940s, a flood of imitative uses by non-mathematicians. — “Terminal Trinity


Elsewhere Other-Engageable

A Fracteasel on a Fract-L — an earlier look at continued fractions and fractal fract-Ls

Sequence Unfurls…

The Fibonacci sequence is beautiful like clockwork. There’s a perfectly clear, rigorously defined mechanism ticking out an entirely predictable result for ever:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, … — A000045 at the Online Encyclopedia of Integer Sequences (OEIS)

And there’s a formula to calculate any term in the sequence without calculating all the terms that precede it:

Binet’s formula for Fn, the n-th Fibonacci number


But I also like sequences that you might call definitely arbitrary. That is, there’s a perfectly clear, rigorously defined mechanism, but the results seem arbitrary — not predictable at all:

6, 15, 5, 22, 6, 3, 30, 9, 7, 2, 45, 15, 6, 5, 1, 36, 14, 6, 5, 3, 1, 62, 22, 16, 6, 5, 3, 2, 69, 21, 15, 4, 9, 5, 2, 1, 84, 30, 15, 9, 6, 7, 2, 2, 1, 56, 22, 13, 7, 3, 5, 2, 0, 0, 0, 142, 45, 22, 15, 12, 6, 9, 5, 3, 1, 2, 53, 17, 8, 4, 5, 1, 6, 3, 1, 1, 1, 0, 124, 36, 27, 14, 18, 6, 6, 5, 2, 3, 1, 1, 0, … A349083 at OEIS

What’s the formula there? That sequence is defined at the OEIS as “The number of three-term Egyptian fractions of rational numbers x/y, 0 < x/y < 1, ordered as below. The sequence is the number of (p,q,r) such that x/y = 1/p + 1/q + 1/r where p, q, and r are integers with p < q < r.” For example: “The sixth rational number is 3/4 [and] 3/4 = 1/2 + 1/5 + 1/20 = 1/2 + 1/6 + 1/12 = 1/3 + 1/4 + 1/5, so a(6)=3.”

The Number of the Decreased

I wondered what happened when you take a fraction, a/b, and calculate a/b – (a/b)^2 = c/d. And an interesting pattern appeared when I tried a prime denominator and all numerators less than that denominator. Here’s the pattern with the prime denominator of 7:


1/7 - 01/49 = 06/49
2/7 - 04/49 = 10/49
3/7 - 09/49 = 12/49
4/7 - 16/49 = 12/49
5/7 - 25/49 = 10/49
6/7 - 36/49 = 06/49

And here it is with the prime denominator of 13:


01/13 - 001/169 = 12/169
02/13 - 004/169 = 22/169
03/13 - 009/169 = 30/169
04/13 - 016/169 = 36/169
05/13 - 025/169 = 40/169
06/13 - 036/169 = 42/169
07/13 - 049/169 = 42/169
08/13 - 064/169 = 40/169
09/13 - 081/169 = 36/169
10/13 - 100/169 = 30/169
11/13 - 121/169 = 22/169
12/13 - 144/169 = 12/169

It’s easier to see what’s going on with the smaller denominator:


1/7 - 01/49 = 06/49 = 1/7 - (1/7)^2
2/7 - 04/49 = 10/49 = 2/7 - (2/7)^2
3/7 - 09/49 = 12/49 = 3/7 - (3/7)^2
4/7 - 16/49 = 12/49
5/7 - 25/49 = 10/49
6/7 - 36/49 = 06/49


1/7 - 01/49 = 07/49 - 01/49 = 06/49
2/7 - 04/49 = 14/49 - 04/49 = 10/49
3/7 - 09/49 = 21/49 - 09/49 = 12/49
4/7 - 16/49 = 28/49 - 16/49 = 12/49
5/7 - 25/49 = 35/49 - 25/49 = 10/49
6/7 - 36/49 = 42/49 - 36/49 = 06/49


1/7 - 01/49 = 1*7/7^2 - 1^2/7^2 = 07/49 - 01/49 = 06/49
2/7 - 04/49 = 2*7/7^2 - 2^2/7^2 = 14/49 - 04/49 = 10/49
3/7 - 09/49 = 3*7/7^2 - 3^2/7^2 = 21/49 - 09/49 = 12/49
4/7 - 16/49 = 4*7/7^2 - 4^2/7^2 = 28/49 - 16/49 = 12/49
5/7 - 25/49 = 5*7/7^2 - 5^2/7^2 = 35/49 - 25/49 = 10/49
6/7 - 36/49 = 6*7/7^2 - 6^2/7^2 = 42/49 - 36/49 = 06/49

Here’s a set of the patterns using prime denominators from 3 to 13:


1/3 - 1/9 = 2/9
2/3 - 4/9 = 2/9


1/5 - 01/25 = 4/25
2/5 - 04/25 = 6/25
3/5 - 09/25 = 6/25
4/5 - 16/25 = 4/25


1/7 - 01/49 = 06/49
2/7 - 04/49 = 10/49
3/7 - 09/49 = 12/49
4/7 - 16/49 = 12/49
5/7 - 25/49 = 10/49
6/7 - 36/49 = 06/49


01/11 - 001/121 = 10/121
02/11 - 004/121 = 18/121
03/11 - 009/121 = 24/121
04/11 - 016/121 = 28/121
05/11 - 025/121 = 30/121
06/11 - 036/121 = 30/121
07/11 - 049/121 = 28/121
08/11 - 064/121 = 24/121
09/11 - 081/121 = 18/121
10/11 - 100/121 = 10/121


01/13 - 001/169 = 12/169
02/13 - 004/169 = 22/169
03/13 - 009/169 = 30/169
04/13 - 016/169 = 36/169
05/13 - 025/169 = 40/169
06/13 - 036/169 = 42/169
07/13 - 049/169 = 42/169
08/13 - 064/169 = 40/169
09/13 - 081/169 = 36/169
10/13 - 100/169 = 30/169
11/13 - 121/169 = 22/169
12/13 - 144/169 = 12/169

Then I tried a/b – (a/b)^3. There were no obvious strong patterns, but something caught my eye in the last subtraction for b = 19:


01/19 - 0001/6859 = 0360/6859 = 1/19 - (1/19)^3
02/19 - 0008/6859 = 0714/6859 = 2/19 - (2/19)^3
03/19 - 0027/6859 = 1056/6859 = 3/19 - (3/19)^3
04/19 - 0064/6859 = 1380/6859
05/19 - 0125/6859 = 1680/6859
06/19 - 0216/6859 = 1950/6859
07/19 - 0343/6859 = 2184/6859
08/19 - 0512/6859 = 2376/6859
09/19 - 0729/6859 = 2520/6859
10/19 - 1000/6859 = 2610/6859
11/19 - 1331/6859 = 2640/6859
12/19 - 1728/6859 = 2604/6859
13/19 - 2197/6859 = 2496/6859
14/19 - 2744/6859 = 2310/6859
15/19 - 3375/6859 = 2040/6859
16/19 - 4096/6859 = 1680/6859
17/19 - 4913/6859 = 1224/6859
18/19 - 5832/6859 = 0666/6859

Look at the final subtraction: 18/19 – 5832/6859 = 666/6859. So the Number of the Beast is the numerator when 18/19 is decreased by (18/19)^3. Dropping the need for powers of a/b, I looked for more beastly fraction subtractions using pairs of simplified fractions. Here are a few:


26/35 - 04/31 = 666/1085 = 0.613824885...
29/35 - 05/29 = 666/1015 = 0.656157635...
32/35 - 02/23 = 666/0805 = 0.827329193...
40/41 - 14/31 = 666/1271 = 0.523996853...
35/43 - 13/35 = 666/1505 = 0.442524917...
23/47 - 01/31 = 666/1457 = 0.457103638...
30/47 - 12/41 = 666/1927 = 0.345614946...
31/47 - 01/23 = 666/1081 = 0.616096207...
31/47 - 02/46 = 666/1081 = 0.616096207...
40/47 - 02/19 = 666/0893 = 0.745800672...
[...]

This fraction subtraction is beastly in two ways: 95/103 – 83/97 = 666/9991 = 0.066659994…

I also noticed that 666 can be the numerator in two ways when the denominator is 19 and its powers:


18/19 - 5832/6859 = 666/6859 = 18/19 - (18/19)^3
18/19 + 0324/0361 = 666/0361 = 18/19 + (18/19)^2

So 666 is both the Number of the Decreased and the Number of the Increased. That double pattern is general when you either decrease (b-1)/b by ((b-1)/b)^3 or increase (b-1)/b by ((b-1)/b)^2:


2/3 - 8/27 = 10/27 = 2/3 - (2/3)^3
2/3 + 04/9 = 10/09 = 2/3 + (2/3)^2


4/5 - 64/125 = 36/125 = 4/5 - (4/5)^3
4/5 + 16/025 = 36/025 = 4/5 + (4/5)^2


6/7 - 216/343 = 78/343 = 6/7 - (6/7)^2
6/7 + 036/049 = 78/049 = 6/7 + (6/7)^2


10/11 - 1000/1331 = 210/1331
10/11 + 0100/0121 = 210/0121


12/13 - 1728/2197 = 300/2197
12/13 + 0144/0169 = 300/0169


16/17 - 4096/4913 = 528/4913
16/17 + 0256/0289 = 528/0289


18/19 - 5832/6859 = 666/6859
18/19 + 0324/0361 = 666/0361


22/23 - 10648/12167 = 990/12167
22/23 + 00484/00529 = 990/00529

A FracTeasel on a Fract-L

Here are two new fractals, both of which remind me of the seedheads of the wildflower known as a teasel, Dipsacus fullonum:

A FracTeasel fractal


Dried seedheads of teasel, Dipsacus fullonum (Wikipedia)


Another FracTeasel fractal (embedded in the first)


Flowering seedhead of teasel, Dipsacus fullonum (Wikipedia)


How do you create the two FracTeasels? Let’s look first at the fractal they’re inspired by. In “Back to Frac’” I talked about this fractional fractal, a variant of what I call the limestone fractal:

Variant of a limestone fractal or gryke fractal


It’s a fractal on a fract-L, that is, the x and y co-ordinates of the red L represent pairs of fractions generating decimals between 0 and 1. The x represents the fractions a1/b1 = 1/n to (n-1)/n in simplest form: 1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6, 5/6, 1/7, 2/7, 3/7, 4/7, 5/7, 6/7, 1/8, 3/8, 5/8, 7/8,…

And what about the y? It represents the fraction found by taking the continued fraction of a1/b1, reversing it, and generating a new fraction, a2/b2, from the reversal. For example, here’s the continued fraction of a1/b1 = 3/23 = 0.1304347826…:

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

The continued fraction of a1/b1 = 3/23 is used like this to reconstruct a1/b1:

7,1,2

0 → 1 / (0 + 2) = 1/2 → 1 / (1/2 + 1) = 2/3 → 1 / (7 + 2/3) = 3/23

Now reverse the continued fraction, 7,1,2 → 2,1,7, and generate a2/b2:

2,1,7

0 → 1 / (0 + 7) = 1/7 → 1 / (1/7 + 1) = 7/8 → 1 / (2 + 7/8) = 8/23 = 0.3478260869565…

The limestone fractal above appears when a1/b1 → a2/b2 for a1/b1 = 1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6, 5/6, 1/7, 2/7, 3/7, 4/7, 5/7, 6/7, 1/8, 3/8, 5/8, 7/8,… But you can do other things to contfrac(a1/b1) beside just reversing it. What about the permutations of contfrac(a1/b1), for example? If length(contfrac(a1/b1)) = n, the permutations can generate up to n! (factorial n) new a2/b2 for the y co-ordinate (if all the numbers of contfrac(a1/b1) are different, you’ll get n! permutations). The resultant fractal is the first of the FracTeasels above (note that a2/b2 isn’t multiplied by two):

FracTeasel #1 from fract-L for y = perm(contfrac(a1/b1))


If you think about it, you’ll see that the fractal from permed contfrac(a1/b1) contains the fractal from reversed contfrac(a1/b1). It also contains the second FracTeasel:

FracTeasel #2


How so? Because the second FracTeasel — let’s call it the stemmed FracTeasel — is created by shifting some numbers in contfrac(a1/b1) and leaving others alone. For example:

contfrac(940/1089) = 1, 6, 3, 4, 5, 2 → 1, 4, 3, 2, 5, 6 = contfrac(1008/1243)

So the function is finding one particular permutation of contfrac(a1/b1) to generate a2/b2, not all permutations. And so the function creates the stemmed FracTeasel, which carries an infinite number of seedheads on the same stem. To show that, here’s an animated gif zooming in on the bend of the fract-L for the stemmed FracTeasel:

Zooming the FracTeasel (animated at ezGif)


Elsewhere Other-Accessible…

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

Matchin’ Fraction

I wondered whether contfrac(a/b), the continued fraction of a/b, ever matched the digits of a and b in some base. The answer was yes. But I haven’t found any examples in base 10:

3,1,2 = contfrac(3/12) in base 9 = contfrac(3/11) in base 10
4,1,3 = contfrac(4/13) in b16 = contfrac(4/19) in b10
5,1,45/14 in b25 = 5/29
6,1,56/15 in b36 = 6/41
25,22/52 in b9 = 2/47 → 23,2
7,1,67/16 in b49 = 7/55
8,1,78/17 in b64 = 8/71
9,1,89/18 in b81 = 9/89
A,1,9A/19 in b100 = 10/109 → 10,1,9
42,1,34/213 in b8 = 4/139 → 34,1,3
4,1,2,3,341/233 in b8 = 33/155
1,17,1,2,3117/123 in b14 = 217/227 → 1,21,1,2,3
3A,33/A3 in b28 = 3/283 → 94,3
3,5,A,235/A2 in b34 = 107/342 → 3,5,10,2
3,1,4,1,4,1,5314/1415 in b8 = 204/781
2,1,36,3,2213/632 in b12 = 303/902 → 2,1,42,3,2
3,2,11,2,2,2321/1222 in b9 = 262/911 → 3,2,10,2,2,2
4H,44/H4 in b65 = 4/1109 → 277,4
6,2,1,3,J62/13J in b35 = 212/1349 → 6,2,1,3,19
8,3,3,1,D83/31D in b22 = 179/1487 → 8,3,3,1,13
93,1,89/318 in b27 = 9/2222 → 246,1,8
1,3A,1,1,4,2,213A1/1422 in b12 = 2281/2330 → 1,46,1,1,4,2,2
C7,1,BC/71B in b21 = 12/3119 → 259,1,11
1,2,2,1,O,F122/1OF in b50 = 2602/3715 → 1,2,2,1,24,15
2,1,1,5,55211/555 in b28 = 1597/4065 → 2,1,1,5,145
3,1,1,A,K,6311/AK6 in b29 = 2553/8996 → 3,1,1,10,20,6
1,2[70],1,3,912[70]/139 in b98 = 9870/9907 → 1,266,1,3,9
1,E,4,1,M,71E4/1M7 in b100 = 11404/12207 → 1,14,4,1,22,7
LG,5,4L/G54 in b28 = 21/12688 → 604,5,4
G4,1,FG/41F in b64 = 16/16463 → 1028,1,15

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