undraft sand-1; minor edits

This commit is contained in:
queue-miscreant 2025-02-25 00:49:44 -06:00
parent 21b472e250
commit 324bda9563
2 changed files with 76 additions and 48 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
--- ---
title: "Counting in 2D: Lines, Leaves, and Sand" title: "Counting in 2D, Part 1: Lines, Leaves, and Sand"
draft: true description: |
An introduction to two-dimensional counting using polynomials of two variables.
format: format:
html: html:
html-math-method: katex html-math-method: katex
@ -14,6 +15,18 @@ execute:
echo: false echo: false
--- ---
<style>
.cell-output-display .figure {
text-align: center;
}
.figure-img {
max-width: 512px;
object-fit: contain;
height: 100%;
}
</style>
```{python} ```{python}
from pathlib import Path from pathlib import Path
@ -24,9 +37,7 @@ import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from IPython.display import ( from IPython.display import (
Video,
Latex, Latex,
display,
display_latex, display_latex,
) )
@ -50,10 +61,12 @@ Does it make sense to count in two variables?
Preliminaries Preliminaries
------------- -------------
Before proceeding, I will summarize some of the restrictions on which polynomials can be Before proceeding, I'll summarize some desired characteristics of polynomials which can be
used as carries in positional systems. used as carries in positional systems.
Carry polynomials must be nonpositive when evaluated at 1 (otherwise the digital root of Carry polynomials must be nonpositive when evaluated at 1 (otherwise the digital root of
an expansion is unbounded) and either: an expansion is unbounded).
Moreover, to make things easier, either:
- All coefficients have the same sign but one, which has a much larger - All coefficients have the same sign but one, which has a much larger
magnitude than the rest (and forces the digital root condition) magnitude than the rest (and forces the digital root condition)
@ -62,8 +75,8 @@ Carry polynomials must be nonpositive when evaluated at 1 (otherwise the digital
and monotonically increase toward 0 after the second coefficient (0's are allowed anywhere) and monotonically increase toward 0 after the second coefficient (0's are allowed anywhere)
- These are *implicit* irrational carries - These are *implicit* irrational carries
Implicit carries must be multiplied, typically by cylotomic polynomials, to obtain additional In previous systems, it was discovered that implicit carries can be multiplied,
rules for larger numerals. typically by cylotomic polynomials, to obtain explicit rules for larger numerals.
A Game of Che...ckers A Game of Che...ckers
@ -276,11 +289,15 @@ if not Path("./count_xy2.mp4").exists():
"./count_xy2.mp4", "./count_xy2.mp4",
fps=60 fps=60
) )
Video("./count_xy2.mp4")
``` ```
Starting at the expansion of twelve, the furthest extent is not in the first column or row. :::: {.row .text-center }
::: {.column width="60%"}
{{< video ./count_xy2.mp4 >}}
:::
::::
Starting at the expansion of twelve, the terms extend past the first column and row.
It instead grows faster along the diagonal, along which larger triangles appear when It instead grows faster along the diagonal, along which larger triangles appear when
counting to higher and higher integers. counting to higher and higher integers.
Meanwhile, lower degrees (toward the upper left) appear to be slightly less predictable. Meanwhile, lower degrees (toward the upper left) appear to be slightly less predictable.
@ -293,8 +310,6 @@ Fortunately, this is a simple enough system that we can scalar-multiply base exp
Ascending the powers of *n* in this manner for the carries where *n* = 3 and 4: Ascending the powers of *n* in this manner for the carries where *n* = 3 and 4:
```{python} ```{python}
#| layout-ncol: 2
# Run the animations until we overflow in the standard 100x100 range # Run the animations until we overflow in the standard 100x100 range
if not Path("./count_xy3.mp4").exists(): if not Path("./count_xy3.mp4").exists():
try: try:
@ -323,18 +338,22 @@ if not Path("./count_xy4.mp4").exists():
).save("count_xy4.mp4") ).save("count_xy4.mp4")
except ValueError: except ValueError:
pass pass
display(
Video("./count_xy3.mp4"),
Video("./count_xy4.mp4")
)
display_latex(
Latex("$$x + y = 3$$"),
Latex("$$x + y = 4$$"),
)
``` ```
:::: {.row layout-ncol="2"}
::: {}
{{< video ./count_xy3.mp4 >}}
$$x + y = 3$$
:::
::: {}
{{< video ./count_xy4.mp4 >}}
$$x + y = 4$$
:::
::::
Yellow corresponds to the highest allowed numeral, $n - 1$. Yellow corresponds to the highest allowed numeral, $n - 1$.
It seems like the lower-right grows much rounder as *n* increases. It seems like the lower-right grows much rounder as *n* increases.
However, neither appears to have an emergent pattern as dibinary did. However, neither appears to have an emergent pattern as dibinary did.
@ -344,7 +363,7 @@ For example,
$$\textcolor{red}{1}\textcolor{blue}{2}_{16} = \textcolor{red}{0001}\textcolor{blue}{0010}_{2}$$ $$\textcolor{red}{1}\textcolor{blue}{2}_{16} = \textcolor{red}{0001}\textcolor{blue}{0010}_{2}$$
because both one hexadecimal digit and four binary digits can range over zero to fifteen. because both one hexadecimal digit and four binary digits range over zero to fifteen.
Consequently, by grouping group *m* digits of an expansion in base *b*, one can easily convert to base $b^m$. Consequently, by grouping group *m* digits of an expansion in base *b*, one can easily convert to base $b^m$.
If such a procedure still exists in 2D, applying it somehow destroys the pattern in the $n = 2$ case, If such a procedure still exists in 2D, applying it somehow destroys the pattern in the $n = 2$ case,
@ -389,8 +408,9 @@ for i in range(3):
carry_add(expansion, xy2, 26) carry_add(expansion, xy2, 26)
``` ```
In each of these figures, shapes like hyperbolae show up and disappear, only to be replaced with In each of these figures, the line is the curve which corresponds to the carry polynomial.
higher-order curves. Along with it, while counting, additional shapes like hyperbolae seem to appear and disappear,
only to be replaced with higher-order curves.
These higher order curves can be difficult to graph, so they show up as thicker lines. These higher order curves can be difficult to graph, so they show up as thicker lines.
At sixty-four, it appears as though the reflection of the carry across the origin At sixty-four, it appears as though the reflection of the carry across the origin
(the curve $x + y = -2$) "wants" to appear. (the curve $x + y = -2$) "wants" to appear.
@ -405,8 +425,10 @@ We can also evaluate the polynomial at $(x, y) = (1, 1)$, a point on the carry c
This underlies a key difference from the 1D case. This underlies a key difference from the 1D case.
1D systems are special because the carry can be equated with a base (or bases), which 1D systems are special because the carry can be equated with a base (or bases), which
is a discrete, zero-dimensional point (one dimension less) on a number line. is a discrete, zero-dimensional point (one dimension less) on a number line.
In higher dimensions, there is no proper "base" we can plug in to "test" that an expansion In higher dimensions, all points on the carry curve (or hypersurface) are "bases" we can plug in
is valid like we can with the golden ratio in phinary. to test that an expansion is valid.
This makes naming much harder, since there are no preferred numbers to represent the system,
like the golden ratio does with phinary.
Casting the Line Casting the Line
@ -505,18 +527,22 @@ if not Path("./count_x3y4.mp4").exists():
op_val=4, op_val=4,
frames=list(range(200)), frames=list(range(200)),
).save("./count_x3y4.mp4") ).save("./count_x3y4.mp4")
display(
Video("./count_x2y3.mp4"),
Video("./count_x3y4.mp4"),
)
display_latex(
Latex("$$2x + y = 3$$"),
Latex("$$3x + y = 4$$"),
)
``` ```
:::: {.row layout-ncol="2"}
::: {}
{{< video ./count_x2y3.mp4 >}}
$$2x + y = 3$$
:::
::: {}
{{< video ./count_x3y4.mp4 >}}
$$3x + y = 4$$
:::
::::
The pattern produced is similar to the one from dibinary. The pattern produced is similar to the one from dibinary.
However, the triangular pattern no longer grows all at once, and instead, the bottom leads the top. However, the triangular pattern no longer grows all at once, and instead, the bottom leads the top.
Meanwhile, the disordered part in the upper left of the expansion appears to grow larger as *n* increases, Meanwhile, the disordered part in the upper left of the expansion appears to grow larger as *n* increases,
@ -612,9 +638,8 @@ As the negative term in an explicit carry, we must place it atop the digit we ar
While the shape of the curve is different from an ordinary line, the coefficients are arranged While the shape of the curve is different from an ordinary line, the coefficients are arranged
too similarly; for $a = 2/3$ (so the curve passes through the point $(1, 1)$) incrementing appears as: too similarly; for $a = 2/3$ (so the curve passes through the point $(1, 1)$) incrementing appears as:
:::: {.row layout-ncol="2"}
```{python} ```{python}
#| layout-ncol: 2
folium_carry = Carry([ folium_carry = Carry([
[ 0, 0, 0, 1], [ 0, 0, 0, 1],
[ 0,-2, 0, 0], [ 0,-2, 0, 0],
@ -647,10 +672,11 @@ if not Path("./count_folium.mp4").exists():
).save("./count_folium.mp4") ).save("./count_folium.mp4")
except ValueError: except ValueError:
pass pass
display(Video("./count_folium.mp4"))
``` ```
{{< video ./count_folium.mp4 >}}
::::
Clearly, this also tends back toward dibinary, but with the yellow digits spaced out more. Clearly, this also tends back toward dibinary, but with the yellow digits spaced out more.
@ -738,8 +764,6 @@ As a cellular automaton, it is rather popular as a coding challenge
These videos discuss toppling the initial value, but do not point out the analogy to polynomial expansions. These videos discuss toppling the initial value, but do not point out the analogy to polynomial expansions.
```{python} ```{python}
#| layout-ncol: 2
if not Path("./count_x2y3.mp4").exists(): if not Path("./count_x2y3.mp4").exists():
animate_carry_count( animate_carry_count(
carry = Carry([ carry = Carry([
@ -751,10 +775,14 @@ if not Path("./count_x2y3.mp4").exists():
op_val=4, op_val=4,
frames=list(range(200)), frames=list(range(200)),
).save("./count_laplace.mp4") ).save("./count_laplace.mp4")
Video("./count_laplace.mp4")
``` ```
:::: {.row .text-center }
::: {.column width="60%"}
{{< video ./count_laplace.mp4 >}}
:::
::::
The shapes produced by this pattern are well-known, with larger numbers appearing as fractals. The shapes produced by this pattern are well-known, with larger numbers appearing as fractals.
Generally, the expansions are enclosed within a circle, with shrinking triangular looking sections. Generally, the expansions are enclosed within a circle, with shrinking triangular looking sections.
This is eerily similar to the same shrinking triangles which appear in other unary-like carries. This is eerily similar to the same shrinking triangles which appear in other unary-like carries.