[ prog / sol / mona ]

prog


The Forced Indentation Of Code

116 2022-06-24 11:33

The fractal dust of >>115 has a ratio of area covered by tiles to area of the enclosing rectangle that converges to 0. This is because at each new level the cover ratio is multiplied by a factor that converges to 5/9, so the overall product will drop below any strictly positive bound.

The tile heap of >>111 has a cover ratio that converges to a fixed value. With symmetry assumptions of square tiles and gaps and overlaps that are one third of a tile, the heap can be divided into quadrants, arbitrarily choosing to put the (0, 0) cell into the first quadrant, and the quadrants can be retiled with repeating 4x4 blocks:

2 2 2 2 | 1 1 1 1
0 2 2 2 | 0 1 1 1
2 2 2 2 | 1 1 1 1
2 2 0 2 | 1 1 0 1
--------+--------
3 3 3 3 | 4 4 4 4
0 3 3 3 | 0 4 4 4
3 3 3 3 | 4 4 4 4
3 3 0 3 | 4 4 0 4

Since each 4x4 block has two empty cells, the cover ratio converges to 7/8.

The ratio for the non-dust fractal of >>113 is only slightly harder to obtain. Using the same symmetry assumptions, at each new level the overall size is doubled and incremented by one, while the occupied cell count is multiplied by 4 and incremented by 9 - 4 = 5. The overall size forms the stream 3, 7, 15, 31, 63... which is one less than the next power of 2. The occupied cell count is C(n+1) = 4 * C(n) + 5, with C(0) depending on our choice of starting pattern. We would obtain the same result by choosing either a single 3x3 tile or a 5-group of corners-and-center as our starting pattern, but I find the latter to be clearer because it already exhibits the replication rule. So here we will take C(0) = 4 * 9 + 9 - 4 = 41 and an overall size that starts with 7. We get the ratio:

          C(n)
-----------------------
(2 ** (3 + n) - 1) ** 2

Expanding C(n) recursively as 4 * C(n-1) + 5 with C(0) = 41 yields:

C(n) = 41 * 4n + 5 * 4(n-1) + 5 * 4**(n-2) + ... + 5 * 4 + 5

We split the 41 back into 36 + 5 and we take Q to be 4**n and we get:

C(n) = 36 * Q + 5 * Q * (1 + 1/4 + 1/42 + ... + 1/4n)

The parens contain the partial sum of the geometric series of ratio 1/4. In the limit the partial sum becomes the actual sum of the series.

267


VIP:

do not edit these