diff --git a/.gitignore b/.gitignore index 0d27235..acc2ee8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -_freeze/ _site/ /.quarto/ index_files/ diff --git a/_freeze/polycount/1/index/execute-results/html.json b/_freeze/polycount/1/index/execute-results/html.json new file mode 100644 index 0000000..44aae5e --- /dev/null +++ b/_freeze/polycount/1/index/execute-results/html.json @@ -0,0 +1,12 @@ +{ + "hash": "8eea12e2dbee7f9631ee6eec95583c6d", + "result": { + "engine": "jupyter", + "markdown": "---\ntitle: \"Polynomial Counting 1: A primer\"\nformat:\n html:\n html-math-method: katex\njupyter: python3\ndate: \"2021-02-03\"\ndate-modified: \"2025-02-07\"\ncategories:\n - algebra\n - phinary\n - python\n---\n\nThe single most common method of representing numbers in the modern world is in *positional numeral system*.\nDespite being taught in early grade school, it is the result of millennia of mathematical thought.\n\nThe decimal system we use today assigns integers to *expansions* consisting several symbols called *numerals* next to each other.\nEach numeral is positioned at a *place value*, which has a value ten times greater than its neighbor to the right and a tenth as much of its neighbor to the left.\nDue to place values sharing a constant ratio of ten, the system is called *decimal*.\n\n$$\n\\begin{align*}\n \\scriptsize 10^2 && \\scriptsize 10^1 && \\scriptsize 10^0 && \\scriptsize 10^{-1} &\n \\quad \\} \\quad \\text{Place values} \\\\\n 4 && 3 && 2 .&& 1 &\n \\quad \\} \\quad \\text {Numerals: 1, 2, 3, 4} \\\\\n \\hline\n\\end{align*} \\\\\n\\text{Four hundred, thirty-two, and one tenth}\n$$\n\n
\n\nOn the difference between \"1, 2, 3, and 4\" and \"one, two, three, and four\"\n\nFor clarity, I distinguish between numerals, such as 1, 2, 3, and 4, and numbers, such as one, two, three, and four.\nWhen discussing different systems from decimal, it is easy to write things like \"base 2\" rather than \"base two\".\nThe former leverages a distinguished symbol for the number two existing, which while at times useful, leads to confusion between the symbol and the underlying number.\n\n\nWhen referring to its value, I'll tend to write out a number's English name, rather than how it would be written in decimal.\nConversely, when I want to refer to the symbols themselves, I will enclose them in quotes; for example, \"0\" refers to the symbol 0.\n
\n\n\nA Brief History\n---------------\n\nAs mentioned, this practice is millenia old.\n\nArguably, the oldest common ancestor was used by the Babylonians (circa eighteenth century BC), who instead used a sexagesimal (base sixty) system.\nIt lacked a \"decimal point\" (more properly a sexagesimal point, *fractional separator*, or *radix point*), meaning that a representation could equally as well refer to thirty (30) or one-half (1/2), or one hundred and eight thousand (108000), since all these numbers differ by a power of sixty (60).\nThis system lacked a \"0\" symbol to represent an empty place value, opting instead to simply skip them.\nThus, the onus was on the arithmetician to properly align digits, maintain spacing, and correctly interpret results.\nDespite these limitations, it was robust enough to develop basic trigonometry and [approximate the square root of 2](https://en.wikipedia.org/wiki/YBC_7289).\n\nLater, Indian mathematics developed its own place value system -- this time in the familiar base ten -- at least by the time of Aryabhata (4th century AD). It introduced the empty \"0\" symbol that the Babylonian system lacked.\nEventually, this system made its way to Europe by means of the Arabs.\nThe 16th century Dutch engineer Simon Stevin was one of the first individuals to introduce a \"decimal point\".\nThough modern notation differs slightly from his, it introduced (or perhaps re-introduced) a means of adding and multiplying numbers between integers.\nNeedless to say, it has become so popular as to become one of the most predominant ways to express numbers.\n\nLater thought realized bases other than ten were possible; for example, [binary](https://en.wikipedia.org/wiki/Binary_number) (base two) due in part to Leibniz.\nStranger yet are non-integral bases, for example the complex base $2i$ due to Knuth.\nHowever, I find bases which rely on *irrational* numbers to be the most interesting.\n\nStaying Golden\n--------------\n\nThe [*golden ratio*](https://en.wikipedia.org/wiki/Golden_ratio), a number with many apocryphal attributions, was a favorite of Greek mathematics.\nAs such, it was originally recognized in the context of geometry, long before the development of algebra.\nIt is constructed by dividing a line segment such that the ratio between the longer and shorter sub-segments is the same as the ratio between original segment and the longer sub-segment.\n\nPhrased in modern algebraic language, the golden ratio *φ* is the unique positive root of the polynomial $x^2 - x - 1$, expressed as $\\frac{1 + \\sqrt 5}{2} \\approx 1.618…$.\nDespite its name, this number is ir**ratio**nal, since it cannot be represented as a **ratio** of integers.\nFurthermore, raising it to any integral power does not produce an integer (left as an exercise to the reader).\n\nIt might seem inconceivable that one may obtain an integer (other than zero or one) by summing powers of *φ*.\nHowever, base *φ* (also called phinary) does in fact exist.\nHere is a list of (canonical) expansions up to 10\n\n:::: {.row .text-center width=\"50%\"}\n::: {#canonical-phinary-table .column}\n\n| *n* (Decimal) | *n* (Phinary) |\n|--------------:|:-------------:|\n| 0 | 0 |\n| 1 | 1 |\n| 2 | 10.01 |\n| 3 | 100.01 |\n| 4 | 101.01 |\n| 5 | 1000.1001 |\n| 6 | 1010.0001 |\n| 7 | 10000.0001 |\n| 8 | 10001.0001 |\n| 9 | 10010.0101 |\n| 10 | 10100.0101 |\n\n:::\n::::\n\nWe can obtain the entries on this list in two ways: naively (and imprecisely), or directly.\n\n\n### The Naive Approach\n\nIn the most general sense, an expansion is just a sequence of integers, or digits.\nWe can recover the value by summing the products of the integers by their place values.\nFor example, a decimal number has the form\n\n$$\n\\begin{align*}\n x &= ({a_n a_{n-1}... a_1 a_0})_{10} \\\\\n &= a_0 \\cdot 10^0 + a_1 \\cdot 10^1 + ... + a_{n-1} \\cdot 10^{n-1} + a_n \\cdot 10^{n}\n\\end{align*}\n$$\n\nwhere the $a_i$ are digits of the number.\nNegative indices (corresponding to fractional values) may also be used, but have been omitted for horizontal space.\n\nThis equivalence means that we can convert to and from a particular base.\nNaively, we might use the following \"greedy\" algorithm to derive the base-$b$ expansion\n(also called a [β-expansion](https://en.wikipedia.org/wiki/Non-integer_base_of_numeration)) of a number $x$:\n\n::: {#d3ab392d .cell execution_count=1}\n``` {.python .cell-code}\nfrom math import log, floor\n\ndef beta_expand_greedy(\n x: float,\n b: float,\n tol: float = 0.0001\n) -> dict[int, int]:\n ret = {}\n\n while x > tol: # While we're not precise enough\n p = int(floor(log(x, b))) # Get the place value p\n digit, new_x = divmod(x, b**p) # Get the quotient and remainder from\n # dividing by this place value\n ret[p] = int(digit) # Place the digit in place value p\n x = new_x # Update the value of x and repeat\n\n return ret\n```\n:::\n\n\nAs a demonstration, this algorithm, when run on a decimal number gives the same value:\n\n::: {#7518c855 .cell execution_count=2}\n``` {.python .cell-code}\ndef as_digits(digits: dict[int, int]) -> str:\n '''Convert a dictionary from `beta_expand_greedy` to a sequence of digits'''\n return \"\".join(\n str(digits.get(i, 0)) + (\".\" if i == 0 else \"\")\n for i in range(max(digits.keys()), min(digits.keys()) - 1, -1)\n )\n\none_thousand_two_hundred_thirty_four = 1234\nprint(\n \"one_thousand_two_hundred_thirty_four =\",\n as_digits(beta_expand_greedy(one_thousand_two_hundred_thirty_four, 10)),\n \"in base 10\"\n)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\none_thousand_two_hundred_thirty_four = 1234. in base 10\n```\n:::\n:::\n\n\nThere are three problems with this.\n\n1. It is inexact. `x` gets smaller, but we can only ever approximate the result.\n For numbers smaller than the tolerance, it is outright wrong.\n Due to the nature of the approximation, the result can also appear in an unexpected form:\n\n\n ::: {#837b45d7 .cell execution_count=3}\n ``` {.python .cell-code}\n phi = (5**0.5 + 1) / 2\n print(\"Expected:\", \"10100.0101\")\n print(\"Got: \", as_digits(beta_expand_greedy(10, phi)))\n ```\n \n ::: {.cell-output .cell-output-stdout}\n ```\n Expected: 10100.0101\n Got: 10100.0100101010101010101\n ```\n :::\n :::\n \n \n2. It relies on a transcendental function, the logarithm.\n - One may approximate this by repeated division, but in general, it is practical to use a floating-point function.\n\n3. The arguments `x` and `b` are given as floating-point numbers.\n However, if `p` is always positive, we can instead use integer arithmetic, which is more precise.\n Generally, we need some form of fractional arithmetic.\n\nModern FPUs are make the last two items somewhat trivial, but they necessarily make the calculation approximate.\nFortunately for phinary, there is a direct method which remedies all these issues and produces exact results without floating-point operations.\n\n\n### Deriving Expansions\n\nTake another look at the canonical representations [above](#canonical-phinary-table).\nMuch like binary, phinary only requires the digits 0 and 1.\nAnother slightly less obvious fact is that the string \"11\" never occurs in the expansion.\nThis is because we can rewrite the polynomial as the following\n\n$$\n\\begin{gather*}\n x - 2 = 0 \\implies\n \\left. \\begin{align*}\n x &= 2 \\\\\n 10_x &= 02\n \\end{align*} \\right\\}\n & \\text{Binary}\n \\\\ \\\\\n \\varphi^2 - \\varphi - 1 = 0 \\implies\n \\left. \\begin{align*}\n \\varphi^2 &= \\varphi + 1 \\\\\n 100_\\varphi &= 11_\\varphi\n \\end{align*} \\right \\}\n & \\text{Phinary}\n\\end{gather*}\n$$\n\nThis shows a connection between polynomials and positional notation which is not at all obvious.\nThe second lines leverage positional notation in lieu of a symbol; their interpretation is exactly the same as the first line.\n\nWhen we multiply or divide by ten in decimal (or two in binary), we shift the digits left or right.\nLikewise, we may multiply or divide by *φ* on either side of the equation.\nThus, it is also true that\n\n$$\n\\begin{gather*}\n \\left. \\begin{align*}\n 2^2 &= 2\\cdot 2 &&\\iff&\n 100_2 &= 20_2 \\\\\n 1 &= 2\\cdot 2^{-1} &&\\iff&\n 1_2 &= 0.2_2\n \\end{align*}\\right \\}\n & \\text{Binary}\n \\\\ \\\\\n \\left. \\begin{align*}\n \\varphi^3 &= \\varphi^2 + \\varphi &&\\iff&\n 1000_\\varphi &= 110_\\varphi \\\\\n \\varphi &= 1 + \\frac 1 \\varphi &&\\iff&\n 10_\\varphi &= 1.1_\\varphi\n \\end{align*}\\right \\}\n & \\text{Phinary}\n\\end{gather*}\n$$\n\nSince this relationship holds for any adjacent place values, it is analogous to \"carrying\" in base ten.\nIn decimal, we care if a single place value exceeds ten and increment the next place value (once for each multiple of ten).\nIn phinary, we care if there are two \"1\"s in adjacent place values, and can remove such occurrences by doing the same.\n\nMore generally, we can look at expansions not restricted to the symbols \"0\" and \"1\" and do similarly\n\n$$\n\\begin{align*}\n 32_\\varphi &= 121_\\varphi \\\\\n 0.61_\\varphi &= 1.5_\\varphi\n\\end{align*}\n$$\n\nThinking a little more cleverly, we can decompose 2 as\n\n$$\n\\begin{align*}\n \\textcolor{red}{2} = 1.\\textcolor{red}{11}_\\varphi =\n \\textcolor{blue}{1.1}1_\\varphi &= \\textcolor{blue}{1}0.01_\\varphi \\\\\n 2 &= \\varphi + \\varphi^{-2}\n\\end{align*}\n$$\n\nWith this rule in tow, we can finally start counting in phinary.\nWe count in base ten by incrementing the ones digit (or 0th place value) and carrying tens to higher digits.\nIn phinary, we have two carry rules, which we repeat until we cannot:\n\n1. Express \"011\" as \"100\"\n2. Express \"0200\" as \"1001\"\n\nAggressively applying these rules results in the same expansion as found in the [canonical table](#canonical-phinary-table).\nFor example, the expansion of three is clearly\n\n$$\n3 = 2 + 1 = 10.01_\\varphi + 1 = \\textcolor{red}{11}.01 = \\textcolor{red}{1}00.01\n$$\n\nBoth of these rules hold for larger digits as well.\nFor example, we can expand the quantity $4\\varphi + 3$ as:\n\n$$\n\\stackrel{\\text{Carry 033 = 300}}{\n 00\\textcolor{red}{043}_\\varphi =\n 00\\textcolor{red}{310}\n}_\\varphi =\n\\stackrel{\\text{Carry 0200 = 1001}}{\n 0\\textcolor{blue}{0310}_\\varphi =\n 0\\textcolor{blue}{1111}\n}_\\varphi =\n0\\textcolor{green}{11}\\textcolor{orange}{11}_\\varphi =\n\\textcolor{green}{1}0\\textcolor{orange}{1}00_\\varphi\n$$\n\nChecking approximately, this identity appears to be true:\n\n::: {#91e15dfe .cell execution_count=4}\n``` {.python .cell-code}\nprint(phi**4 + phi**2 - (4 * phi + 3))\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n0.0\n```\n:::\n:::\n\n\n### The Other Root\n\nAs a quadratic, the polynomial $x^2 - x - 1$ has two roots: $\\varphi$ and its conjugate $\\varphi^* = -\\varphi^{-1}$.\nThis implies that each phinary string can be interpreted by either root.\n\n$$\n\\begin{align*}\n 5 = 1000.1001_{\\varphi_{\\phantom{*}}}\n &= \\varphi^3 + \\varphi^{-1} + \\varphi^{-4} \\\\\n \\phantom{5} = 1000.1001_{\\varphi^*}\n &= ((-\\varphi)^{-1})^3 + ((-\\varphi)^{-1})^{-1} + ((-\\varphi)^{-1})^{-4} \\\\\n &= \\varphi^{4} -\\ \\varphi -\\ \\varphi^{-3} \\\\\n &= 10000_\\varphi -\\ 10.001_\\varphi\n\\end{align*}\n$$\n\nTo make the calculation easier, we can un-expand the postive part to make cancellation with the negative part easier.\nThis is the same as borrowing when doing typical subtraction.\n\n$$\n\\begin{align*}\n 10000_\\varphi &= 1100_\\varphi = 1011_\\varphi = 1010.11_\\varphi \\\\\n &= 1010.1011_\\varphi\n\\end{align*}\n$$\n\nProceeding onwards,\n\n$$\n\\begin{align*}\n 1000.1001_{\\varphi^*} &= 10000_\\varphi -\\ 10.001_\\varphi \\\\\n &= 1010.1011_\\varphi -\\ 10.001_\\varphi \\\\\n &= 1000.1001_\\varphi\n\\end{align*}\n$$\n\nAnd we breathe a sigh of relief since the expansion we get is the same we started with.\nThis is perhaps one of the reasons phinary expansions seem so verbose.\n\nAs an aside, since $-\\varphi^{-1}$ is negative, its powers alternate between positive and negative.\nAlso, since its magnitude is less than one, place values to the right of the radix point are larger than one, the inverse of what one is used to with base ten.\n\n\nFibonacci and Zeckendorf\n------------------------\n\nInstead of assigning place values to powers of the base, we can instead imagine a situation where the place values correspond to the values of a sequence, in particular the Fibonacci numbers.\nPhi also turns up when discussing this sequence, or more generally, sequences generated by the recurrence $a_{n+1} = a_n + a_{n-1}$.\nThis bears a striking resemblance the the polynomial mentioned above, with cursory examination by [generating functions](https://en.wikipedia.org/wiki/Generating_function) revealing the connection.\n\nFibonacci numbers are all integers, so sums of them can only express integers.\nIf we assign place values to unique Fibonacci numbers (one is \"1\" and not \"10\"), we can imagine a similar algorithm to the one presented earlier.\nThat is, we can derive an expansion for a number by subtracting out the largest Fibonacci number less than it (possibly multiple times) and repeating with the remainder.\nExpansions of the integers up to 10 are:\n\n:::: {.row .text-center width=\"50%\"}\n::: {#canonical-zeckendorf-table .column}\n\n| *n* (Decimal) | *n* (Fibonacci) |\n|--------------:|----------------:|\n| 0 | 0 |\n| 1 | 1 |\n| 2 | 10 |\n| 3 | 100 |\n| 4 | 101 |\n| 5 | 1000 |\n| 6 | 1001 |\n| 7 | 1010 |\n| 8 | 10000 |\n| 9 | 10001 |\n| 10 | 10010 |\n\n:::\n::::\n\nThese are known as *Zeckendorf expansions*.\n\nThese representations seem very similar to the phinary strings above.\nNot only that, but this sequence is also the sequence of all binary strings that do not contain two consecutive \"1\"s ([OEIS A014417](https://oeis.org/A014417)).\nThis representation is exactly as arbitrary as preferring the greedy phinary representation;\ninstead, this is the \"greedy series expansion\" of an integer in the Fibonacci numbers.\n\n### Expanding Two, Again\n\nBecause of the relationship between phi and the Fibonacci numbers, we have the familiar relation\n\n$$\n\\begin{align*}\n 2 F_n &= F_{n+1} + F_{n-2} \\\\\n 0200_{Z} &= 1001_{Z}\n\\end{align*}\n$$\n\nFor small $n$, this identity seems wrong, but it can in fact be justified:\n\n$$\n\\begin{array}{c|ccccc:cc}\n & 8 & 5 & 3 & 2 & 1 & 1 & \\sim \\\\ \\hline\n 2 & & & & & 2 & & \\\\\n & & & & 1 & 0 & 0 & 1 \\\\\n & & & & 1 & 0 \\\\ \\hline\n 4 & & & & 2 & 0 & & \\\\\n & & & 1 & 0 & 0 & 1 & \\\\\n & & & 1 & 0 & 1\n\\end{array}\n$$\n\nIn the expansion of 2, the rightmost \"1\" seems to underflow.\nHowever, in the expansion of 4, we must consider the second \"1\" in the negative first place value.\nIt acts as a sort of temporary storage which is immediately transferred into place value zero.\n\n\nSynthesis: Generalizing Phinary\n-------------------------------\n\nBy starting with the golden ratio base, many natural questions arise.\nDoes this approach work with other quadratic roots?\nAre there any restrictions on the coefficients (or sequences)?\nDoes it work with any polynomial with positive roots?\nAre only monic polynomials allowed to be used?\nWhat digits are minimally necessary to represent any integer?\nHow \"canonical\" can \"canonical\" really be?\n\nRather than answering these questions or giving proofs, I think it's best to lay some ground rules.\nUsing the above examples, I define two genera of positional number systems:\n\n- A *fractional* number system is one where the place values are determined by the powers of the root of a polynomial with integer coefficients.\n The \"fraction\" in fractional comes allowing negative powers of our base.\n Therefore, we can represent rational numbers and use a fractional separator.\n - Naturally, the decimal system currently in use fits in here, corresponding to the polynomial $x - 10$.\n - Likewise, phinary corresponds to the polynomial $x^2 - x - 1$.\n\n- An *integral* number system is one where the place values are given by a strictly increasing integral sequence.\n It can express only integers and there is no fractional separator.\n\n - As an example, the geometric series produced from an integer (e.g.: 1, 2, 4, 8, …), corresponds to a typical system without support for fractions.\n\n - The already-discussed the Fibonacci base fits here as well.\n In fact, since linear recurrence relations correspond to polynomials, this extends to a correspondence between integral and fractional systems.\n\n - Other sequences are also valid, like the square numbers.\n In the \"square number base\" we know the digital root (of canonical expansions) never exceeds 4 due to\n [Lagrange's four-square theorem](https://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem).\n\n\n### Alphabets\n\nA positional number system not only has place values, but a *numeral alphabet*.\nIn standard decimal, there are ten distinct symbols including \"0\": {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.\nThe choice of symbols is arbitrary\n (it can vary [with](https://en.wikipedia.org/wiki/Eastern_Arabic_numerals) [language](https://en.wikipedia.org/wiki/Chinese_numerals)),\n but each has a *weight*, the integer quantity assigned to them.\nIn the modern Western world, [Hindu-Arabic numerals](https://en.wikipedia.org/wiki/Hindu%E2%80%93Arabic_numeral_system) are standard and distinct from alphabetic characters,\n so the distinction between \"weight\" and \"symbol\" can be ignored by using them conventionally for the first ten whole numbers.\nSubsets of this alphabet include the binary alphabet, {0, 1}, and the ternary alphabet, {0, 1, 2}.\n\nA *minimal alphabet* for a number system is an alphabet of the smallest size which can still represent every integer.\nIt is most convenient to consider an alphabet of integers from 0 up to a particular value,\n even though it may be true that minimal alphabets might exist which \"skip\" over certain weights.\n\nIt is often useful to be able to borrow a symbol of a certain weight, even if it would not be present in a minimal alphabet\n (for example, using \"2\" when it is convenient to do so, as above).\n In this manner, it is also possible to interpret the representation of a number in one base in another arbitrary base.\n\n*Balanced alphabets* also exist, which contain negative numeral weights.\nFor example, the balanced ternary alphabet consists of the weights of $\\{-1, 0, 1\\}$.\nPowers of 3 always determine the place values in ternary, but expansions change to suit the alphabet.\nTo conserve horizontal space, I'll use the symbols $\\bar{1}$ and \"T\" to signify -1.\n\n\n### Canonicity\n\nFinding the *canonical expansion* of a number should be as simple as incrementing the 0th place value and aggressively applying the carry.\nFor fractional systems, this amounts to adding one the 1's digit, and for integral ones, adding it to the rightmost.\n\nNote that irrational systems have at least *two* carry rules.\nIn phinary, these are the \"011\" = \"100\" rule, and the \"0200\" = \"1001\" rule.\n\n\n### Questions About the Above Rules\n\nOne may take several exceptions with these definitions and the restrictions they impose, to which I will offer a brief dismissal:\n\n\n#### Why limit alphabet weights to integers?\n\nIntegers and integer arithmetic are fundamental systems with very straightforward addition and multiplication.\nAdding more complex rules by introducing fractions or polynomial roots creates unnecessary complications.\n\n#### Why prefer weights of integers from 0 to n?\n\nAlphabets are best kept inductive -- either a weight is the largest possible or its successor is also a weight.\nIf we start with a negative weight, this includes balanced alphabets.\n\nUnbounded alphabets have their uses.\nFor example, we might hold off from carrying until necessary, or prefer expansions like\n $21_\\varphi = 1 + 2\\varphi$ to $21_\\varphi = 1000_\\varphi = \\varphi^4$.\n\nThe inductive base case, the binary alphabet, is fairly important for two reasons:\n\n- Expansions can always be padded with 0s to produce other valid expansions.\n- If \"1\" does not exist in the alphabet, it should be derivable in some way from other symbols like \"2\" and \"3\".\n\n\n#### Do we prefer monic polynomials?\n\nThe recurrence relation corresponding to a non-monic polynomials must cycle mod the leading term.\nThe simplest (only?) examples are just geometric series; in other words, normal integral systems.\n\nFor example, the powers of 3 satisfy $2a_{n+1} = 5a_n + 3a_{n-1}$. But the RHS simplifies:\n\n$$\n2a_{n+1} = 5a_n + 3a_{n-1} = 5a_n + a_n = 6a_n \\\\\na_{n+1} = 3a_n\n$$\n\nIncidentally, 3 is a root of $2x^2 - 5x - 3$.\nFermat's little theorem is likely a component in proving this generally.\n\n\n#### Why exclude transcendentals from fractional systems?\n\nConvergent series like $\\exp{x}$ require coefficients which shrink quickly, far below a magnitude of 1.\nThis conflicts with our expectation of counting polynomials to be integral polynomials.\nThis is disappointing, since relatively simple (in terms of continued fractions, combinatorics, etc) transcendental like $e$ relies on a series in rationals.\n\n\nClosing\n-------\n\nWith these restrictions in mind, I wrote a simple Haskell library to help explore these systems (found [here](https://github.com/queue-miscreant/GenBase)).\nThe [next post](../2) will discuss quadratic polynomials with larger coefficients than 1, and problems not discussed with higher expansions.\n\n", + "supporting": [ + "index_files" + ], + "filters": [], + "includes": {} + } +} \ No newline at end of file diff --git a/_freeze/polycount/3/index/execute-results/html.json b/_freeze/polycount/3/index/execute-results/html.json new file mode 100644 index 0000000..cc45b74 --- /dev/null +++ b/_freeze/polycount/3/index/execute-results/html.json @@ -0,0 +1,12 @@ +{ + "hash": "3ce9c87a34928281a8934daca818c9e4", + "result": { + "engine": "jupyter", + "markdown": "---\ntitle: \"Polynomial Counting 3: The third degree\"\nformat:\n html:\n html-math-method: katex\ndate: \"2021-02-06\"\ndate-modified: \"2025-02-08\"\njupyter: python3\ncategories:\n - algebra\n - phinary\n - binary\n - python\n---\n\n\n\nThis post assumes you have read the [first](../1) post, which introduces generalized positional counting, and the [second](../2), which restricts the focus and specifies the general aim.\n\nThus far, the systems have been based on quadratic polynomials and two-term linear recurrences,\n or more directly, carries of width two.\nNumbers larger than one introduce certain complications to carries.\nWith that in mind, let's go back to things closer to phinary and Fibonacci.\n\n\nTribonacci and Beyond\n---------------------\n\nThe *Tribonacci numbers* ([OEIS A000073](http://oeis.org/A000073)) come from elongating the Fibonacci recurrence to 3 terms.\nIn other words, this is the carry/recurrence $\\langle 1,1,1|$.\nThe Tribonacci numbers are seeded with two zeros followed by a single one; thus, the sequence begins $0, 0, 1, 1, 2, 4, 7, 13,\\dots$\nThe *Tribonacci constant* is the limiting ratio of these numbers (i.e., the positive real root of $x^3 - x^2 - x - 1$) with approximate value\n $T = 1.8393\\dots$\n\nThe number two bounds both this number and the terms in the recurrence, so its expansion can be deduced:\n\n$$\n\\textcolor{red}{2} = 1.\\textcolor{red}{111}_T = \\textcolor{blue}{1.11}1_T = \\textcolor{blue}{1}0.001_T\n$$\n\nNaturally, the string \"111\" will be illegal in both systems.\nThe Tribonacci expansions of the integers are as follows:\n\n:::: {.row .text-center width=\"60%\"}\n::: {#canonical-tribonacci-table .column}\n\n| *n* (Decimal) | *n* (base $T$) | *n* (Tribonacci) |\n|--------------:|:--------------:|------------------|\n| 0 | 0 | 0 |\n| 1 | 1 | 1 |\n| 2 | 10.001 | 10 |\n| 3 | 11.001 | 11 |\n| 4 | 100.100011 | 100 |\n| 5 | 101.100011 | 101 |\n| 6 | 110.101011 | 110 |\n| 7 | 1000.101011 | 1000 |\n| 8 | 1001.101011 | 1001 |\n| 9 | 1010.110100011 | 1010 |\n| 10 | 1100.010100011 | 1011 |\n\n:::\n::::\n\nSince \"111\" is a rarer string than \"11\", the integral base more closely resembles standard binary.\n\nExtensions of the Fibonacci numbers, which have an $n$-term recurrence\n (seeded with $n - 1$ zeroes followed by a one) are called \"n-nacci\" or \"n-bonacci\" numbers.\nIf we discard the seeding terms, then for larger and larger *n*, this sequence of sequences appears\n to approach the powers of two.\n\n$$\n\\begin{matrix}\n \\text{Fibonacci: } & & & 0,& 1,& 1,& 2,& 3,& 5,& 8\\dots \\\\\n \\text{Tribonacci: } & & 0,& 0,& 1,& 1,& 2,& 4,& 7,& 13\\dots \\\\\n \\text{Tetranacci: } & 0,& 0,& 0,& 1,& 1,& 2,& 4,& 8,& 15\\dots \\\\\n \\vdots \\\\\n \\text{Binary: } & (\\dots,& 0,& 0,& 1,)& 1,& 2,& 4,& 8,& 16\\dots\n\\end{matrix}\n$$\n\nIn the limit, the rightmost and leftmost \"1\"s in the carry $\\langle 1, 1, ..., 1, 1 |$ are\n infinitely far away from each other.\nThis is similar to binary, in which $2 = 1.1111\\dots_2$.\nThis argument is clearer if we directly manipulate the carry as a polynomial $p_n(x)$:\n\n$$\n\\begin{align*}\np_n &= x^n - x^{n-1} - … - x - 1 \\\\\n-p_n &= -x^n + x^{n-1} + … + x + 1 \\\\\nx^n - p_n &= x^{n-1} + … + x + 1 \\\\\nx - p_n x^{-n+1} &= 1 + x^{-1} + … x^{-n+2} + x^{-n+1} \\\\[8pt]\n\\text{Let } n &\\rightarrow \\infty \\\\\nx &= 1 + x^{-1} + x^{-2} + x^{-3} + …\n\\end{align*}\n$$\n\nSince both *φ* and $T$ are greater than 1, we can assume that $x > 1$, which causes the\n $x^{-n+1}$ term to vanish in the limit.\nUnfortunately, this means $p_n$ should diverge, invalidating the above argument.\n\nIgnoring this, the last line can be manipulated as a power series:\n\n$$\n\\begin{align*}\n\\frac{1}{1 - x} &= 1 + x + x^2 + x^3 + \\dots \\\\\n\\frac{1}{1 - (1/x)} &= 1 + x^{-1} + x^{-2} + x^{-3} + \\dots \\\\\nx &= \\frac{1}{1- (1/x)} \\\\\nx - 1 &= 1 \\\\\nx &= 2\n\\end{align*}\n$$\n\nWhich is to imply that, in a non-rigorous sense and by partially assuming the conclusion,\n that the $n$-nacci constants approach two.\n\n\nGolder than Gold\n----------------\n\nAll carries entirely made up of \"1\"s correspond to the $n$-nacci constants.\nWhile this would appear to exhaust every sequence without going to negative numbers,\n it ignores the potential of carries with a \"0\".\n\nStarting simple, Narayana's cows sequence ([OEIS A000930](http://oeis.org/A000930)) corresponds to\n the recurrence $\\langle 1,0,1|$.\nIt may be seeded with either three 1's, or in the same way as above, with a sequence of 0's followed by a 1.\nThe limiting ratio $\\psi \\approx 1.4656\\dots$ is called the supergolden ratio.\nThe introduction of \"0\"s turns out to have big implications, since the concatenation trick to devise\n the expansion of two no longer works.\nHowever, hope is not lost.\n\n$$\n\\begin{gather*}\n 1\\textcolor{red}{1}000_\\psi\n = 10\\textcolor{red}{101}_\\psi\n = \\textcolor{blue}{101}01_\\psi\n = \\textcolor{blue}{1}00001_\\psi \\\\\n \\textcolor{red}{2} = 1.\\textcolor{red}{101}_\\psi\n = \\textcolor{blue}{1.1}01_\\psi\n = \\textcolor{blue}{1}0.001\\textcolor{blue}{1}_\\psi\n = 10.00\\textcolor{purple}{11}_\\psi\n = 10.0\\textcolor{purple}{1}0000\\textcolor{purple}{1}_\\psi\n\\end{gather*}\n$$\n\nIncredibly, the carry contains not only an explicit rule for \"101\", but implicit rules \"2\" and \"11\".\nThis sort of makes sense: since $\\psi < \\varphi$, adjacent place values are \"too dense\",\n and therefore we can rewrite the string \"11\".\nOn the other hand, attempting to manipulate \"1001\" and \"10001\" results in circuiting back to the original string.\n\n$$\n\\begin{split}\n 100\\textcolor{red}{1}000000_\\psi\n &= 1000\\textcolor{red}{101}000_\\psi\n = 1000\\textcolor{orange}{1}01000_\\psi\n = 10000\\textcolor{orange}{1}1\\textcolor{orange}{1}00_\\psi \\\\\n &= 10000\\textcolor{blue}{11}100_\\psi\n = 1000\\textcolor{blue}{1}0010\\textcolor{blue}{1}_\\psi\n = 1000100\\textcolor{red}{101}_\\psi \\\\\n &= 100010\\textcolor{red}{1}000_\\psi\n = 1000\\textcolor{orange}{101}000_\\psi\n = 100\\textcolor{orange}1000000_\\psi \\\\ \\\\\n \\textcolor{red}{1}0001000_\\psi\n &= 0\\textcolor{red}{101}1000_\\psi\n = 010\\textcolor{blue}{11}000_\\psi\n = 01\\textcolor{blue}{1}0000\\textcolor{blue}{1}_\\psi \\\\\n &= 0\\textcolor{purple}{11}00001_\\psi\n = \\textcolor{purple}{1}0000\\textcolor{purple}{1}01_\\psi \\\\\n &= 10000\\textcolor{red}{101}_\\psi = 1000\\textcolor{red}{1}000_\\psi\n\\end{split}\n$$\n\nI call these strings of \"0\"s sandwiched between \"1\"s *spacings*.\nThe smallest spacing, with a width of zero, is the Fibonacci recurrence.\nIf we forbid both the width-1 and width-0 spacings from appearing in supergolden expansions,\n we obtain the following list:\n\n:::: {.row .text-center width=\"60%\"}\n::: {#canonical-supergolden-table .column}\n\n\n\n| *n* (Decimal) | *n* (base $\\psi$) |\n|--------------:|:-------------------:|\n| 0 | 0 |\n| 1 | 1 |\n| 2 | 10.0100001 |\n| 3 | *100.0110001* |\n| 3 | 100.1000100001 |\n| *4* | *110.0001100001* |\n| 4 | 1000.1000100001 |\n| *5* | *1010.0001100001* |\n| 5 | 10000.0010001 |\n| 6 | 10001.0010001 |\n| *7* | *10010.0110002* |\n| *7* | *10010.1000012* |\n| 7 | 100000.0001000001 |\n| 8 | 100001.0001000001 |\n| 9 | 100100.0000001001 |\n| 10 | 1000000.0000001001 |\n\n:::\n::::\n\nIn the above table, some intermediate steps are shown in red,\n but the last entry for each integer is canonical.\nNot only does the number of digits grow radically faster than in phinary (or even binary),\n but there are many more intermediate steps.\n\nFor space reasons, I do not show the integral dual.\nSlowly-growing sequences, which have largely uninteresting integral systems, dominate the rest of this post.\nTherefore, the remainder of this post will focus solely on fractional systems.\n\n\nRadiant Plastic\n---------------\n\nA similar degree 3 recurrence is $\\langle 0,1,1|$.\nIts root corresponds to the plastic ratio $\\rho \\approx 1.3247\\dots$.\nA number of sequences share this recurrence; when seeded with $0, 0, 1$ as before,\n the best match is the Padovan sequence ([OEIS A000931](http://oeis.org/A000931)),\n which begins with an additional one.\n\nSince $\\rho < \\psi < \\varphi$, we should expect that spacings of at least width two are illegal.\nThe system turns out to be even stricter than that: spacings up to and including width three are expandable.\n\n$$\n\\begin{array}{c|c}\n \\text{Width} & \\textcolor{red}{0} & \\textcolor{green}{1} & 2 & \\textcolor{blue}{3} \\\\ \\hline\n & 0\\textcolor{red}{011}_\\rho\n & 010\\textcolor{red}{1}000_\\rho\n & 0\\textcolor{red}{1}00\\textcolor{red}{1}00000_\\rho\n & 0\\textcolor{red}{1}0001_\\rho\n \\\\\n & \\textcolor{red}{1}000_\\rho\n & 0100\\textcolor{red}{011}_\\rho\n & 00\\textcolor{red}{011}\\textcolor{red}{011}00_\\rho\n & 00\\textcolor{red}{011}1_\\rho\n \\\\\n && 0\\textcolor{blue}{10001}1_\\rho\n & 000\\textcolor{blue}{11011}00_\\rho\n & 000\\textcolor{orange}{111}_\\rho\n \\\\\n && \\textcolor{blue}{1}000001_\\rho\n & 00\\textcolor{blue}{1}0101000_\\rho\n & 00\\textcolor{orange}{1}100_\\rho\n \\\\\n &&\n & 0010\\textcolor{green}{101}000_\\rho\n & 0\\textcolor{red}{011}00_\\rho\n \\\\\n &&\n & 001\\textcolor{green}{1000001}_\\rho\n & \\textcolor{red}{1}00000_\\rho\n \\\\\n &&\n & 0\\textcolor{red}{011}000001_\\rho\n \\\\\n &&\n & \\textcolor{red}{1}000000001_\\rho\n \\\\\\\\\n \\hline\n & s_0 = \\rho^2\n & s_1 = \\rho s_{5}\n & s_2 = \\rho s_{8}\n & s_3 = \\rho\n\\end{array}\n$$\n\nThe final line is shorthand for the spacing rules:\n\n- The zero-spacing is equal to a one in the place value two higher than it\n- The one-spacing is equal to an five-spacing which begins one place value higher than it\n- The two-spacing is equal to an eight-spacing which begins one place value higher than it\n- The three-spacing is equal to a one in the place value one higher than it\n\nWith these rules, we can write a canonical expansion expansion for 2:\n\n$$\n\\begin{align*}\n \\textcolor{red}{2}\n &= 1.\\textcolor{red}{011}\n = \\textcolor{blue}{1.011}\n = \\textcolor{blue}{1}\\overbrace{0.0100000}^{8 \\text{ digits}}\\textcolor{blue}{1} \\\\\n &= \\textcolor{purple}{10.01}000001\n = \\textcolor{purple}{1}00.000000\\textcolor{purple}{1}1 \\\\\n &= 100.00000\\textcolor{red}{011}\n = 100.0000\\textcolor{red}{1}\n\\end{align*}\n$$\n\nSince $\\rho < \\sqrt 2$, the largest place value in the expansion of two is $\\rho^2$, which\n distinguishes it from previous systems.\n\nSimilarly to how the width-two and width-three spacings are allowed in the supergolden ratio base,\n we realize that the width-four spacing cannot be expanded further in the plastic ratio base:\n\n$$\n\\begin{align*}\n \\textcolor{red}{1}0000\\textcolor{red}{1}000\n &= 0\\textcolor{red}{011}00\\textcolor{red}{011}\n = 001\\textcolor{blue}{10001}1\n = 00\\textcolor{blue}{2}000001 \\\\\n &= \\textcolor{blue}{1}000000\\textcolor{blue}{1}1\n = 100001000\n\\end{align*}\n$$\n\nWith these implicit rules derived for spacings of width smaller than three,\n the plastic expansions of the integers up to ten are as follows:\n\n:::: {.row .text-center width=\"70%\"}\n::: {#canonical-plastic-table .column}\n\n\n\n| *n* (Decimal) | *n* (base $\\rho$) |\n|--------------:|:----------------------------:|\n| 0 | 0 |\n| 1 | 1 |\n| 2 | 100.00001 |\n| *3* | *101.00001* |\n| *3* | *1000.00101* |\n| 3 | 1000.01000001 |\n| *4* | *10000.0101000000001* |\n| 4 | 10000.1000001000001 |\n| *5* | *10100.0000001000001* |\n| 5 | 100000.1000001000001 |\n| *6* | *100001.1000001000001* |\n| *6* | *100100.0000001000001* |\n| *6* | *1000000.0010001000001* |\n| 6 | 1000000.0100000000001 |\n| *7* | 1000001.0100000000001 |\n| 7 | 1000010.0000100000001 |\n| *8* | *1001000.0000100000001* |\n| *8* | *10000000.0100100000001* |\n| *8* | *10000000.1000000001001* |\n| 8 | 10000000.100000001000000001 |\n| 9 | 10000100.000000001000000001 |\n| 10 | 10001000.001000001000000001 |\n\n:::\n::::\n\nClearly, this base is incredibly sensitive.\nA number as small as 8 has a fractional part as small as $\\rho^{-18}$ in its expansion.\n\n\nSkipped Spacings\n----------------\n\nWhen discussing the expandable spacings in the supergolden and plastic bases, they jumped from\n width one to width three.\nDid we forgot width 2?\nThe strings \"1001\" and \"10001\" are associated to the carries\n $\\langle 1, 0, 0, 1|$ and $\\langle 1, 0, 0, 0, 1|$.\n\n| Spacing Width | Carry | Integral Sequence | Root |\n|---------------|--------------------------------------------|------------------------------------------|---------------------------|\n| 0 | $\\langle 1,1|$ | Fibonacci numbers, Lucas numbers | Golden Ratio, $\\varphi$ |\n| 1 | $\\langle 1,0,1|$ | Narayana's cows sequence | Supergolden Ratio, $\\psi$ |\n| 2 | $\\langle 1,0,0,1|$ | [OEIS A003269](https://oeis.org/A003269) | Unnamed $(\\upsilon?)$ |\n| 3 | $\\langle 1,0,0,0,1| \\simeq \\langle 0,1,1|$ | Padovan sequence, Perrin sequence | Plastic Ratio, $\\rho$ |\n\nI chose the symbol $\\upsilon$ since it came from the second half of the Greek alphabet,\n like the others.\n\nWhile the width-two spacing is a irreducible polynomial like its predecessors,\n the width-three one can be factored\n\n::: {#aae758ce .cell execution_count=2}\n``` {.python .cell-code}\nfrom sympy.abc import x\n\ndef spacing(width):\n return x**(width + 2) - x**(width + 1) - 1\n\nspacing(3).factor()\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=2}\n$\\displaystyle \\left(x^{2} - x + 1\\right) \\left(x^{3} - x - 1\\right)$\n:::\n:::\n\n\nThis also means that despite $\\rho$ and $\\psi$ being cubic roots,\n $\\upsilon$ is irreducibly a quartic root, despite being between them in terms of spacing width.\n\nThe right polynomial may be familiar from the previous post as $\\langle 1, -1 |$,\n which only has complex roots.\nIt happens to be the sixth cyclotomic polynomial ($\\Phi_6$), and allows the width-three spacing\n to be equivalent to the simpler plastic ratio carry.\n\nAs previously stated, the cyclotomic polynomials cause big trouble for carries.\nOther than factoring, there appears to be no way to derive $\\langle 0,1,1|$ from $\\langle 1,0,0,0,1|$.\nAt best, we can observe the following:\n\n$$\n\\begin{matrix}\n \\langle 1,0,0,0,1| && \\langle 0,1,1| \\\\ \\hline\n 11111 &\\iff& 11111 \\\\\n 101110 && 1000111 \\\\\n 1001100 &\\iff& 1001100 \\\\\n 10001000 && 1100000 \\\\\n 100000000 &\\iff& 100000000 \\\\\n\\end{matrix}\n$$\n\n\n### Chopped Circles\n\nThe appearance of a cyclotomic factor is not unique to the width-three spacing.\nEach of the smaller-width rules in the supergolden and plastic bases can be reexamined as polynomials.\nAfter converting and factoring, their cyclotomic factors become clear:\n\n$$\n\\begin{gather*}\n 11000_\\psi = 100001_\\psi \\\\\n 1\\bar{1}\\bar{1}001_\\psi = 0 \\\\\n \\psi^5 - \\psi^4 - \\psi^3 + 1 \\\\\n (\\psi - 1)(\\psi + 1)(\\psi^3 - \\psi^2 - 1) \\\\\n \\Phi_1 \\Phi_2 \\langle 1,0,1|\n \\\\ \\\\\n \\begin{gather*}\n 101000_\\rho = 1000001_\\rho &\n 100100000_\\rho = 1000000001_\\rho \\\\\n 1\\bar{1}0\\bar{1}001_\\rho = 0 &\n 1\\bar{1}00\\bar{1}00001_\\rho = 0 \\\\\n \\rho^6 - \\rho^5 - \\rho^3 + 1 &\n \\rho^9 - \\rho^8 - \\rho^5 + 1 \\\\\n (\\rho - 1)(\\rho^2 + 1)(\\rho^3 - \\rho - 1) &\n \\dots(\\rho^2 - \\rho + 1)(\\rho^3 - \\rho - 1) \\\\\n \\Phi_1 \\Phi_4 \\langle 0,1,1| &\n \\Phi_1 \\Phi_2 \\Phi_4 \\Phi_6 \\langle 0,1,1|\n \\end{gather*}\n\\end{gather*}\n$$\n\nThough I am uncertain without a proof, it seems that cyclotomic polynomials\n play a role in spacing out \"1\"s.\nThis is to say that spacings have a \"fundamental\" irreducible polynomial.\nBy multiplying certain cyclotomic polynomials by the fundamental, (all?) smaller spacings\n can produce spacings the size of the fundamental or less.\n\nNaturally, I attempted to write a program to compute lesser spacings from an implicit rule.\nGenerally, this entailed assembling all lesser spacings, then expanding the rightmost 1\n if unable to find any spacing, else replacing and continuing.\nUnfortunately, since it operates in lockstep, it gets stuck easily, and I had little success.\nMy Haskell code can be found [here](zero_spacing.hs).\n\n### Inherently Factorable Spacings\n\nThe width-three spacing is not fundamental, since it can be factored.\nWe can collect reducible spacings into a table:\n\n::: {#6f97736a .cell execution_count=3}\n``` {.python .cell-code}\nis_irreducible = lambda p: len(p.factor().as_ordered_factors()) == 1\ndisplay = lambda x: color(\"green\", \"Yes\") if x else color(\"red\", \"No\")\n\nMarkdown(tabulate(\n zip(*(\n [[\"*n*\", \"Irreducible?\"]]\n + [[ str(i), display(is_irreducible(spacing(i))) ] for i in range(20)]\n ))\n))\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=3}\n------------ ------------------------------------- ------------------------------------- ------------------------------------- ---------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ---------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ---------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- -------------------------------------\n*n* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\nIrreducible? Yes Yes Yes No Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes No Yes Yes Yes Yes\n------------ ------------------------------------- ------------------------------------- ------------------------------------- ---------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ---------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ---------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- -------------------------------------\n:::\n:::\n\n\nIn the range given, this table appears to repeat every six terms.\nWe can examine each of these factors directly:\n\n$$\n\\begin{align*}\n x^5 - x^4 - 1 &= (x^2 - x + 1)\n (x^3 - x - 1) \\\\\n &= 1\\bar{1}1_x * 10\\bar{1}\\bar{1}_x \\\\\n x^{11} - x^{10} - 1 &= (x^2 - x + 1)\n (x^9 - x^7 - x^6 + x^4 + x^3 - x - 1) \\\\\n &= 1\\bar{1}1_x * 10\\bar{1}\\bar{1}0110\\bar{1}\\bar{1}_x \\\\\n x^{17} - x^{16} - 1 &= (x^2 - x + 1)\n (x^{15} - x^{13} - \\dots + x^4 + x^3 - x - 1) \\\\\n &= 1\\bar{1}1_x * 10\\bar{1}\\bar{1}0110\\bar{1}\\bar{1}0110\\bar{1}\\bar{1}_x \\\\\n 5, 11, 17, \\dots &= 6n + 5\n\\end{align*}\n$$\n\nEach of these polynomials has $\\Phi_6$ as a common factor.\nThe other factor appears to be a truncation of the repeating string \"$\\underline{0110\\bar{1}\\bar{1}}$\".\n^[Since I already use the overbar for negative digits, I gather repeating terms using an underline as a vinculum.]\nInterpreted as a power series, this is the reciprocal of $-\\Phi_6$ ([OEIS A010892](https://oeis.org/A010892)).\n\nAs the carry approaches infinite width, the $x$ terms go to 0 for $x < 1$.\nThis shows that like the $n$-nacci constants approach two, the spacing constants approach one.\n\n\nRepeating Expansions\n--------------------\n\nLet's not get too eager here and instead return to base $\\upsilon$.\nIt should be possible to expand the strings \"11\" and \"101\", since it is the fundamental spacing of width 2.\nHowever, we immediately run into an issue:\n\n$$\n\\begin{array}{c|c}\n \\text{Width} & \\textcolor{green}{0} & \\textcolor{blue}{1} & \\textcolor{red}{2} \\\\ \\hline\n & 01\\textcolor{red}{1}00000_\\upsilon\n & 010\\textcolor{red}{1}0000_\\upsilon\n & 0\\textcolor{red}{1001}_\\upsilon\n \\\\\n & 010\\textcolor{red}{1001}0_\\upsilon\n & 0100\\textcolor{red}{1001}_\\upsilon\n & \\textcolor{red}{1}0000_\\upsilon\n \\\\\n & 0\\textcolor{blue}{101}0010_\\upsilon\n & 0\\textcolor{orange}{1001}001_\\upsilon\n \\\\\n & \\textcolor{blue}{1}000001\\textcolor{blue}{1}_\\upsilon\n & \\textcolor{orange}{1}0000001_\\upsilon\n \\\\\n & 100000\\textcolor{green}{11}_\\upsilon \\\\\n & \\vdots \\\\ \\hline\n & s_0 = \\ ? & s_1 = \\rho s_6 & s_2 = \\rho\n\\end{array}\n$$\n\nThe width-0 expansion is recursive.\nIf we continue to apply its rule, we generate the string \"100001\" repeating.\nFortunately, each repeating unit is a width-four spacing, which is allowed by the carry.\n\nRepeating expansions imply a representation by geometric series:\n\n$$\n\\begin{gather*}\n 1.\\underbrace{\\underline{0\\dots1}}_{n}{}_x = 1 + x^{-n} + x^{-2n} + x^{-3n} + \\dots\n = \\frac{1}{1 - (1/x)^n} = \\frac{x^n}{x^n - 1}\n \\\\\n 10 = 1.\\underbrace{\\underline{0\\dots1}}_{n}{}_x ~\\iff~ x = \\frac{x^n}{x^n - 1} \\\\\n 1 = \\frac{x^{n-1}}{x^n - 1} \\\\ \\\\\n x^{n-1} = x^n - 1\n\\end{gather*}\n$$\n\nThe final expression is just the definition of a carry, so we can immediately write:\n\n$$\n\\begin{align*}\n 10_\\varphi &= 1.\\underline{01}_\\varphi & &\n \\text{Carry } \\langle 1,1| \\\\\n 10_\\psi &= 1.\\underline{001}_\\psi & &\n \\text{Carry } \\langle 1,0,1| \\\\\n 10_\\upsilon &= 1.\\underline{0001}_\\upsilon & &\n \\text{Carry } \\langle 1,0,0,1| \\\\\n 10_{\\rho} &= 1.\\underline{00001}_\\rho & &\n \\text{Carry } \\langle 1,0,0,0,1| = \\langle 0,1,1|\n\\end{align*}\n$$\n\nThis neatly ties repeating spacings in with carries.\n^[Recall that when we naively computed ten in base phi, we got \"10100.0100101010101010101\".\nAfter a certain point, this expansion alternates between 0 and 1. Assuming that this is true repetition\nand applying $10_\\varphi = 1.\\underline{01}_\\varphi$, one obtains \"10100.0101\", which is canonical. ]\n\nBut we didn't want \"10\" as a repeating expansion, we wanted \"11\".\nAttempting to justify with the same strategy:\n\n$$\n\\begin{align*}\n 0.11_\\upsilon &= 1.\\underline{00001}_\\upsilon & \\text{Carry } \\langle 1,0,0,1|\n \\\\\n \\frac{1}{x} + \\frac{1}{x^2} &= \\frac{x^n}{x^n - 1} \\\\\n x + 1 &= \\frac{x^{n+2}}{x^n - 1}\n \\\\[8pt]\n x^{n+1} + x^n - x - 1 &= x^{n+2} \\\\\n x^{n+2} - x^{n+1} - x^n + x + 1 &= 0 \\\\\n x^n(x^2 - x - 1) + x + 1 &= 0\n\\end{align*}\n$$\n\n::: {#83a45569 .cell execution_count=4}\n``` {.python .cell-code}\nrepeating_pair = lambda n: (x**n * (x**2 - x - 1) + x + 1).expand().factor()\n\nMarkdown(tabulate(\n zip(*(\n [[\"*n*\", \"Irreducible?\"]]\n + [[ str(i), display(is_irreducible(repeating_pair(i))) ] for i in range(1, 10)]\n ))\n))\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=4}\n------------ ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ---------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- -------------------------------------\n*n* 1 2 3 4 5 6 7 8 9\nIrreducible? Yes Yes Yes Yes No Yes Yes Yes Yes\n------------ ------------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- ---------------------------------- ------------------------------------- ------------------------------------- ------------------------------------- -------------------------------------\n:::\n:::\n\n\nFor $n$ = 5, the polynomial factors as the product of $\\langle 1, 0, 0, 1|$ and $\\langle 0, 1, 1|$.\nThe second factor should come as no surprise since we know directly that $0.11_\\rho = 10_\\rho$\n and we already evaluated $10_{\\rho} = 1.\\underline{00001}_\\rho$\n\nChecking more $n$, this polynomial actually seems to be the only reducible one for quite a while.\n\n::: {#3a22f178 .cell freeze='true' execution_count=5}\n``` {.python .cell-code}\nall(is_irreducible(repeating_pair(i)) for i in range(10, 100))\n```\n\n::: {.cell-output .cell-output-display execution_count=5}\n```\nTrue\n```\n:::\n:::\n\n\nThis bestows some level of intrigue upon the repeating expansion of \"11\".\nSince repeating expansions are required for base $\\upsilon$ I will elect to not show the expansion of the integers.\n\n\n### Weird Modulus Patterns\n\nThis can be generalized slightly to match any spacing with any repeating spacing:\n\n$$\n\\begin{gather*}\n 0.\\underbrace{10\\dots01}_m = 1.\\underbrace{\\underline{0\\dots01}}_n\n ~\\Leftrightarrow~\n \\frac{1}{x} + \\frac{1}{x^m} = \\frac{x^n}{x^n - 1}\n \\\\\n x^{m-1} + 1 = \\frac{x^{n+m}}{x^n - 1} \\\\\n \\\\\n x^{n+m-1} + x^n - x^{m-1} - 1 = x^{n+m}\\\\\n x^{n+m} - x^{n+m-1} - x^n + x^{m-1} + 1 = 0 \\\\\n (x^n)(x^m - x^{m-1} - 1) + x^{m-1} + 1 = 0 \\\\\n\\end{gather*}\n$$\n\nIf the polynomial has factors, then fractional systems where those factors are carries have\n repeating expansions of width $n$ for a spacing of width $m$.\nGraphing the tuples of reducible polynomials produces a strange pattern\n apparently arranged in lines (going from the lower left to the upper right):\n\n::: {#b7068ef6 .cell execution_count=6}\n``` {.python .cell-code}\ngeneral_repeats = lambda m, n: (x**n)*(x**m - x**(m-1) - 1) + x**(m-1) + 1\n\nplt.xticks(range(20))\nplt.yticks(range(20))\nplt.xlabel(\"$m - 1$\")\nplt.ylabel(\"$n - 1$\")\nplt.imshow([\n [ is_irreducible(general_repeats(m + 1, n + 1)) for m in range(20) ]\n for n in range(20)\n])\n```\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-7-output-1.png){width=433 height=429}\n:::\n:::\n\n\nThe leftmost purple square is the exception, which corresponds to the earlier $(m, n) = (2, 5)$.\nEvery purple square here is a reducible polynomial, the first few of whose factors are:\n\n\n| $(m, n)$ | Sum | Polynomial Factors\n|----------|-----|-------------------\n| (2, 5) | 7 | $(x^3 - x - 1) (x^4 - x^3 - 1)$\n| (3, 11) | 14 | $(x^4 - x^3 + x^2 - x + 1)$
$(x^{10} - x^8 - x^7 - x^6 - x^5 + x^3 + x^2 + x + 1)$\n| (7, 7) | | $(x^4 - x^3 + x^2 - x + 1)$
$(x^{10} - x^8 - x^5 + x + 1)$\n| (13, 1) | | $(x^4 - x^3 + x^2 - x + 1)$
$(x^{10} + x^7 - x^5 - x^2 + 1)$\n| (7, 17) | 24 | $(x^4 - x^3 + x^2 - x + 1)$
$(x^{20} - x^{18} - x^{15} - x^{12} + x^{10} + x^7 - x^5 + x + 1)$\n| (13, 11) | | $(x^4 - x^3 + x^2 - x + 1)$
$(x^{20} - x^{18} - x^{15} + x^{13} + x^{10} + \\dots + x + 1)$\n| (17, 7) | | $(x^4 - x^3 + x^2 - x + 1)$
$(x^{20} - x^{18} - x^{15} + x^{13} + x^{12} + \\dots + x + 1)$\n| (17, 17) | | $(x^4 - x^3 + x^2 - x + 1)$
$(x^{30} - x^{28} - x^{25} + x^{23} + x^{20} - x^{18} - \\dots + x + 1)$\n\nOnly the first entry has factor that is a carry associated to a spacing.\nEvery other entry appears to have $(x^4 - x^3 + x^2 - x + 1)$ as a common factor,\n which is the 10th cyclotomic polynomial.\n\nThese solutions also have sums which increment in tens, which correspond to the\n vertical and horizontal lines of purple squares in the image.\nBoth $m$ and $n$ solutions work in a similar way: the symmetric solution (7, 7)\n has similar solutions (7, 17), (17, 7), and (17, 17).\nThis pattern also holds up in the \"next\" terms (7, 27), (17, 27), (27, 27), (27, 17), and (27, 7).\nIt appears as though there is a congruence of $m + n\\ (\\text{mod } mn)$,\n where m and n come from the exception (2, 5).\nThis pattern is similar to the one in which one in every six spacings can be factored.\n\n\nClosing\n-------\n\nIn summary, the Fibonacci recurrence can be generalized in at least two two different ways.\nIntroducing \"0\"s into the carry is more touch-and-go than would otherwise seem,\n though they produce (with much effort) valid bases.\n\nThe [next post](../4) will explore a more distant cousin of the Fibonacci numbers,\n and other strange power series which arise from its discussion.\n\n", + "supporting": [ + "index_files" + ], + "filters": [], + "includes": {} + } +} \ No newline at end of file diff --git a/_freeze/polycount/3/index/figure-html/cell-7-output-1.png b/_freeze/polycount/3/index/figure-html/cell-7-output-1.png new file mode 100644 index 0000000..d714e0f Binary files /dev/null and b/_freeze/polycount/3/index/figure-html/cell-7-output-1.png differ diff --git a/_freeze/polycount/4/index/execute-results/html.json b/_freeze/polycount/4/index/execute-results/html.json new file mode 100644 index 0000000..6487f24 --- /dev/null +++ b/_freeze/polycount/4/index/execute-results/html.json @@ -0,0 +1,12 @@ +{ + "hash": "e6b66233e4bd8354553fa53b3612202a", + "result": { + "engine": "jupyter", + "markdown": "---\ntitle: \"Polynomial Counting 4: Two 2's\"\nformat:\n html:\n html-math-method: katex\ndate: \"2021-02-09\"\ndate-modified: \"2025-02-12\"\njupyter: python3\ncategories:\n - algebra\n - python\n---\n\n\n\n\nThis post assumes you have read [the first](../1), which introduces generalized polynomial counting,\n and [the second](../2), which restricts the focus and specifies the general aim.\n\n\nExtra Metals\n------------\n\nAs previously shown, the golden ratio (recurrence $\\langle 1, 1|$) can be generalized in several ways.\nThe silver ratio was introduced as the next \"metallic mean\",\n a sequence of quadratic roots of the form $\\langle n, 1|$,\n and the limiting ratios of the corresponding recurrences.\n\nThe metallic ratios have simple [*continued fraction*](https://en.wikipedia.org/wiki/Continued_fraction) expansions:\n\n$$\n\\begin{gather*}\n \\langle n, 1| ~~\\iff~~ x^2 - nx - 1 \\\\\n x^2 = nx + 1 ~~\\implies~~\n x = n + \\frac{1}{x} \\\\\n x = n + \\cfrac{1}\n {n + \\cfrac{1}\n {n + \\cfrac{1}\n {n + \\cfrac{1}{\\ddots}}\n }\n }\n = [n; \\underline{n}]\n\\end{gather*}\n$$\n\nAgain, the underline denotes repetition, since the overbar has been used for negation.\n\nParametrizing the carry in both terms (recurrence $\\langle n, n|$) demonstrates a strange duality\n with the above continued fraction:\n\n$$\n\\begin{gather*}\n \\langle n, n| ~~\\iff~~ x^2 - nx - n \\\\\n x^2 = nx + n ~~\\implies~~\n x = n + \\frac{n}{x} \\\\\n x = n + \\cfrac{n}{n + \\cfrac{n}{n + \\cfrac{n}{n + \\cfrac{n}{\\ddots}}}} =\n n + \\cfrac{\\textcolor{red}{\\cancel{n}}}\n {\\textcolor{red}{\\cancel{n}} + \\cfrac{\\textcolor{red}{\\cancel{n}}}\n {n + \\cfrac{\\textcolor{blue}{\\cancel{n}}}\n {\\textcolor{blue}{\\cancel{n}} + \\cfrac{\\textcolor{blue}{\\cancel{n}}}{\\ddots}}\n }\n } \\\\\n x = n + \\cfrac{1}\n {1 + \\cfrac{1}\n {n + \\cfrac{1}\n {1 + \\cfrac{1}{\\ddots}}\n }\n }\n = [n; \\underline{1, n}]\n\\end{gather*}\n$$\n\nIn other words, the root of $\\langle n, 1|$ has continued fraction n repeating,\n and the root of $\\langle n, n|$ has continued fraction $n, 1$ repeating.\n\n\n### Gray Silver\n\nThe golden ratio belongs to both series.\nAfter it, the next term in in the non-metallic series is the recurrence $\\langle 2, 2 |$.\nIt produces the series $0, 1, 2, 6, 16\\dots$ ([OEIS A002605](http://oeis.org/A002605)),\n and the limiting ratio of its successive terms is $1 + \\sqrt 3 \\approx 2.7321\\dots$.\nThis value and the polynomial coefficients are bounded above by 3, so it stands to reason that\n a ternary alphabet is suitable.\nThe trick for expanding 3 works as before:\n\n$$\n\\textcolor{red}{3}00 = 2\\textcolor{red}{22}\n= \\textcolor{blue}{22}2 = \\textcolor{blue}{1}002\n$$\n\n:::: {.row .text-center}\n::: {#canonical-cendree-table .column width=\"60%\"}\n\n| *n*
(Decimal) | *n*
(Unnamed Ratio) | *n*
(Unnamed Sequence) |\n|:------------------:|:------------------------:|:---------------------------:|\n| 0 | 0 | 0 |\n| 1 | 1 | 1 |\n| 2 | 2 | 10 |\n| 3 | 10.02 | 11 |\n| 4 | 11.02 | 20 |\n| 5 | 12.02 | 21 |\n| 6 | 20.1102 | 100 |\n| 7 | 21.1102 | 101 |\n| 8 | 100.1102 | 110 |\n| 9 | 101.1102 | 111 |\n| 10 | 102.1102 | 120 |\n\n:::\n::::\n\nAs an homage to heraldry terminology, I choose to call this system cendrée,\n and the root of the polynomial the ashen ratio (abbreviated *κ*).\nGold and silver (\"or\" and \"argent\") are \"metals\"; cendrée is a non-standard color\n referring to an ashen gray, which reflects its relationship to the metallic means.\n\n\nAsh on the Fulcrum\n------------------\n\nJust like the silver ratio base, we can try expressing these using a balanced alphabet\n {-1, 0, 1} instead of the standard one {0, 1, 2}.\nThere, we had the choice of forbidding either the string \"11\" or \"10\", because when the carry\n was applied to either, the negative of the other would appear.\nJust like then, we must choose whether to forbid \"11\" or \"TT\" (its negative), since carrying\n at one produces the other.\n\n$$\n0\\textcolor{red}{11} = \\textcolor{red}{1}\\bar{1}\\bar{1}\n$$\n\nI choose to permit \"11\" since both terms of the carry are positive.\n\n\n### Intractible Repetition\n\nOur first target for conversion into a balanced form is \"2\".\n\n$$\n\\textcolor{red}{2.0}_{\\kappa}\n = \\textcolor{red}{1}0.\\textcolor{blue}{\\bar{2}0}_{\\kappa}\n = 1\\textcolor{blue}{\\bar{1}}.0\\textcolor{orange}{20}_{\\kappa}\n = 1\\bar{1}.\\textcolor{orange}{1}0\\bar{2} _{\\kappa}\n = \\dots\n = 1\\bar{1}.\\underline{1\\bar{1}}_{\\kappa}\n$$\n\nBy iteratively applying the carry, we get a repeating balanced expansion.\nInstead of this, we could derive an expansion by decrementing the expansion of three\n\n$$\n2 = 3 - 1 = 10.02_{\\kappa} + \\bar{1}\n= 1\\bar{1}.0\\textcolor{green}{2}_{\\kappa}\n= 1\\bar{1}.1\\bar{1}0\\textcolor{green}{2}_{\\kappa}\n= \\dots\n= 1\\bar{1}.\\underline{1\\bar{1}}_{\\kappa}\n$$\n\nfor which we get the same expansion after recursing on the symbol \"2\".\n\nBoth of the above derivations involve an infinite number of steps, so there might still be some nagging suspicion\n that the methods used are invalid.\nTo put it on firm(er) ground, we can derive the carry polynomial directly from this series (and vice versa)\n using a geometric series argument:\n\n::: {#geometric-series-2}\n$$\n\\begin{gather*}\n 1.\\underline{\\vphantom{\\bar{1}}1}_x\n = 1 + x^{-1} + x^{-2} + x^{-3} + \\dots\n = \\frac{1}{1 - (1/x)}\n = \\frac{x}{x - 1}\n \\\\\n 1.\\underline{\\bar{1}1}_x\n = 1 -\\ x^{-1} + x^{-2} -\\ x^{-3} + \\dots\n = \\frac{1}{1 + (1/x)}\n = \\frac{x}{x + 1}\n \\\\\n 2 = 1\\bar{1}.\\underline{1\\bar{1}}_x\n = \\frac{x^2}{x + 1}\n \\\\\n x^2 = 2x + 2 \\iff \\langle 2, 2 |\n\\end{gather*}\n$$\n:::\n\nWe assume both series converge, since $\\kappa > 1$.\n\nRecall that in decimal, repeating expansions usually signify rational numbers, like $0.\\underline{3}_{10} = 1/3$.\nSimilarly, we can interpret \"$1\\bar{1}.\\underline{1\\bar{1}}$\" as a base three expansion by evaluating\n $x^2 / ( x + 1 )$ at three, getting $1\\bar{1}.\\underline{1\\bar{1}}_3 = 9/4 = 2.25_{10}$.\nNormally, the rule is that when the denominator of a rational number and base are coprime\n (in the first example, three and ten; in the second, four and three), its expansion repeats.\nBut two in the irrational base *κ* breaks that rule in a balanced alphabet.\n\n\n### Mixing Ashes\n\nNaively, we can convert each entry of the earlier table to a balanced form by replacing \"2\"s with\n (shifts of) the repeating expansion.\nBut notice that each listed fractional expansion above three appears to end in \"2\".\nIn contrast, the [silver ratio expansions](../2#canonical-silver-table) ended in both \"1\" and \"2\".\n\nWhile this isn't a problem with the fractional base on its own, it complicates things\n when considering the balanced alphabet.\nIn fact, it seems to be the case that *all* base *κ* expansions of integers above three terminate in \"2\",\n but I won't bother proving it (see note for a sketch[^1]).\n\nInstead of converting directly, we can also just try counting from zero again, remembering the aforementioned\n trick for converting \"2\", but we may get problems when \"2\" appears multiple times in the expansion.\nAlternatively, by applying a finite version of the rule, we can move \"2\" further and further to the right.\n\n\n:::: {.row .text-center}\n::: {#canonical-balanced-cendree-table .column width=\"100%\"}\n\n\n\n| *n*
(Decimal) | *n*
(Mixed Cendrée) | *n*
(Balanced Cendrée) | Remark |\n|-------------------:|:------------------------:|:---------------------------:|:------------------------------------------|\n| 0 | 0 | 0 | |\n| 1 | 1 | 1 | |\n| *2* | *2* | *1T. 1T...* | |\n| 2 | 1T.02 | 1T. 1T... | Example of pushing \"2\" to the right |\n| 3 | 10.02 | 10. 1T... | |\n| 4 | 11.02 | 11. 1T... | |\n| *5* | *12.02* | *11. 1T...* | |\n| 5 | 1T0.02 | 1T0. 1T... | Carry \"012\" to \"1T0\" |\n| 6 | 1T1.02 | 1T1. 1T... | |\n| *7* | *1T2.02* | *1T2. 1T...* | |\n| 7 | 10T.1102 | 10T.11 1T... | Push \"02000\" to \"1T1T02\" |\n| 8 | 100.1102 | 100.11 1T... | |\n| 9 | 101.1102 | 101.11 1T... | |\n| *10* | *102.1102* | *102.11 1T...* | |\n| 10 | 110.T102 | 110.T1 1T... | Carry \"2.1\" to \"10.T\" |\n| 11 | 111.T102 | 111.T1 1T... | |\n| *12* | *112.T102* | *112.T1 1T...* | |\n| *12* | *2T0.T102* | | Carry \"012\" to \"1T0\" |\n| 12 | 1T0T.001102 | 1T0T.0011 1T... | Push \"0200000000\" to \"1T1T1T1T02\" |\n\n: {tbl-colwidths=\"[15,20,25,40]\"}\n\n:::\n::::\n\nBetween some rows of the table, we have to apply the carry slightly more greedily --\n on the strings \"21\" and \"12\" as well as \"22\".\nIn fact, looking slightly ahead to fifteen, we have to use another trick:\n\n$$\n\\begin{align*}\n15_{10} = 1\\bar{1}0\\textcolor{red}{2}.001102_{\\kappa}\n &= 1\\bar{1}\\textcolor{red}{1\\bar{1}.02}1102_{\\kappa} \\\\\n &= 1\\bar{1}1\\bar{1}.0\\textcolor{blue}{21}102_{\\kappa}\n = 1\\bar{1}1\\bar{1}.\\textcolor{blue}{10\\bar{1}}102_{\\kappa}\n\\end{align*}\n$$\n\nIn other words, \"2\" should only be pushed to the right as far as an occurrence of \"11\", since at that point we can carry.\n\nIt remains to be proven that all but the rightmost \"2\" can be eliminated from a balanced expansion,\n but good \"pushes\" appear to suffice.\n\n\n-ary to -adic\n-------------\n\nWe can convert a repeating expansions back into the ratio of two integers by using a fairly simple procedure.\nHere, we apply that procuedure is applied to both $0.\\underline{69}_{10}$\n and the string in question, \"$0.\\underline{1\\bar{1}}_{p}$\", for generic $p$:\n\n$$\n\\begin{gather*}\n {\n 0.\\underbrace{\n \\underline{\\textcolor{blue}{69}}_{10}\n }_{\\text{length } \\textcolor{red}{2}}\n }\n = \\frac{\\textcolor{blue}{69}_{10}}{10^{\\textcolor{red}{2}} - 1}\n = \\frac{\\textcolor{blue}{69}_{10}}{99_{10}}\n = \\frac{23_{10}}{33_{10}}\n \\\\\n 0.\\underline{\\textcolor{blue}{1\\bar{1}}}_p\n = \\frac{\\textcolor{blue}{1\\bar{1}}_p}{p^2 - 1}\n = \\frac{p - 1}{p^2 - 1}\n = \\frac{1}{p + 1}\n\\end{gather*}\n$$\n\nThese fractions can be used to construct [p-*adic numbers*](https://en.wikipedia.org/wiki/P-adic_number).\nDoing so requires us to realize that $p + 1$ always divides $p^{2n} - 1$.\nDoing the long division directly for some small $n$, we get:\n\n$$\n\\begin{align*}\n &\\frac{p^2 - 1}{p+1} = \\frac{10\\bar{1}_p}{11_p}\n & \\substack{\n \\phantom{11}{\\underline{\\phantom{)1}1\\bar{1}}} \\\\[3pt]\n 11)10\\bar{1} \\\\\n \\phantom{11)}\\underline{11} \\phantom{0} \\\\[3pt]\n \\phantom{11)1}{\\bar{1}\\bar{1}} \\\\\n \\phantom{11)1}{\\underline{\\bar{1}\\bar{1}}} \\\\[3pt]\n \\phantom{11)1}00\n } \\\\\n \\\\\n &\\frac{p^4 - 1}{p+1} = \\frac{1000\\bar{1}_p}{11_p}\n & \\substack{\n \\phantom{11}{\\underline{\\phantom{)1}1\\bar{1}1\\bar{1}}} \\\\[3pt]\n 11)1000\\bar{1} \\\\\n \\phantom{11)} \\underline{11} \\phantom{000} \\\\[3pt]\n \\phantom{11)1} \\bar{1}0 \\phantom{00}\\\\\n \\phantom{11)1} \\underline{\\bar{1}\\bar{1}} \\phantom{00} \\\\[3pt]\n \\phantom{11)10}10 \\phantom{0} \\\\\n \\phantom{11)10} \\underline{11} \\phantom{0} \\\\[3pt]\n \\phantom{11)100} \\bar{1}\\bar{1} \\\\\n \\phantom{11)100} \\underline{\\bar{1}\\bar{1}} \\\\[3pt]\n \\phantom{11)100} 00 \\\\\n }\n\\end{align*}\n$$\n\nIf we assert $p^\\infty$ approaches zero (regardless of whether $p$ is greater than or less than 1),\n then in the limit we have the quotient $\\bar{1}_p / 11_p = \\dots 1\\bar{1}1\\bar{1}1\\bar{1}_p$.\n\n\n### Flip it Radix-ways\n\nThe series we're actually interested in is $1_p / 11_p$, which is the negative of the above series.\nSince we're using a balanced alphabet, we can negate this by simply replacing $\\bar{1}$ with $1$\n (and vice versa), producing...\n\n$$\n0.\\underline{1\\bar{1}}_p\n = \\frac{1_p}{11_p}\n = \\underline{\\bar{1}1}\\bar{1}1_p\n$$\n\n...which is the initial expansion, but flipped about the radix point.\nWe might also remember what [we did earlier with geometric series](#geometric-series-2) and just do\n\n$$\n\\begin{align*}\n \\underline{1}1_p\n &= 1 + p + p^2 + p^3 + ...\n = \\frac{1}{1 - p} \\\\\n \\underline{\\bar{1}1}\\bar{1}1_p\n &= 1 - p + p^2 - p^3 + ...\n = \\frac{1}{1 + p}\n\\end{align*}\n$$\n\nContrary to the usual case, in a *p*-adic sense, these series always converge,\n since $p^n$ is considered to always shrink as $n$ grows.\n\n\n### Back to *κ*\n\nReturning to base *κ*, we can create the *κ*-adic expansion for two through simple addition:\n\n$$\n\\begin{align*}\n &\\phantom{+} 1\\bar{1}.000000\\dots_\\kappa\n ~=~ \\dots00001\\bar{1}_\\kappa \\\\\n &+ \\underline{00.1\\bar{1}1\\bar{1}1\\bar{1}\\dots_\\kappa\n ~=~ \\dots\\bar{1}1\\bar{1}1\\bar{1}1}_\\kappa \\\\\n & \\phantom{+} 1\\bar{1}.1\\bar{1}1\\bar{1}1\\bar{1}\\dots_\\kappa\n ~=~ \\dots\\bar{1}1\\bar{1}100_\\kappa \\\\\n\\end{align*}\n$$\n\nWe can check this expansion by power series manipulations:\n\n$$\n\\begin{align*}\n 2 = \\dots\\bar{1}1\\bar{1}100_\\kappa\n &=\\kappa^2 - \\kappa^3 + \\kappa^4 - \\kappa^5 +\\dots \\\\\n &= \\kappa^2(1 - \\kappa + \\kappa^2 - \\kappa^3 +\\dots) \\\\\n &= \\kappa^2 \\cdot \\frac{1}{1 - (-\\kappa)} \\\\\n &= \\frac{\\kappa^2}{\\kappa + 1} \\\\[8pt]\n {2\\kappa + 2}\n &= \\kappa^2\n\\end{align*}\n$$\n\nThis gives us the defining relation of *κ*, so the expansion appears to be correct.\n\n\nTwo Plus Two Equals Chaos\n-------------------------\n\n*p*-adic expansions are still expressions in the base *p*, so the carry rule still applies.\nHowever, since the carry continues to infinity, we have a necessarily limited view,\n which we can at best combat by marking repeating sections.\n\nWhile the *κ*-adic expansion for two can be incremented once to produce a valid expansion one for three,\n problems arise when attempting to construct four.\nThe most direct method is to start with the symbol \"4\" and manipulate it:\n\n$$\n\\begin{align*}\n 4_{\\kappa}\n &= 2\\bar{4}0_{\\kappa}\n = \\bar{2}600_{\\kappa}\n = 3\\bar{8}000_{\\kappa}\n = \\bar{4}\\text{B}0000_{\\kappa} \\\\\n &= 5\\bar{\\text E}10000_{\\kappa}\n = \\bar{7}\\text{J}0\\textcolor{red}{1}0000_{\\kappa}\n = \\dots\n\\end{align*}\n$$\n\nLatin characters used as numerals start at A for ten, as in hexadecimal.\nAs we carry to the left, the most significant digits (which I call the \"carry head\") grow larger without bound.\nHowever, in doing so, a residual \"1\" (marked in red) is left behind in the fourth place value.\n\nIn typical *p*-adics, *p* is an integer, and the carry head is a single digit wide.\n*κ* is not an integer, and the carry head here is two digits wide.\nThis may seem a little dubious, but truncating immediately to the right of the carry head\n will produce the same effect regardless of its size.\n\n\n### Alternative Constructions\n\nTo keep the head small, it would be nice if it were taken mod an integer.\nBoth $\\bar{1}$ and $1$ are odd, so one might hope that in between carries, we could mod out by two.\nUnfortunately, this is not the case.\nAll of the expansions above are identically four, and manipulating the digits directly would just\n give a different number.\n\nInstead, we could try representing \"4\" in a more direct manner\nThere are a few other options available.\n\n- Add the nonrepeating part of the mixed balanced expansion of 4 with the\n $\\kappa$-adic version of the repeating part (Another direct manipulation)\n\n- Increment the least significant digit in the expansion of 2 twice (Addition)\n $$\n 4 = 2 + 2 = \\frac{\\kappa^2}{1 + \\kappa} + 2 = \\dots\\bar{1}1\\bar{1}102_{\\kappa}\n $$\n\n- Add the expansion of 2 to itself (Multiplication)\n $$\n 4 = 2 \\cdot 2 = 2 \\cdot \\frac{\\kappa^2}{1 + \\kappa} = \\dots\\bar{2}2\\bar{2}200_{\\kappa}\n $$\n\n- Square the power series expansion of 2 (Exponentiation)\n $$\n \\begin{gather*}\n 4 = 2^2 = \\left(\\frac{\\kappa^2}{1 + \\kappa}\\right)^2 =\n -\\kappa^4 \\left(\n \\frac{d}{dx} \\frac{1}{1 + x}\n \\right)_{x = \\kappa}\n = \\dots\\bar{4}3\\bar{2}10000_{\\kappa}\n \\end{gather*}\n $$\n\nIf all of these series are expansions of four, then they should produce the same string after\n applying the carry enough times.\nFortunately, this seems to be the case, as this table demonstrates:\n\n$$\n\\begin{array}{}\n {\\kappa^2 \\over 1 + \\kappa} + 2 &\\phantom{00}&\n {2\\kappa^2 \\over 1 + \\kappa} &\\phantom{00}&\n \\left({\\kappa^2 \\over 1 + \\kappa}\\right)^2 \\\\[10pt] \\hline\n \\vphantom{2^{2^{2^2}}}\\dots\\bar{1}1\\bar{1}1\\bar{1}102 \\\\[4pt]\n \\dots\\bar{1}1\\bar{1}1\\bar{1}2\\bar{2}0 \\\\[4pt]\n \\dots\\bar{1}1\\bar{1}1\\bar{2}400 &&\n \\dots\\bar{2}2\\bar{2}2\\bar{2}200 \\\\[4pt]\n \\dots\\bar{1}1\\bar{1}3\\bar{6}000 &&\n \\dots\\bar{2}2\\bar{2}3\\bar{4}000 \\\\[4pt]\n \\dots\\bar{1}1\\bar{4}90000 &&\n \\dots\\bar{2}2\\bar{4}70000 \\\\[4pt]\n \\dots\\bar{1}5\\bar{\\text C}10000 &&\n \\dots\\bar{1}5\\bar{\\text A}10000 &&\n \\dots\\bar{4}3\\bar{2}10000 \\\\[4pt]\n \\dots\\bar{7}{\\text H}010000 &&\n \\dots\\bar{6}\\text F010000 &&\n \\dots\\bar{5}5010000 \\\\[4pt]\n \\dots\\bar{\\text N}1010000 &&\n \\dots\\bar{\\text L}1010000 &&\n \\dots\\bar{9}1010000 \\\\[4pt]\n \\textcolor{green}{\\dots\\bar{1}1010000} &&\n \\textcolor{green}{\\dots\\bar{1}1010000} &&\n \\textcolor{green}{\\dots\\bar{1}1010000}\n\\end{array}\n$$\n\nThe rightmost series is the most resilient to the carry head growth, but it comes at\n the cost of not operating on a repeating series.\nIn the range shown, all three columns converge to the same digit sequence, which truncated to 20 terms is:\n\n$$\n4 = \\dots \\bar{1}00000\\bar{1}00001\\bar{1}1010000_\\kappa = \\kappa^4 + \\kappa^6 -\\ \\kappa^7 + \\dots\n$$\n\nContrary to the sequence used to build it, this expansion appears to be nonrepeating.\nAs of writing, there are\n [no matches](http://oeis.org/search?q=1%2C0%2C1%2C-1%2C1%2C0%2C0%2C0%2C0%2C-1%2C0%2C0%2C0%2C0%2C0%2C-1&sort=&language=&go=Search)\n in the OEIS, even if the leading 0's are ignored.\nThe Haskell used to generate each expansion above can be found [here](./cendree.hs),\n and the first 8192 digits be found in a CSV [here](./cendree_adic_4.csv).\n\n\n### All Positive\n\nIf we are slightly greedier with the carry, we can clear it of all negative digits.\nFor example,\n\n$$\n\\begin{align*}\n 4 &= \\dots \\bar{1}00000\\bar{1}00001\\bar{1}1010000_\\kappa \\\\\n &= \\dots \\bar{1}00000\\bar{1}000\\bar{1}311010000_\\kappa \\\\\n &= \\dots \\bar{1}00000\\bar{1}001\\bar{3}111010000_\\kappa \\\\\n &= \\dots \\bar{1}00000\\bar{1}0\\bar{2}51111010000_\\kappa \\\\\n &= \\dots \\bar{1}00000\\bar{1}2\\bar{6}11111010000_\\kappa \\\\\n &= \\dots \\bar{1}00000\\bar{4}8011111010000_\\kappa \\\\\n &= \\quad \\vdots \\\\\n &= \\dots 0 11000 0 0011111010000_\\kappa \\\\\n &= \\kappa^4 + \\kappa^6 + \\kappa^7 + \\kappa^8 + \\kappa^9 \\dots\n\\end{align*}\n$$\n\nAgain, it appears to be possible to achieve this sequence by applying the carry enough times,\n starting with any of the alternative expansions.\nA similar CSV containing 8192 terms is available [here](./cendree_adic_4_binary.csv).\n\nThis alternate expansion is somewhat confounding, since *κ* is bounded above by the\n integer three and should therefore require three symbols in its alphabet.\nI can think of two explanations, and do not know whether either of them are correct:\n\n- The expansion is related to the conjugate root $\\kappa^* = 1 -\\ \\sqrt 3 \\approx -0.73205\\dots$.\n The reciprocal of this number is less than two.\n- Because infinite precision is required, the minimal alphabet can become (possibly arbitrarily) small.\n\n\nSearching for Repetition\n------------------------\n\nThe [discrete Fourier transform](https://en.wikipedia.org/wiki/Discrete_Fourier_transform)\n is an operation on a discrete signal (i.e., a sequence of numbers).\nIt has the desirable property that it converts highly repetitive signals sequences into ones with peaks.\nWe can use this to assess whether an expansion repeats or not.\n\nSince our expansions are infinite, we'll need to truncate them.\nUnfortunately, this renders us unable to pick up on repetitions larger than a certain size.\nIn other words, to detect very large periods, we need to truncate our sequence to a large number of terms.\n\nFor example, the digits in the decimal expansion of 1/7 form the string \"142857\", repeating.\nTruncating this sequence to 256 terms, we can plot its DFT:\n\n::: {#a6158b7e .cell execution_count=2}\n``` {.python .cell-code code-fold=\"true\"}\nfrom itertools import cycle, islice\nfrom matplotlib import pyplot as plt\nimport numpy as np\n\none_seventh = list(islice(cycle([1,4,2,8,5,7]), 256))\n\nplt.title(\"DFT of first 256 digits of decimal expansion of 1/7\")\nplt.plot(abs(np.fft.fft(one_seventh))[:129])\n```\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-2-output-1.png){width=583 height=431}\n:::\n:::\n\n\nThe clear peak near forty is because the expansion repeats every 6 terms and\n $\\frac{256}{43} < 6 < \\frac{256}{42}$.\n\n\n### Four-ier Transforms\n\nIf the $\\kappa$-adic expansion of four is nonrepeating, then its DFT should not have any noticeable peaks.\n\n::: {#079df1ce .cell execution_count=3}\n``` {.python .cell-code code-fold=\"true\"}\nimport csv\n\nwith open(\"cendree_adic_4.csv\") as f:\n cendree_adic_4 = [int(i) for i in list(csv.reader(f))[0]]\n\nplt.title(\"DFT of first 256 digits of $\\\\kappa$-adic expansion of 4\")\nplt.plot(abs(np.fft.fft(cendree_adic_4[:256]))[:129])\n```\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-3-output-1.png){width=575 height=432}\n:::\n:::\n\n\nThe DFT of the first 256 terms shows it to be very noisy.\nThere is a pronounced spike at the right edge of the graph (the Nyquist frequency),\n but it has a simple explanation: $1$ appears only at even place values and $\\bar{1}$ at odd.\nAt Nyquist, the DFT degenerates into an alternating sum, so its value is simply the number of nonzero digits.\n\nIf we map the negatives out of the sequence, the peak moves to the left edge (where the DFT degenerates into a sum).\n\n::: {#219cff53 .cell execution_count=4}\n``` {.python .cell-code code-fold=\"true\"}\nplt.title(\"DFT of $4_{\\\\kappa}$ after mapping $\\\\bar{1}$ to $1$\")\nplt.plot(abs(np.fft.fft([abs(i) for i in cendree_adic_4[:256]]))[:129])\n```\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-4-output-1.png){width=575 height=435}\n:::\n:::\n\n\nIf you look closely, you'll notice that this plot is a mirror of the other.\n\n\n### Longer Truncations\n\nEven in the 8192-term truncation, there are no noticeable spikes in its DFT,\n lending further credence to its aperiodicity.\nIf it feels like we're doing something wrong, we might also try the \"all-positive\" variant of the expansion.\nUnfortunately, we're not so lucky.\nEven then, we just end up with pure noise.\n\n:::: {#long-trunc-figures .row layout-ncol=\"2\"}\n::: {.column width=\"40%\"}\n\n::: {#e5d46955 .cell execution_count=5}\n``` {.python .cell-code code-fold=\"true\"}\nplt.title(\"DFT of first 8192 digits of $4_{\\\\kappa}$\")\nplt.plot(abs(np.fft.fft(cendree_adic_4))[:len(cendree_adic_4) // 2])\n\n#\n```\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-5-output-1.png){width=575 height=432}\n:::\n:::\n\n\n:::\n\n::: {.column width=\"40%\"}\n\n::: {#0370766d .cell execution_count=6}\n``` {.python .cell-code code-fold=\"true\"}\n# Alternatively, with the non-balanced expansion\nwith open(\"cendree_adic_4_binary.csv\") as f:\n cendree_adic_4_binary = [int(i) for i in list(csv.reader(f))[0]]\n\nplt.title(\"DFT of first 8192 digits of $4_\\\\kappa$ (binary)\")\nplt.plot(abs(np.fft.fft(cendree_adic_4_binary))[1:len(cendree_adic_4_binary) // 2])\n```\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-6-output-1.png){width=575 height=432}\n:::\n:::\n\n\n:::\n::::\n\nMuch like the expansion of irrational numbers in integral bases, the balanced\n *κ*-adic expansion of four seems to be nonrepeating.\nThis is surprising, considering four is an integer, and especially since its expansion terminates\n in a normal alphabet and repeats in a balaced alphabet.\n\n\nClosing\n-------\n\nThis concludes the discussion of base *κ* and the *κ*-adics.\nRemember, we only bothered investigating *κ*-adic expansions for the number four.\nGreater integers suffer the same issues, and other bases are certainly possible.\nHopefully, four provides an illuminating enough example of the general chaos induced by irrational bases.\n\nThe [next post](../5) will return to integral sequences, and the patterns produced from their\n \"erroneousness\" as an actual base.\n\n[^1]:\n
\n \n Proof sketch that base *κ* expansions of integers above three end in \"2\"\n \n\n Recall that $3 = 10.02_{\\kappa}$ and $4 = 11.02_{\\kappa}$.\n\n We can add two expansion together to produce a new valid expansion.\n Hence,\n\n :::: {.row layout-ncol=\"2\"}\n ::: {.column width=\"40%\"}\n $$\n \\begin{align*}\n 8 &= 4 + 4\n = 11.02_{\\kappa} + 11.02_{\\kappa} \\\\\n &= \\textcolor{red}{22}.04_{\\kappa}\n = \\textcolor{red}{1}00.0\\textcolor{blue}{4}_{\\kappa}\n = 100.\\textcolor{blue}{1102}_{\\kappa}\n \\end{align*}\n $$\n :::\n\n ::: {.column width=\"40%\"}\n $$\n \\begin{align*}\n 11_{10} &= 8 + 3\n = 100.1102_{\\kappa} + 10.02_{\\kappa} \\\\\n &= 110.1\\textcolor{red}{3}02_{\\kappa}\n = 110.\\textcolor{red}{2004}_{\\kappa} \\\\\n &= 110.200\\textcolor{blue}{4}_{\\kappa}\n = 110.20\\textcolor{blue}{1102}_{\\kappa}\n \\end{align*}\n $$\n :::\n ::::\n\n From these examples, we see that adding small numbers like three will, at most,\n produce a \"3\" or \"4\" in the negative second place value.\n\n If there is a \"2\" in the negative first place value, then expanding \"3\" or \"4\" in the negative\n second will give a \"3\" there, which is troublesome.\n But we got in this position by adding three; by adding two first, we can apply the carry\n across the zeroth and negative first place values instead, which produces\n at most a \"3\" in the first place value.\n Expanding \"3\" at this place value places a \"2\" back in the negative first place value,\n and we don't have to worry about modifying digits in other negative place values.\n\n If there is *not* a \"2\" in the negative first place value, then expanding the \"3\" or \"4\"\n in the negative second place value pushes a \"2\" into the negative fourth place value.\n From here \"2\" is either in the terminal position, or causes another expansion of \"3\" or \"4\".\n In the latter cases, we recurse, eventually pushing a \"2\" into a negative even place value in terminal position.\n
\n\n", + "supporting": [ + "index_files" + ], + "filters": [], + "includes": {} + } +} \ No newline at end of file diff --git a/_freeze/polycount/4/index/figure-html/cell-2-output-1.png b/_freeze/polycount/4/index/figure-html/cell-2-output-1.png new file mode 100644 index 0000000..7ee8ef3 Binary files /dev/null and b/_freeze/polycount/4/index/figure-html/cell-2-output-1.png differ diff --git a/_freeze/polycount/4/index/figure-html/cell-3-output-1.png b/_freeze/polycount/4/index/figure-html/cell-3-output-1.png new file mode 100644 index 0000000..496f871 Binary files /dev/null and b/_freeze/polycount/4/index/figure-html/cell-3-output-1.png differ diff --git a/_freeze/polycount/4/index/figure-html/cell-4-output-1.png b/_freeze/polycount/4/index/figure-html/cell-4-output-1.png new file mode 100644 index 0000000..90b15f9 Binary files /dev/null and b/_freeze/polycount/4/index/figure-html/cell-4-output-1.png differ diff --git a/_freeze/polycount/4/index/figure-html/cell-5-output-1.png b/_freeze/polycount/4/index/figure-html/cell-5-output-1.png new file mode 100644 index 0000000..1289cd7 Binary files /dev/null and b/_freeze/polycount/4/index/figure-html/cell-5-output-1.png differ diff --git a/_freeze/polycount/4/index/figure-html/cell-6-output-1.png b/_freeze/polycount/4/index/figure-html/cell-6-output-1.png new file mode 100644 index 0000000..fefc759 Binary files /dev/null and b/_freeze/polycount/4/index/figure-html/cell-6-output-1.png differ diff --git a/_freeze/polycount/5/index/execute-results/html.json b/_freeze/polycount/5/index/execute-results/html.json new file mode 100644 index 0000000..3c4077a --- /dev/null +++ b/_freeze/polycount/5/index/execute-results/html.json @@ -0,0 +1,12 @@ +{ + "hash": "75ea07652b53798dee08142061175e2e", + "result": { + "engine": "jupyter", + "markdown": "---\ntitle: \"Polynomial Counting 5: Pentamerous multiplication\"\nformat:\n html:\n html-math-method: katex\ndate: \"2021-02-12\"\ndate-modified: \"2025-2-12\"\njupyter: python3\ncategories:\n - algebra\n - haskell\n---\n\n\n\n\nThis post assumes you have read [the first](../1), which introduces generalized polynomial counting.\n\nOne layer up from counting is arithmetic.\nWe've done a little arithmetic using irrational expansions in pursuit of counting, but maybe we should investigate it a bit.\n\n\nArithmetical Algorithms\n-----------------------\n\nAddition is a fairly simple process for positional systems: align the place values, add each term together,\n then apply the carry as many times as possible.\nWithout a carry rule, this can be approached formally by treating the place values as a sequence\n $b_n$ and gathering terms:\n\n$$\n\\begin{gather*}\n \\phantom{+~} \\overset{b_2}{1} \\overset{b_1}{2} \\overset{b_0}{3} &\n \\phantom{+~} 1b_2 + 2b_1 + 3b_0 \\\\\n \\underline{\n +\\\n \\smash{\n \\overset{\\phantom{b_0}}4\n \\overset{\\phantom{b_0}}5\n \\overset{\\phantom{b_0}}6\n }\n \\vphantom,\n } &\n \\underline{\n +\\\n 4b_2 + 5b_1 + 6b_0 \\vphantom,\n } \\\\\n \\phantom{+~}\n \\smash{\n \\overset{\\phantom{b_0}}5\n \\overset{\\phantom{b_0}}7\n \\overset{\\phantom{b_0}}9\n } &\n \\phantom{+~} 5b_2 + 7b_1 + 9b_0\n\\end{gather*}\n$$\n\nMultiplication is somewhat trickier.\nIts validity follows from the interpretation of an expansion as a polynomial.\nPolynomial multiplication itself is equivalent to\n [*discrete convolution*](https://en.wikipedia.org/wiki/Convolution#Discrete_convolution).\n\n$$\n\\begin{align*}\n &\\begin{matrix}\n \\phantom{\\cdot~}\n 111_x \\\\\n \\underline{\\cdot\\ \\phantom{1}21_x\\vphantom,} \\\\\n \\phantom{\\cdot \\ 0}\n 111_{\\phantom{x}} \\\\\n \\underline{\\phantom{\\cdot\\ } 2220_{\\phantom{x}} \\vphantom,} \\\\\n \\phantom{\\cdot\\ }\n 2331_{\\phantom{x}}\n \\end{matrix}\n &\\qquad&\n \\begin{gather*}\n (x^2 + x + 1)(2x + 1) \\\\ \\\\\n = \\phantom{2x^3 + } \\phantom{2}x^2 + \\phantom{2}x + 1 \\\\\n + \\phantom{.} 2x^3 + 2x^2 + 2x \\phantom{+ 1}\\\\\n = 2x^3 + 3x^2 + 3x + 1\n \\end{gather*}\n &\\qquad&\n \\begin{gather*}\n [1,1,1] * [2,1] \\\\\n \\begin{matrix}\n \\textcolor{blue}0 &\\textcolor{red}1 & \\textcolor{red}1 & \\textcolor{red}1 & \\textcolor{blue}0 &\\\\\n & & &1 & 2 & =~1\\\\\n & & 1 & 2 & &=~3\\\\\n & 1 & 2 & & &=~3\\\\\n 1 & 2 & & & & =~2\n \\end{matrix}\n \\end{gather*}\n\\end{align*}\n$$\n\nThe left equation shows familiar multiplication, the middle equation is the same product when expressed as polynomials,\n and the right equation shows this product obtained by convolution.\nNote that \\[2, 1\\], the second argument, is reversed when performing the convolution.\n\nWithout carrying, multiplication and addition are base-agnostic.\nWhen doing arithmetic in a particular base, we should obtain the same result even if we perform the same operations in another base.\n\n$$\n\\begin{array}{c}\n 18_{10} \\cdot 5_{10} = 10010_2 \\cdot 101_2\n \\\\ \\hline \\\\\n \\begin{gather*}\n &\n \\begin{matrix}\n \\phantom{\\cdot~}\n 18_{10} \\\\\n \\underline{\\cdot\\\n \\phantom{1}5_{10}\\vphantom,} \\\\\n \\phantom{\\cdot~}90_{10} \\\\ \\\\\n =~1011010_2\n \\end{matrix}\n &&\n \\begin{matrix}\n [1,0,0,1,0] * [1,0,1] \\\\ \\\\\n \\begin{matrix}\n \\textcolor{blue}0 & \\textcolor{blue}0 &\\textcolor{red}1 & \\textcolor{red}0 & \\textcolor{red}0\n & \\textcolor{red}1 & \\textcolor{red}0 & \\textcolor{blue}0 & \\textcolor{blue}0 &\\\\\n & & & & & &1 & 0 & 1 & =~0\\\\\n & & & & &1 & 0 & 1 & & =~1\\\\\n & & & &1 & 0 & 1 & & & =~0\\\\\n & & &1 & 0 & 1 & & & & =~1\\\\\n & &1 & 0 & 1 & & & & & =~1\\\\\n & 1 & 0 & 1 & & & & & & =~0\\\\\n 1 & 0 & 1 & & & & & & & =~1\\\\\n \\end{matrix}\n \\end{matrix}\n \\end{gather*}\n\\end{array}\n$$\n\nThis shows that regardless of whether we multiply eighteen and five together in base ten or two,\n we'll get the same string of digits if afterward everything is rendered in the same base.\nFortunately in this instance, we don't have to worry about any carries in the result.\n\n\nTwo Times Tables\n----------------\n\nThe strings \"10010\" and \"101\" do not contain adjacent \"1\"s, so they can also be interpreted as\n Zeckendorf expansions (of ten and four, respectively).\nThis destroys their correspondence to polynomials, so their product by convolution,\n as a Zeckendorf expansion (when returned to canonical form) is not the product of ten and four.\n\n$$\n\\begin{gather*}\n [1,0,0,1,0] * [1,0,1] = 1011010 \\\\\n 10\\textcolor{red}{11}010_{\\text{Zeck}}\n = 1\\textcolor{red}{1}00010_{\\text{Zeck}}\n = \\textcolor{blue}{11}00010_{\\text{Zeck}}\n = \\textcolor{blue}{1}0000010_{\\text{Zeck}} = 36_{10} \\\\\n \\text{Zeck}(10_{10}) * \\text{Zeck}(4_{10})\n = 36_{10} \\neq 40_{10} = 10_{10} \\cdot 4_{10}\n\\end{gather*}\n$$\n\nWe can express this operation for general integers *x* and *y* as\n\n$$\nx \\odot_\\text{Zeck} y = Unzeck(Zeck(x) * Zeck(y))\n$$\n\nwhere \"Zeck\" expands an integer into its Zeckendorf expansion and \"Unzeck\" signifies the process of\n re-interpreting the string as an integer.\nWe can do this because for every integer, a canonical expansion exists.\nFurther, since this operation is defined via convolution (which is commutative), it is also commutative.\n\n::: {#562ef349 .cell execution_count=2}\n``` {.python .cell-code}\nfrom itertools import count, chain, islice, takewhile\nimport numpy as np\n\ndef fibs():\n i = 1\n j = 1\n while True:\n yield i\n t = i + j\n j = i\n i = t\n\ndef zeck(n: int) -> list[int]:\n fibs_ = list(takewhile(lambda x: x <= n, fibs()))[::-1]\n ret = []\n\n for i in fibs_:\n digit, n = divmod(n, i)\n ret.append(digit)\n\n return ret or [0]\n\ndef unzeck(ns: list[int]) -> int:\n return sum(map(lambda x, y: x * y, reversed(ns), fibs()))\n\ndef zeck_times(x: int, y: int) -> int:\n return unzeck(np.convolve(zeck(x), zeck(y), \"full\"))\n```\n:::\n\n\nWe can then build a times table by experimentally multiplying.\nThe expansions for zero and one are invariably the strings \"0\" (or the empty string!) and \"1\".\nWhen a sequence has length one, convolution degenerates to term-by-term multiplication.\nThus, convolution by \"0\" produces a sequence of \"0\"s, and convolution by \"1\" produces the same sequence.\n\nIgnoring those rows, the table is:\n\n::: {#545985aa .cell execution_count=3}\n``` {.python .cell-code code-fold=\"true\"}\nfrom IPython.display import Markdown\nfrom tabulate import tabulate\n\nMarkdown(tabulate(\n [[zeck_times(i, j) for i in range(1, 10)] for j in range(2, 10)],\n headers=[\"$\\\\odot_\\\\text{Zeck}$\", *range(2, 10)]\n))\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=2}\n $\\odot_\\text{Zeck}$ 2 3 4 5 6 7 8 9\n--------------------- --- --- --- --- --- --- --- ---\n 2 3 5 7 8 10 11 13 15\n 3 5 8 11 13 16 18 21 24\n 4 7 11 15 18 22 25 29 33\n 5 8 13 18 21 26 29 34 39\n 6 10 16 22 26 32 36 42 48\n 7 11 18 25 29 36 40 47 54\n 8 13 21 29 34 42 47 55 63\n 9 15 24 33 39 48 54 63 72\n:::\n:::\n\n\nThis resembles a sequence in the OEIS ([A101646](https://oeis.org/A101646)), where it mentions the defining operation\n is sometimes called the \"arroba\" product.\n\n### Correcting for Errors\n\nThe difference between the actual product and the false product can be interpreted as an error endemic to Zeckendorf expansions.\nIf assigned to the symbol $\\oplus_\\text{Zeck}$, then the normal product can be recovered as\n $mn = m \\odot_\\text{Zeck} n + m \\oplus_\\text{Zeck} n$.\n\nWe can then tabulate these errors just like we did our \"products\":\n\n::: {#f5cffcdc .cell execution_count=4}\n``` {.python .cell-code code-fold=\"true\"}\nzeck_error = lambda x, y: x*y - zeck_times(x, y)\n\nMarkdown(tabulate(\n [[j] + [zeck_error(i, j) for i in range(2, 10)] for j in range(2, 10)],\n headers=[\"$\\\\oplus_\\\\text{Zeck}$\", *range(2, 10)]\n))\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=3}\n $\\oplus_\\text{Zeck}$ 2 3 4 5 6 7 8 9\n---------------------- --- --- --- --- --- --- --- ---\n 2 1 1 1 2 2 3 3 3\n 3 1 1 1 2 2 3 3 3\n 4 1 1 1 2 2 3 3 3\n 5 2 2 2 4 4 6 6 6\n 6 2 2 2 4 4 6 6 6\n 7 3 3 3 6 6 9 9 9\n 8 3 3 3 6 6 9 9 9\n 9 3 3 3 6 6 9 9 9\n:::\n:::\n\n\nNotice that the errors seem to be grouped together in rectangular blocks.\nBecause this operation is commutative, the shapes of the rectangles must agree along the main diagonal, where they are squares.\n\n### Fibonacci Runs\n\nThe shape of the rectangular blocks is somewhat odd.\nWe can assess the number of terms the series \"hangs\" before progressing by looking at the\n [*run lengths*](https://en.wikipedia.org/wiki/Run-length_encoding)).\n\n:::: {.row layout-ncol=\"1\"}\n::: {.row}\n\n::: {#b4a13686 .cell execution_count=5}\n``` {.python .cell-code code-fold=\"true\"}\nfrom IPython.display import Math\nfrom typing import Generator\n\ndef run_lengths(xs: Generator) -> Generator:\n last = next(xs)\n run_length = 1\n for i in xs:\n if i != last:\n yield run_length\n last = i\n run_length = 1\n else:\n run_length += 1\n\nshow_trunc_list = lambda xs, n: \"[\" + \", \".join(chain(islice(map(str, xs), n), (\"...\",))) + \"]\"\n\nMath(\n \"RL([i \\\\oplus 2]_{i}) =\"\n + f\"RL({show_trunc_list((zeck_error(i, 2) for i in count(0)), 10)}) =\"\n + show_trunc_list(run_lengths(zeck_error(i, 2) for i in count(0)), 10)\n)\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=4}\n$\\displaystyle RL([i \\oplus 2]_{i}) =RL([0, 0, 1, 1, 1, 2, 2, 3, 3, 3, ...]) =[2, 3, 2, 3, 3, 2, 3, 2, 3, 3, ...]$\n:::\n:::\n\n\n:::\n\n::: {.row}\n\n::: {#c073b4b3 .cell execution_count=6}\n``` {.python .cell-code code-fold=\"true\"}\nMath(\n \"RL([i \\\\oplus 5]_{i}) =\"\n + f\"RL({show_trunc_list((zeck_error(i, 5) for i in count(0)), 10)}) =\"\n + show_trunc_list(run_lengths(zeck_error(i, 2) for i in count(0)), 10)\n)\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=5}\n$\\displaystyle RL([i \\oplus 5]_{i}) =RL([0, 0, 2, 2, 2, 4, 4, 6, 6, 6, ...]) =[2, 3, 2, 3, 3, 2, 3, 2, 3, 3, ...]$\n:::\n:::\n\n\n:::\n\n::: {.row}\n\n::: {#a83206da .cell execution_count=7}\n``` {.python .cell-code code-fold=\"true\"}\nMath(\n \"RL([i \\\\oplus i]_{i}) =\"\n + f\"RL({show_trunc_list((zeck_error(i, i) for i in count(0)), 10)}) =\"\n + show_trunc_list(run_lengths(zeck_error(i, i) for i in count(0)), 10)\n)\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=6}\n$\\displaystyle RL([i \\oplus i]_{i}) =RL([0, 0, 1, 1, 1, 4, 4, 9, 9, 9, ...]) =[2, 3, 2, 3, 3, 2, 3, 2, 3, 3, ...]$\n:::\n:::\n\n\n:::\n::::\n\nThe initial two comes from the errors for $0 \\oplus i$ and $1 \\oplus i$.\nThese rows never have errors, so they can be ignored.\n\nSince the run lengths appear to only be occur in twos and threes, we don't lose any information by converting it\n into, say, ones and zeroes.\nArbitrarily mapping $3 \\mapsto 0,~ 2 \\mapsto 1$, the sequence becomes (truncated to 30 terms):\n\n$$\n0,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,0,...\n$$\n\nThis sequence matches the *Fibonacci word* ([OEIS A3849](http://oeis.org/A003849)).\nThe typical definition of this sequence follows from the a slight modification to that of\n the Fibonacci sequence: rather than starting with two 1s and adding, we start with\n \"0\" and \"1\" (as distinct strings), and concatenate.\n\nPerhaps this is unsurprising, since Zeckendorf expansions are literally strings in Fibonacci numbers.\nHowever, this shows that the errors can be interesting, since it is not obvious that this is the case\n from just looking at the multiplication table.\n\n\nVisualizing Tables\n------------------\n\nWhile it's great that we can build a table, just showing the numbers isn't the best we can do when it comes to visualization.\n\nFor inspiration, I remembered what WolframAlpha does when you ask it for operation tables in finite fields.\nRather than showing you the underlying field elements in a table, it renders\n [a grayscale image](https://www.wolframalpha.com/input?i=finite+field+of+order+25).\n\nI'd like produce something similar in color, but there's a slight problem: we don't have a finite number of elements.\nTo get around this, we'll have to take our tables mod an integer.\nIn the HSV color space, colors are cyclic just like the integers mod *n*.\nThis actually has an additional appealing feature: two colors with similar hues are \"near\" in a similar way to the underlying numbers.\nThen, the entry-to-color mapping can just be given as\n\n$$\nk \\mapsto HSV \\left({2\\pi k \\over n}, 100\\%, 100\\% \\right)\n$$\n\nIn this mapping, for $n = 2$, zero goes to red and one goes to cyan.\nThe following is a 100x100 image of the multiplication table of $\\oplus_\\text{Zeck}$ from 0 to 99.\n\n![](fibonacci_deficiency_mod_2.png)\n\n\n### Anima Moduli\n\nThis table can by animated by gathering various n into an animation and incrementing n every frame.\nBefore applying this technique to an error table, it'd be prudent to apply it to standard addition and multiplication tables first.\n\n::: {.row layout-ncol=\"2\"}\n![\n Addition\n](canonical_tables/canonical_addition.gif){.image-wide}\n\n![\n Multiplication\n](canonical_tables/canonical_multiplication.gif){.image-wide}\n:::\n\nBoth images appear to zoom in as the animation progresses.\nUnsurprisingly, addition produces diagonal stripes, along which the sum is the same.\nMultiplication produces a squarish pattern (with somewhat appealing moirés).\n\nTables for $\\odot_\\text{Zeck}$ and $\\oplus_\\text{Zeck}$ should resemble the table to the right,\n since their definition relies on it.\n\n::: {.row layout-ncol=\"2\"}\n![\n $\\odot_\\text{Zeck}$\n](series_tables/fibonacci_odot.gif){.image-wide}\n\n![\n $\\oplus_\\text{Zeck}$\n](series_tables/fibonacci_oplus.gif){.image-wide}\n:::\n\nIndeed, the zooming is present in both tables.\nAt later frames, both tables share the same \"square rainbow\" pattern, but the error table is closer.\nThough both tables appear to have a repeating pattern, the blocks in the error table are still\n irregularly shaped, as in the mod 2 case.\n\nThe error table also demonstrates (for a given modulus) how much the series differs from a geometric series.\nWe know there will always be an error since, while Fibonacci numbers grow on the order of\n $O(\\varphi^n)$, the ratio between place values is only *φ* in the limit.\n\n\nOther Error Tables\n------------------\n\nThese operations can can also be defined in terms of any other series expansion (i.e., integral system).\nRather than showing both of the multiplication and error tables, I will elect to show only the latter.\nThe error table is more fundamental since the table for $\\odot$ can be constructed from it and the normal multiplication table.\n\nThe error tables for some of the previously-discussed generalizations of the Fibonacci numbers are presented below.\n\n\n### Pell, Jacobsthal\n\n::: {.row layout-ncol=\"2\"}\n![\n Pell ([OEIS A000129](http://oeis.org/A000129))\n $\\langle 2,1|$\n](series_tables/pell_oplus.gif){.image-wide}\n\n![\n Jacobsthal ([OEIS A001045](http://oeis.org/A001045)),\n $\\langle 1,2|$\n](series_tables/jacobsthal_oplus.gif){.image-wide}\n:::\n\nOf the two tables, the Pell table looks more similar to the Fibonacci one.\nMeanwhile, the Jacobsthal table has frames which are significantly redder than the either surrounding it.\nThese occur on frames for which *n* is a power of 2, which is a root of the recurrence polynomial.\n\n\n### *n*-nacci\n\n::: {.row layout-ncol=\"2\"}\n![\n Tribonacci,\n $\\langle 1,1,1|$\n](series_tables/tribonacci_oplus.gif){.image-wide}\n\n![\n Tetranacci,\n $\\langle 1,1,1,1|$\n](series_tables/tetranacci_oplus.gif){.image-wide}\n:::\n\nCompared to the Fibonacci image, the size of the square pattern in the Tribonacci and Tetranacci images is larger.\nHigher orders of Fibonacci recurrences approach binary, so in the limit,\n the pattern disappears, as if the tiny red corner in the upper-left is all that remains.\n\n\n### Other\n\nOf course, integral systems are not limited to linear recurrences, and tables can also be produced\n that correspond to other integer sequences.\nFor example, the factorials produce distinct patterns at certain frames.\nThe Catalan numbers (which are their own recurrence) mod two seem to make a fractal carpet.\nTo prevent the page from getting bloated, these frames are presented in isolation.\n\n\n::: {.row layout-ncol=\"2\"}\n![\n Factorial Error (mod 8)\n](series_tables/factorial_oplus_mod_8.png){.image-wide}\n\n![\n Catalan Numbers Error (mod 2)\n](series_tables/catalan_oplus_mod_2.png){.image-wide}\n:::\n\n\nAdditional tables which I find interesting are:\n\n- [\n Triangular Numbers (recurrence $\\langle 3, \\bar{3}, 1|$)\n](series_tables/triangular_oplus.gif){target=\"_blank_\"}\n- [\n Square Numbers\n](series_tables/square_oplus.gif){target=\"_blank_\"}\n- [\n Padovan Numbers (recurrence $\\langle 0,1,1|$)\n](series_tables/padovan_oplus.gif){target=\"_blank_\"}\n- [\n $\\langle 1, 1, 2|$, based on the first 3 Catalan numbers\n](series_tables/recurrence_1_1_2_oplus.gif){target=\"_blank_\"}\n\n\nClosing\n-------\n\nEven if not particularly useful, I enjoy the emergent behavior apparent in the tables.\nEven for typical multiplication, this visualization technique shows regular patterns which appear to \"grow\".\nMeanwhile, the sequence products frequently produce a pattern that either repeats, or is composed of many similar elements.\n\nThe project that I used to render the images can be found [here](https://github.com/queue-miscreant/SeriesDeficient).\nI didn't put much thought into command line arguments, nor did I build in many features.\nAs an executable, it should be completely serviceable to generate error tables based on recurrence relations;\n the GHCi REPL can be used for more sophisticated sequences.\n\n\n### Bad Visualization\n\nMy first attempt to map integers to colors was to consider its prime factorization.\nThe largest number in the factorization was related to the hue, and the number of terms in the factorization\n was related to the saturation.\nResults were not great.\n\n![ ](fibonacci_old_bad.png)\n\n\n### Bad Filesizes\n\nWhile I rendered these animations as GIFs, I also attempted to convert some of them to MP4s in hopes of shrinking the filesize.\nHowever, this is a use case where the MP4 is larger than the GIF, at least without compromising on resolution.\nThis is a case when space-compression beats ill-suited time-compression.\n\n![Produced with ffmpeg defaults](gif_mp4_size_comparison.png)\n\n", + "supporting": [ + "index_files" + ], + "filters": [], + "includes": {} + } +} \ No newline at end of file diff --git a/_freeze/polycount/cell1/fig1/execute-results/html.json b/_freeze/polycount/cell1/fig1/execute-results/html.json new file mode 100644 index 0000000..a27fbf7 --- /dev/null +++ b/_freeze/polycount/cell1/fig1/execute-results/html.json @@ -0,0 +1,16 @@ +{ + "hash": "87c9932ff62d911a44f6d6fca5c513e4", + "result": { + "engine": "jupyter", + "markdown": "::: {#4d35cd9f .cell execution_count=1}\n``` {.python .cell-code}\nfrom IPython.display import HTML\nfrom carry2d import anim, carry\n\nHTML(\n anim.animate_carry(\n carry = carry.Carry([[2,-1],[-1,0]]),\n frames=list(range(200))\n ).to_jshtml()\n)\n```\n\n::: {.cell-output .cell-output-display execution_count=1}\n```{=html}\n\n\n\n\n\n\n
\n \n
\n \n
\n \n \n \n \n \n \n \n \n \n
\n
\n \n \n \n \n \n \n
\n
\n
\n\n\n\n```\n:::\n\n::: {.cell-output .cell-output-display}\n![](fig1_files/figure-html/cell-2-output-2.png){width=453 height=469}\n:::\n:::\n\n\n", + "supporting": [ + "fig1_files" + ], + "filters": [], + "includes": { + "include-in-header": [ + "\n\n\n" + ] + } + } +} \ No newline at end of file diff --git a/_freeze/polycount/cell1/fig1/figure-html/cell-2-output-1.png b/_freeze/polycount/cell1/fig1/figure-html/cell-2-output-1.png new file mode 100644 index 0000000..a180dfb Binary files /dev/null and b/_freeze/polycount/cell1/fig1/figure-html/cell-2-output-1.png differ diff --git a/_freeze/polycount/cell1/fig1/figure-html/cell-2-output-2.png b/_freeze/polycount/cell1/fig1/figure-html/cell-2-output-2.png new file mode 100644 index 0000000..5005272 Binary files /dev/null and b/_freeze/polycount/cell1/fig1/figure-html/cell-2-output-2.png differ diff --git a/_freeze/polycount/cell1/index/execute-results/html.json b/_freeze/polycount/cell1/index/execute-results/html.json new file mode 100644 index 0000000..a9ce9b3 --- /dev/null +++ b/_freeze/polycount/cell1/index/execute-results/html.json @@ -0,0 +1,16 @@ +{ + "hash": "d862302e1ad9ae64fb1040bc6a446538", + "result": { + "engine": "jupyter", + "markdown": "---\ntitle: \"Counting in 2D: Lines, Leaves, and Sand\"\nformat:\n html:\n html-math-method: katex\ndate: \"2021-02-23\"\ndate-modified: \"2025-2-14\"\njupyter: python3\ncategories:\n - algebra\n - python\nexecute:\n echo: false\n---\n\n\n\nPreviously, I've written about positional systems and so-called \"[polynomial counting](../1)\".\nBasically, this generalizes familiar integer bases like two and ten into less familiar irrational ones\n like the golden ratio.\nHowever, all systems I presented have something in common: they all use polynomials of a single variable.\nDoes it make sense to count in two variables?\n\n\nPreliminaries\n-------------\n\nBefore proceeding, I will summarize some of the restrictions on which polynomials can be\n used as carries in positional systems.\nCarry polynomials must be nonpositive when evaluated at 1 (otherwise the digital root of\n an expansion is unbounded) and either:\n\n- All coefficients have the same sign but one, which has a much larger\n magnitude than the rest (and forces the digital root condition)\n - These are *explicit* irrational carries\n- They are monic (have leading coefficient 1) and the remaining coefficients are all negative\n and monotonically increase toward 0 after the second coefficient (0's are allowed anywhere)\n - These are *implicit* irrational carries\n\nImplicit carries must be multiplied, typically by cylotomic polynomials, to obtain additional\n rules for larger numerals.\n\n\nA Game of Che...ckers\n---------------------\n\n[Conway's checkers](https://en.wikipedia.org/wiki/Conway%27s_Soldiers) is a game played by attempting to\n advance game pieces to the furthest extent beyond a line.\nA piece can only be moved by jumping it horizontally or vertically over others, which removes them from play.\nSquinting hard enough, in one dimension, this is similar to how in phinary, a \"1\" in an\n expansion can jump over an adjacent \"1\" to its left.\n\n$$\n\\begin{array}{}\n \\bullet \\\\ \\hline \\bullet \\\\ \\hline \\vphantom{\\bullet}\n\\end{array} \\huge⤸ \\normalsize\n~\\longrightarrow~\n\\begin{array}{}\n \\vphantom{\\bullet} \\\\ \\hline \\vphantom{\\bullet} \\\\ \\hline \\bullet\n\\end{array}\n\\quad \\iff \\quad\n0\\textcolor{red}{11} = \\textcolor{red}{1}00\n$$\n\nIn fact, it is exactly the same.\nThe best solution of the game relies on a geometric series in *φ*, as seen in\n [this video by Numberphile](https://www.youtube.com/watch?v=Or0uWM9bT5w).\n\n\n### Pairs of Checkers\n\nTo actually take phinary and systems like it from 1D to 2D, we really just need a carry rule that respects the\n second dimension.\nTo do this, we use a new variable *y* and invent a carry rule based on it.\n\nThe smallest way to extend our one-dimensional string of digits is do just introduce a second string.\nBased on this, my intuition was to replace the standard hop with the movement of a knight in chess.\n\n$$\n\\begin{gather*}\n \\begin{array}{c|c}\n \\bullet & \\phantom{\\bullet} \\\\\n \\hline \\bullet \\\\ \\hline \\vphantom{\\bullet}\n \\end{array}\n ~\\longrightarrow~\n \\begin{array}{c|c}\n \\phantom{\\bullet} & \\phantom{\\bullet} \\\\\n \\hline \\\\ \\hline & \\bullet\n \\end{array}\n ~~ \\iff ~~\n \\left. \\begin{array}{}\n 0\\textcolor{red}{11}_x \\\\\n 000_y\n \\end{array} \\right]\n = \\left. \\begin{array}{}\n 000_x \\\\\n \\textcolor{red}{1}00_y\n \\end{array} \\right ] \\\\ \\\\\n y^2 = x + 1,~ x^2 = y + 1\n\\end{gather*}\n$$\n\nThis looks good on the surface, but it turns out that the polynomials aren't sufficiently intertwined.\nSince each variable is a function of the other, they can easily be coaxed into a single polynomial:\n\n$$\ny = x^2 - 1 \\longrightarrow y^2 = (x^2 - 1)^2 = x + 1 \\\\[6pt]\nx^4 - 2x^2 + 1 = x + 1 \\\\\nx^3 - 2x - 1 = 0 \\\\\n(x + 1)(x^2 - x - 1) = 0\n$$\n\nThe same argument applies symmetrically for *y*.\nOne of the resultant polynomials is the minimal polynomial of *φ*, so the prospective\n 2D system reduces back to standard phinary.\n\nThere are additional problems with this \"pairs of strings\" model.\nFor example, terms like *xy* never appear, and there is no way to represent them by just using two strings.\nAlso, both sequences have a ones' place, but should agree that $x^0 = y^0 = 1$.\n\n\nBuilding the Plane\n------------------\n\nIf it is the case that both powers of variables should share the one's digit, then why not\n join the two strings there?\nIn other words, for each variable, we think of a line with a distinguished point for zero.\nWe then match the distinguished points together.\nThus, instead of a point separator between positive and negative powers,\n the radix point is now a pair of lines that share a vertex.\nFrom this pair of lines, according to Euclid, we can make a plane.\n\n$$\n\\begin{array}{|c}\n \\hline\n f & d & a \\\\\n e & b \\\\\n c\n\\end{array}\n\\begin{matrix} ~\\equiv~\n ax^2 + bxy + cy^2 + dx + ey + f, \\\\\n \\text{the general form of a conic}\n\\end{matrix}\n$$\n\nSince the horizontal and vertical correspond with the *x* and *y* appearing in polynomials,\n it may be easy to confuse this with the *x*- and *y*-axes of the typical Cartesian plane.\nThe key differences here are that these are discrete (two-dimensional) strings, rather than a continuous plane,\n and along each point, there exists a cell in which an integer value lives.\n\n\n### An Arithmetical Aside\n\nExpressed in this way, it is very simple to compute the sum of two polynomials.\nJust like in the 1D system, we can align the one's places, add them together term-by-term, then apply carry rules.\nWith luck, this produces a canonical form.\n\nIt should also be possible to multiply two polynomials together.\nIn a single variable, multiplication is a somewhat involved 1D convolution.\nIn two, it is naturally [2D convolution](https://en.wikipedia.org/wiki/Kernel_(image_processing)),\n an operation typically encountered in image processing and signal analysis.\nI won't bother building up an intuition for this, since it won't be relevant to discussion.\n\nEven if multiplication is difficult, division is always harder.\nIn polynomials of a single variable, we can do synthetic (or long) division.\nNotationally, we work in the direction that the digits do not extend (i.e., downward).\nWith 2D numbers, we have digits in both dimensions.\nFortunately, computer algebra systems can divide and factor polynomials of two variables\n reasonably quickly, so this point is moot if we allow ourselves to use one.\n\n\n1, 2, 3, Takeoff\n----------------\n\nWhere should we start in a world of planar numbers?\nWell, we want to assign an integer to a polynomial with extent in both *x* and *y*.\nThe simplest way to do this is by letting $n = x + y$: when the one's place has\n a magnitude of *n*, it flows into *x* and *y*.\n\nIf $n = 1$, then the sum of coefficients is skewed toward the LHS, and the digital root is unbounded.\nWe had a similar restriction in one dimension.\nTherefore, let $n = 2$.\nThe expansions of the powers of 2 are:\n\n$$\n\\begin{matrix}\n &&\\text{Carry:}&\\begin{array}{|c} \\hline\n -2 & 1 \\\\\n 1\n \\end{array}\\\\\n 1 & 2 & ... & 4 & ... & 8 \\\\\n \\begin{array}{|c} \\hline\n 1\n \\end{array} &\n \\begin{array}{|c} \\hline\n 0 & 1 \\\\\n 1\n \\end{array} & ... &\n \\begin{array}{|c} \\hline\n 0 & 2 \\\\\n 2\n \\end{array} & ... &\n \\begin{array}{|c} \\hline\n 0 & 4 \\\\\n 4\n \\end{array} \\\\ \\\\ &&&\n \\begin{array}{|c} \\hline\n 0 & 0 & 1 \\\\\n 0 & 0 & 1 \\\\\n 1 & 1\n \\end{array} & ... &\n \\begin{array}{|c} \\hline\n 0 & 0 & 2 \\\\\n 0 & 0 & 2 \\\\\n 2 & 2\n \\end{array} \\\\ \\\\ &&&&&\n \\begin{array}{|c} \\hline\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 1 & 1 \\\\\n 0 & 1 & 0 & 1 \\\\\n 1 & 1 & 1\n \\end{array}\n\\end{matrix}\n$$\n\nThe final entry of each column is achieved by applying the carry enough times, reducing all digits\n to \"0\"s and \"1\"s.\nIn doing so, the typical binary expansion is visible along first row and column, albeit reversed.\nThis is always the case, since when the carry is restricted to a single dimension (i.e., let $y = 0$),\n we get the 1D binary carry.\nMore visually, there is no mechanism for the carry to disturb the column and row by spreading either left or up.\nI'll call this system *dibinary*, since it is binary across two variables.\n\nAn additional property of this system is that the number of \"1\"s that appear in the expansion is equal\n to the number itself.\nThese two properties make it a sort of hybrid between unary and binary, bridging their\n binary expansion and its [Hamming weight](https://en.wikipedia.org/wiki/Hamming_weight).\n\nThis notation is very heavy, but fortunately lends itself well visualization.\nEach integer's expansion is more or less an image, so we can arrange each as frames in a video:\n\n::: {#260761f4 .cell execution_count=3}\n\n::: {.cell-output .cell-output-display execution_count=2}\n```{=html}\n\n```\n:::\n:::\n\n\nStarting at the expansion of twelve, the furthest extent is not in the first column or row.\nIt instead grows faster along the diagonal, along which larger triangles appear when\n counting to higher and higher integers.\nMeanwhile, lower degrees (toward the upper left) appear to be slightly less predictable.\n\n\n### Higher *n*\n\nBy incrementing *n*, the expansions of numbers shrink exponentially, and simply incrementing is not fast enough.\nFortunately, this is a simple enough system that we can scalar-multiply base expansions, then assiduously apply the carry.\nAscending the powers of *n* in this manner for the carries where *n* = 3 and 4:\n\n::: {#531f85bd .cell layout-ncol='2' execution_count=4}\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n$$x + y = 3$$\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n$$x + y = 4$$\n:::\n:::\n\n\nYellow corresponds to the highest allowed numeral, $n - 1$.\nIt seems like the lower-right grows much rounder as *n* increases.\nHowever, neither appears to have an emergent pattern as dibinary did.\n\nYou might be familiar with the way hexadecimal is a more compact version of binary.\nFor example,\n\n$$\\textcolor{red}{1}\\textcolor{blue}{2}_{16} = \\textcolor{red}{0001}\\textcolor{blue}{0010}_{2}$$\n\nbecause both one hexadecimal digit and four binary digits can range over zero to fifteen.\nConsequently, by grouping group *m* digits of an expansion in base *b*, one can easily convert to base $b^m$.\n\nIf such a procedure still exists in 2D, applying it somehow destroys the pattern in the $n = 2$ case,\n as the quaternary system is very chaotic.\n\n\nCarry Curves\n------------\n\nSince the carry is a polynomial in both *x* and *y*, it lends itself to interpretation as an algebraic curve.\nTaking *x* or *y* to higher powers will dilate expansions along that axis.\n\nThe carry is not the only curve which exists in a system, as each integer is also a polynomial unto itself.\nAdding a constant term will not change anything unless it causes carries to occur.\nStarting at the carry digit, some of the *incremented curves* made by the carry $x + y = 2$ are shown below.\n\n::: {#d64a9e0b .cell layout='[[3,3],[2,2,2]]' execution_count=5}\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-5-output-1.png){width=662 height=470}\n:::\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-5-output-2.png){width=662 height=470}\n:::\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-5-output-3.png){width=662 height=470}\n:::\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-5-output-4.png){width=662 height=470}\n:::\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-5-output-5.png){width=662 height=470}\n:::\n:::\n\n\nIn each of these figures, shapes like hyperbolae show up and disappear, only to be replaced with\n higher-order curves.\nThese higher order curves can be difficult to graph, so they show up as thicker lines.\nAt sixty-four, it appears as though the reflection of the carry across the origin\n (the curve $x + y = -2$) \"wants\" to appear.\n\nThe continued presence of the original carry curve in larger integers suggests that\n the points it passes through are important.\nThis curve happens to intersect with the *x* and *y* axes, which we can interpret as the \"base\"\n with respect to a single variable.\nFor dibinary, these are the aforementioned \"typical binary expansions\".\nWe can also evaluate the polynomial at $(x, y) = (1, 1)$, a point on the carry curve,\n to compute its digital root, which is also equal to the integer it represents.\nThis underlies a key difference from the 1D case.\n1D systems are special because the carry can be equated with a base (or bases), which\n is a discrete, zero-dimensional point (one dimension less) on a number line.\nIn higher dimensions, there is no proper \"base\" we can plug in to \"test\" that an expansion\n is valid like we can with the golden ratio in phinary.\n\n\nCasting the Line\n----------------\n\nWe may want to extend the \"unary\" property to other carries.\nTo do this, we construct a curve which passes through $(1, 1)$.\n\nLines of the form $(n - 1)x + y = n$ trivially satisfy this relationship.\nFurther, while the digits along the *y* column will be expansions of base *n*, those along *x* will\n be in base $n / (n - 1)$.\n\nFor example, for $n = 3$\n\n$$\n\\begin{matrix}\n &&&\\text{Carry:}&\n \\begin{array}{|c} \\hline\n -3 & 2 \\\\\n 1\n \\end{array}\\\\\n 1 & ... & 3 & ... & 6 & ... & 9 \\\\\n \\begin{array}{|c} \\hline\n 1\n \\end{array} & ... &\n \\begin{array}{|c} \\hline\n 0 & 2 \\\\\n 1\n \\end{array} & ... &\n \\begin{array}{|c} \\hline\n 0 & 4 \\\\\n 2\n \\end{array} & ... &\n \\begin{array}{|c} \\hline\n 0 & 6 \\\\\n 3\n \\end{array} \\\\ \\\\ &&&&\n \\begin{array}{|c} \\hline\n 0 & 1 & 2 \\\\\n 2 & 1\n \\end{array} & ... &\n \\begin{array}{|c} \\hline\n 0 & 3 & 2 \\\\\n 3 & 1\n \\end{array} \\\\ \\\\ &&&&&&\n \\begin{array}{|c} \\hline\n 0 & 0 & 1 & 2 \\\\\n 0 & 1 & 0 & 2 \\\\\n 1 & 1 & 1\n \\end{array}\n\\end{matrix}\n$$\n\nThe expansion in the *y* column looks trivially correct, since $y^2 = 9$ when $x = 0$.\nWe can check the base of the expansion of nine (\"2100\") by factoring a polynomial:\n\n::: {#9803cc67 .cell execution_count=6}\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n$\\displaystyle 2 x^{3} + x^{2} - 9 = \\left(2 x - 3\\right) \\left(x^{2} + 2 x + 3\\right)$\n:::\n:::\n\n\nThe linear polynomial has 3/2 as a root, while the quadratic one has only complex roots.\n\nNaturally, these expansions work symmetrically by considering *y* to have the $n - 1$ coefficient instead of *x*.\nThis transposes the carry (and hence the expansion).\n\n\n### Slanted Counting\n\nFor good measure, let's see what it looks like when we count in the $n = 3$ and $n = 4$ cases.\n\n::: {#ce82ae6e .cell layout-ncol='2' execution_count=7}\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n$$2x + y = 3$$\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n$$3x + y = 4$$\n:::\n:::\n\n\nThe pattern produced is similar to the one from dibinary.\nHowever, the triangular pattern no longer grows all at once, and instead, the bottom leads the top.\nMeanwhile, the disordered part in the upper left of the expansion appears to grow larger as *n* increases,\n not to mention that it contains many artifacts from smaller colors.\n\nThe slope of the pattern is $1 / (n - 1)$, since this is the ratio of growth between *x* and *y*.\nAs *n* grows, the diagonal pattern gets thinner and takes longer to show up.\nThis is because the size of the alphabet causing expansions to shrink *geometrically*, while the digital\n root is always increasing *arithmetically*.\nThe binary alphabet is the smallest possible, so the minimal shrinkage is in dibinary.\n\n\n### Incremented Curves\n\nBelow are the incremented curves for $n = 3$.\nThese curves show an interesting phenomenon: an extra line is present in in the expansion of six.\nThis line turns into a spike at twelve, then at fifteen, it seems to grow to encompass the point at infinity.\n\n::: {#741ee02d .cell layout-ncol='2' execution_count=8}\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-8-output-1.png){width=662 height=470}\n:::\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-8-output-2.png){width=662 height=470}\n:::\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-8-output-3.png){width=662 height=470}\n:::\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-8-output-4.png){width=662 height=470}\n:::\n:::\n\n\nLeaves in the Mirror\n--------------------\n\nAlgebraic curves are not my forte.\nHowever, let's briefly look at some classical examples from the perspective of carries.\n\n\n### Quadratic Curves\n\nUnfortunately, the most common quadratic curves are largely uninteresting.\nBriefly, here are some comments about some the simplest cases:\n\n- Unit circle ($x^2 + y^2 - 1 = 0$) and hyperbola ($\\pm x^2 \\mp y^2 - 1 = 0$)\n - The sum of coefficients is positive, which means that expansions are unbounded.\n - Alternatively, coefficients are of an improper form, since one positive coefficient\n does not outweigh all remaining negative coefficients.\n - The curve as a function in *x* and *y* can be written in simpler terms, i.e., $F(x, y) = G(x^2, y^2)$\n- Hyperbola ($xy \\pm 1 = 0$)\n - The curve is a function of only *xy*, i.e., $F(x, y) = P(xy)$,\n so the curve degenerates to one-dimensional unary.\n- Parabolae ($y = \\pm x^2,~ x = \\pm y^2$)\n - One coefficient does not outweigh the other.\n - The system degenerates to a single dimeension due to the fact that either *y* is a polynomial in *x* or vice versa\n\nOther polynomials in *x* and *y* may produce rotations or dilations of these curves,\n but the key fact is that this interpretation is secondary.\nWhat truly matters is that one cell affects relatively close cells in a certain way.\n\n\n### Higher-Order Curves\n\nAll unit Fermat curves $x^n + y^n = 1$ are not suitable as carries, since their digital root is unbounded.\nScaling up the curve, for example to $x^n + y^n = 2$, will just degenerate back to the previous\n examples with lines, but spaced out by zeros between entries.\n\nThe [folium of Descartes](https://en.wikipedia.org/wiki/Folium_of_Descartes) is another\n classical curve that played a role in the development of calculus, described by the equation:\n\n$$\n\\begin{gather*}\n x^3 + y^3 - 3axy = 0\n \\\\ \\\\\n \\begin{array}{|c} \\hline\n 0 & 0 & 0 & 1 \\\\\n 0 & -3a \\\\\n 0 & \\\\\n 1\n \\end{array}\n\\end{gather*}\n$$\n\nAs written above, the position of the 3*a* term may be confusing.\nAs the negative term in an explicit carry, we must place it atop the digit we are carrying,\n meaning that expansions will propagate toward negative powers of *x* and *y* as well as positive.\nWhile the shape of the curve is different from an ordinary line, the coefficients are arranged\n too similarly; for $a = 2/3$ (so the curve passes through the point $(1, 1)$) incrementing appears as:\n\n::: {#51141cba .cell layout-ncol='2' execution_count=9}\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n\\begin{gather*}2: &\\begin{array}{c|cc}0 & 0 & 0 & 1 \\\\ \\hline 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 \\\\ 1 & 0 & 0 & 0 \\\\ \\end{array}\\\\\\\\ \\\\ 4: &\\begin{array}{cc|cccc}0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ \\hline 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\ 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ \\end{array}\\\\\\end{gather*}\n:::\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n:::\n\n\nClearly, this also tends back toward dibinary, but with the yellow digits spaced out more.\n\n\nLaplace's Sandstorm\n-------------------\n\nAs stated previously, polynomials naturally multiply by convolution.\nIn the context of this operation, the discrete 2D Laplacian is frequently used\nWhile commonly presented as a matrix, it has very little to do with the machinery of\n linear algebra which normally empowers matrices.\n\n::: {layout-ncol=\"2\"}\n$$\n\\begin{gather*}\n \\begin{bmatrix}\n 0 & 1 & 0 \\\\\n 1 & -4 & 1 \\\\\n 0 & 1 & 0\n \\end{bmatrix} ~\\implies~\n \\begin{array}{c|cc}\n & 1 & \\\\ \\hline\n 1 & -4 & 1 \\\\\n & 1\n \\end{array} \\\\ \\\\\n x + x^{-1} + y + y^{-1} - 4 = 0 \\\\\n x + xy^2 + y + yx^2 - 4xy = 0\n\\end{gather*}\n$$\n\n::: {#13119403 .cell execution_count=10}\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-10-output-1.png){width=662 height=469}\n:::\n:::\n\n\n:::\n\nFrom the above, it is clear that this is a cubic curve.\nAside from the trivial solution $x = y = 0$ (which obviously also satisfies *x* = *y*),\n the curve made by the carry does not intersect either axis.\nThere is an additional isolated point at (1, 1), implying some is in unary-ness this system.\nIf we make it a carry, then the first few powers of 4 are\n\n$$\n\\begin{matrix}\n 1 & ... & 4 & ... & 16 \\\\\n \\begin{array}{|c} \\hline\n 1\n \\end{array} & ... &\n \\begin{array}{c|cc}\n 0 & 1 & 0 \\\\ \\hline\n 1 & 0 & 1 \\\\\n 0 & 1 &\n \\end{array} & ... &\n \\begin{array}{c|cc}\n 0 & 4 & 0 \\\\ \\hline\n 4 & 0 & 4 \\\\\n 0 & 4 &\n \\end{array} \\\\ \\\\ &&&&\n \\begin{array}{cc|cc}\n & & 1 \\\\\n & 2 & 0 & 2 \\\\ \\hline\n 1 & 0 & 4 & 0 & 1 \\\\\n & 2 & 0 & 2 \\\\\n & & 1\n \\end{array} \\\\ \\\\ &&&&\n \\begin{array}{cc|cc}\n & & 1 \\\\\n & 2 & 1 & 2 \\\\ \\hline\n 1 & 1 & 0 & 1 & 1 \\\\\n & 2 & 1 & 2 \\\\\n & & 1\n \\end{array}\n\\end{matrix}\n$$\n\nAs the negative (and largest) term, we carry at the \"4\" entry, as shown above.\nTerms progress along lower and higher powers of *x* and *y*.\nHowever, rather than just rightward propagation interfering with downward propagation (and vice versa),\n all directions can interfere with each other.\n\nThis system can be interpreted more naturally as a\n [sandpile](https://en.wikipedia.org/wiki/Abelian_sandpile_model).\nAs a cellular automaton, it is rather popular as a coding challenge\n ([video by The Coding Train](https://www.youtube.com/watch?v=diGjw5tghYU)),\n and when the grid is finite, certain subsets of all possible elements form finite groups under addition\n ([video by Numberphile](https://www.youtube.com/watch?v=1MtEUErz7Gg)).\nThese videos discuss toppling the initial value, but do not point out the analogy to polynomial expansions.\n\n::: {#c7293109 .cell layout-ncol='2' execution_count=11}\n\n::: {.cell-output .cell-output-display execution_count=10}\n```{=html}\n\n```\n:::\n:::\n\n\nThe shapes produced by this pattern are well-known, with larger numbers appearing as fractals.\nGenerally, the expansions are enclosed within a circle, with shrinking triangular looking sections.\nThis is eerily similar to the same shrinking triangles which appear in other unary-like carries.\n\n\nClosing\n-------\n\nAll of the 2D carries presented here are explicit carries.\nUnlike phinary, they have no additional rules hidden in mutliples of the carry.\nIt seems to be the case that implicit carries in two variables can be found by\n selecting a cyclotomic polynomial (in *x*, *y*, and $x + y$)\n and computing an explicit carry by multiplying it with another polynomial.\nSome of my investigations into this topic are available [here](../cell2).\n\nI should also mention that my notational inspiration for arranging digits things in\n a 2D array is Norman Wildberger's variable-free approach to\n \"[bipolynumbers](https://www.youtube.com/watch?v=_9FvrO1JTTI)\", a term he uses\n to refer to polynomials of two variables.\n\nJust as learning to count on polynomials in a single variable opens up a world of possibilities,\n learning to count on those in two variables is a perplexing topic that is worth exploring.\n\n", + "supporting": [ + "index_files" + ], + "filters": [], + "includes": { + "include-in-header": [ + "\n\n\n" + ] + } + } +} \ No newline at end of file diff --git a/_freeze/polycount/cell1/index/figure-html/cell-10-output-1.png b/_freeze/polycount/cell1/index/figure-html/cell-10-output-1.png new file mode 100644 index 0000000..8e4f333 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-10-output-1.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-11-output-2.png b/_freeze/polycount/cell1/index/figure-html/cell-11-output-2.png new file mode 100644 index 0000000..d76bce1 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-11-output-2.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-2-output-2.png b/_freeze/polycount/cell1/index/figure-html/cell-2-output-2.png new file mode 100644 index 0000000..5005272 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-2-output-2.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-3-output-1.png b/_freeze/polycount/cell1/index/figure-html/cell-3-output-1.png new file mode 100644 index 0000000..08495f2 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-3-output-1.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-3-output-2.png b/_freeze/polycount/cell1/index/figure-html/cell-3-output-2.png new file mode 100644 index 0000000..f22a263 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-3-output-2.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-3-output-3.png b/_freeze/polycount/cell1/index/figure-html/cell-3-output-3.png new file mode 100644 index 0000000..cb2a484 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-3-output-3.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-3-output-4.png b/_freeze/polycount/cell1/index/figure-html/cell-3-output-4.png new file mode 100644 index 0000000..b7333f7 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-3-output-4.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-3-output-5.png b/_freeze/polycount/cell1/index/figure-html/cell-3-output-5.png new file mode 100644 index 0000000..68e2c95 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-3-output-5.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-3-output-6.png b/_freeze/polycount/cell1/index/figure-html/cell-3-output-6.png new file mode 100644 index 0000000..03c752c Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-3-output-6.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-3-output-7.png b/_freeze/polycount/cell1/index/figure-html/cell-3-output-7.png new file mode 100644 index 0000000..3467d69 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-3-output-7.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-3-output-8.png b/_freeze/polycount/cell1/index/figure-html/cell-3-output-8.png new file mode 100644 index 0000000..e9159ee Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-3-output-8.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-4-output-5.png b/_freeze/polycount/cell1/index/figure-html/cell-4-output-5.png new file mode 100644 index 0000000..35ad995 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-4-output-5.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-5-output-1.png b/_freeze/polycount/cell1/index/figure-html/cell-5-output-1.png new file mode 100644 index 0000000..38c9fd5 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-5-output-1.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-5-output-2.png b/_freeze/polycount/cell1/index/figure-html/cell-5-output-2.png new file mode 100644 index 0000000..330ac72 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-5-output-2.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-5-output-3.png b/_freeze/polycount/cell1/index/figure-html/cell-5-output-3.png new file mode 100644 index 0000000..287c37b Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-5-output-3.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-5-output-4.png b/_freeze/polycount/cell1/index/figure-html/cell-5-output-4.png new file mode 100644 index 0000000..87675f9 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-5-output-4.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-5-output-5.png b/_freeze/polycount/cell1/index/figure-html/cell-5-output-5.png new file mode 100644 index 0000000..ded5391 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-5-output-5.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-7-output-1.png b/_freeze/polycount/cell1/index/figure-html/cell-7-output-1.png new file mode 100644 index 0000000..c6d24fc Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-7-output-1.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-7-output-2.png b/_freeze/polycount/cell1/index/figure-html/cell-7-output-2.png new file mode 100644 index 0000000..5c089b3 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-7-output-2.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-7-output-3.png b/_freeze/polycount/cell1/index/figure-html/cell-7-output-3.png new file mode 100644 index 0000000..8bfa842 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-7-output-3.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-7-output-4.png b/_freeze/polycount/cell1/index/figure-html/cell-7-output-4.png new file mode 100644 index 0000000..d743d9f Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-7-output-4.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-7-output-5.png b/_freeze/polycount/cell1/index/figure-html/cell-7-output-5.png new file mode 100644 index 0000000..e4fc8cf Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-7-output-5.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-8-output-1.png b/_freeze/polycount/cell1/index/figure-html/cell-8-output-1.png new file mode 100644 index 0000000..94809bd Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-8-output-1.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-8-output-2.png b/_freeze/polycount/cell1/index/figure-html/cell-8-output-2.png new file mode 100644 index 0000000..36701db Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-8-output-2.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-8-output-3.png b/_freeze/polycount/cell1/index/figure-html/cell-8-output-3.png new file mode 100644 index 0000000..8b5d6cd Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-8-output-3.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-8-output-4.png b/_freeze/polycount/cell1/index/figure-html/cell-8-output-4.png new file mode 100644 index 0000000..ec5a8ed Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-8-output-4.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-9-output-1.png b/_freeze/polycount/cell1/index/figure-html/cell-9-output-1.png new file mode 100644 index 0000000..a4815dd Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-9-output-1.png differ diff --git a/_freeze/polycount/cell1/index/figure-html/cell-9-output-3.png b/_freeze/polycount/cell1/index/figure-html/cell-9-output-3.png new file mode 100644 index 0000000..30fe6c2 Binary files /dev/null and b/_freeze/polycount/cell1/index/figure-html/cell-9-output-3.png differ diff --git a/_freeze/polycount/cell1/test/execute-results/html.json b/_freeze/polycount/cell1/test/execute-results/html.json new file mode 100644 index 0000000..041781a --- /dev/null +++ b/_freeze/polycount/cell1/test/execute-results/html.json @@ -0,0 +1,12 @@ +{ + "hash": "937ac2b4de72d9620cca965da349a412", + "result": { + "engine": "jupyter", + "markdown": "::: {#239fae83 .cell execution_count=1}\n``` {.python .cell-code}\n%matplotlib notebook\nimport numpy as np\nfrom carry2d import anim, carry\n\nfrom IPython.display import Latex, display_latex\n\nanim.animate_carry_count(\n carry = carry.Carry([\n [-2, 1],\n [ 1, 0]\n ]),\n frames=list(range(256))\n)\n```\n:::\n\n\n", + "supporting": [ + "test_files" + ], + "filters": [], + "includes": {} + } +} \ No newline at end of file diff --git a/_freeze/polycount/cell1/test/figure-html/cell-2-output-1.png b/_freeze/polycount/cell1/test/figure-html/cell-2-output-1.png new file mode 100644 index 0000000..88f750a Binary files /dev/null and b/_freeze/polycount/cell1/test/figure-html/cell-2-output-1.png differ diff --git a/_freeze/polycount/cell2/index/execute-results/html.json b/_freeze/polycount/cell2/index/execute-results/html.json new file mode 100644 index 0000000..e0bab44 --- /dev/null +++ b/_freeze/polycount/cell2/index/execute-results/html.json @@ -0,0 +1,16 @@ +{ + "hash": "0bcc4b142e90ea1913bb3db934dc2a51", + "result": { + "engine": "jupyter", + "markdown": "---\ntitle: \"Counting in 2D 2: Reorienting Polynomials\"\ndraft: true\nformat:\n html:\n html-math-method: katex\ndate: \"2021-03-07\"\ndate-modified: \"2025-02-23\"\njupyter: python3\ncategories:\n - algebra\n - python\nexecute:\n echo: false\n---\n\n\n\n[Previously](../cell1), I explored some very basic 2D counting systems, which turned out to include sandpiles.\nAs the name suggests, these planar numbers require a discrete grid of numbers to contain them.\nWhat follows is a deeper investigation into this natural extension of positional systems.\n\n\nDirection of Propagation\n------------------------\n\nGiven a carry (expressed as a polynomial in two variables or a grid) and an increasing sequence of integers,\n the expansions of the sequence will appear to propagate in a certain direction.\nRecall that from the last post, we know that $x + y = 2$ and a certain case of\n the folium of Descartes will make similar patterns:\n\n$$\n\\begin{gather*}\n & ~ & \\text{Folium} \\\\\n x + y - 2 & ~ &\n x^3 + y^3 - 2xy \\\\\n \\begin{array}{|c} \\hline\n \\bar{2} & 1 \\vphantom{2^{2^2}} \\\\\n 1\n \\end{array} & ~ &\n \\begin{array}{|c} \\hline\n 0 & 0 & 0 & 1 \\\\\n 0 & \\bar{2} \\\\\n 0 \\\\\n 1\n \\end{array}\n\\end{gather*}\n$$\n\nThe general direction in which we carry can be understood as the directions from the negative term of the carry\n (hereafter *pseudo-base*) to the other terms.\nThese can interpreted vectors extending from the pseudo-base to every other term.\nThe simplest way to get these vectors is by placing the pseudo-base at the constant position\n and reading off the exponent of the other terms.\n\n$$\n\\begin{gather*}\n \\begin{array}{|c} \\hline\n \\bar{2} & \\textcolor{red}{1} \\vphantom{2^{2^2}} \\\\\n \\textcolor{blue}{1}\n \\end{array} & ~ &\n \\begin{array}{c|cc}\n 0 & 0 & 0 & \\textcolor{red}{1} \\\\ \\hline\n 0 & \\bar{2} \\vphantom{2^{2^2}} \\\\\n 0 \\\\\n \\textcolor{blue}{1}\n \\end{array} \\\\\n \\begin{matrix}\n \\textcolor{red}{ x^1 y^0 } \\implies \\langle 1, 0 \\rangle \\\\\n \\textcolor{blue}{ x^0 y^1 } \\implies \\langle 0, 1 \\rangle\n \\end{matrix}\n & ~ &\n \\begin{matrix}\n \\textcolor{red}{ x^2 y^{-1} } \\implies \\langle 2, -1 \\rangle \\\\\n \\textcolor{blue}{ x^{-1} y^2 } \\implies \\langle -1, 2 \\rangle\n \\end{matrix}\n\\end{gather*}\n$$\n\nIt is clear that as we count, the expansions can extend only in a linear combination of these vectors.\nHowever, they cannot propagate in the reverse direction, as there is no sense of \"backwards\".\n\n\n### Balancing Act\n\nWe can naively balance the carry by adding additional carry digits.\nTo do this, we just need to double the pseudo-base and add reflections each vector in it.\nEquivalently, this adds the carry with the carry where we have replaced *x* and *y* with their reciprocals.\n\nIf we balance the left carry, it yields the Laplacian.\nBut what about the right?\nUnsurprisingly, it just stretches the expansions along the different \"basis\" vectors.\n\n::: {layout-ncol=\"2\"}\n$$\n\\textcolor{red}{ x^{-2} y^{1} } + x^{-1} y^{2} + \\textcolor{blue}{ x^{1} y^{-2} } + x^{2} y^{-1} - 4 \\\\\n\\begin{array}{cc|ccc}\n & & & \\textcolor{blue}{1} \\\\\n & & 0 & 0 & 1 \\\\ \\hline\n & 0 & \\bar{4} & 0 \\vphantom{2^{2^2}} \\\\\n \\textcolor{red}{1} & 0 & 0 \\\\\n & 1\n\\end{array} \\\\\n\\text{Added Vectors:} \\\\\n\\begin{matrix}\n \\textcolor{red}{\n \\langle -2, 1 \\rangle\n } \\\\\n \\textcolor{blue}{\n \\langle 1, -2 \\rangle\n }\n\\end{matrix}\n$$\n\n::: {#7f137696 .cell execution_count=3}\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n:::\n\n\n:::\n\n\n### Half-Balanced\n\nThe Laplacian carry is remarkably balanced, but it provokes the question of what the expansions\n look like if there are only three directions to propagate.\nThe intuition from above says that it should span a half-plane,\n up from the quarter-plane that $x + y = 2$ spans.\n\n::: {layout-ncol=\"2\"}\n$$\n\\textcolor{red}{ x^{-1} } + x^1 + y^1 - 3 \\\\\n\\begin{array}{c|cc} \\hline\n \\textcolor{red}{1} & \\bar{3} & 1 \\vphantom{2^{2^2}} \\\\\n 0 & 1 & 0\n\\end{array} \\\\\n\\text{Added Vector:} \\\\\n\\begin{matrix}\n \\textcolor{red}{\n \\langle -1, 0 \\rangle\n }\n\\end{matrix}\n$$\n\n::: {#d6364f53 .cell execution_count=4}\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n:::\n\n\n:::\n\nFortunately, this is the case.\n\n\n### 2D Carry Types\n\nBased on the extent of the vectors, in general there appear to be four classes:\n\n1. The degenerate one-dimensional case\n - The carry is equivalent to the product of a polynomial in a single variable and any power *x* and/or *y*.\n2. Quarter-planes, like $x + y = 2$\n - Arise when the inverses of the vectors are inaccessible.\n3. Half-planes, like the above \"semi-\"Laplacian\n - Arise when two vectors are collinear and point in opposite directions,\n but every other vector is either on one side of this line or are also collinear.\n4. Full planes, like the Laplacian\n - Arise when the inverses of both vectors are accessible.\n\nQuarter-plane is a bit of a misnomer.\nTechnically, the fraction of the plane spanned is between 0 and 1/2 noninclusive\n (as these bounds correspond to the previous and next cases respectively).\nFor example, $x + y = 2$ actually to a quarter-plane, as the first row/column\n (which contain binary expansions) are unbounded.\nHowever, the Folium encompasses slightly more of the plane, or...\n\n$$\n\\frac{1}{2\\pi}\\arccos \\left (\n \\frac{\\langle 2, -1 \\rangle \\cdot \\langle -1, 2 \\rangle}\n {\\| \\langle 2, -1 \\rangle \\| \\| \\langle -1, 2 \\rangle \\|}\n\\right)\n= \\frac{1}{2\\pi} \\arccos \\left ( -\\frac 4 5 \\right )\n\\approx 0.397584\n$$\n\n...about 39% of the plane.\nThis is still smaller than the half-plane case.\n\n\nHunting for Implicitness\n------------------------\n\nWith these categories in mind, I would now like to shift focus.\nAll systems discussed thus far have been explicit and irreducible, meaning they are\n not derived from any \"simpler\" implicit rules.\nDo such rules exist, and cam we find any?\n\nAs mentioned previously, in the 1D case, we form explicit carries from implicit ones by\n multiplying the latter by cyclotomic polynomials.\nIt would be convenient if the same were true in two dimensions -- we generate an explicit 2D carry from\n the product of some input polynomial and a cyclotomic polynomial in x and y.\nHowever, I would like to leverage the visual representation used previously,\n since working with coefficients is linear, unintuitive, and most importantly, annoying.\n\n\n![](./polyproduct.png)\n\nAbove is a screenshot of (my admittedly low-effort) attempt to ameliorate these shortcomings.\nThe left image is clickable, with the coefficients incrementing with left clicks and decrementing with right.\nThe text box controls the second multiplicand in the center image by selecting a cyclotomic polynomial\n and evaluating it with a particular expression.\nThe right image is the product.\n\nIt could obviously be improved by showing the coefficients in the picture and using color to only indicate sign.\nHowever, there is a benefit to hiding coefficients behind solid colors.\nFor instance, I don't need to recognize numerals to pinpoint what the product should look like.\n\n\n### Degenerate Expressions\n\nI have chosen to evaluate the right term (center image) at $x + y$ for a reason.\nChoosing *x* or *y* on their own is a poor decision because they change nothing from the one dimensional case.\nPut another way, when arranged in a grid, the coefficients are all collinear.\nAt first blush, *xy* seems like a decent pick, but it has the exact same problem;\n the line simply extends along the diagonal instead.\n$x/y$ has the same problem, but it is instead collinear along the anti-diagonals.\nWe allow negative exponents for the same reason we can carry at any location in an expansion\n\n::: {#cf00dfbe .cell execution_count=5}\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-5-output-1.png){width=512 height=469}\n:::\n:::\n\n\nIt should go without saying that these are all degenerate, and can only span a line.\nOn the other hand, expressions like the sum of *x* and *y* form triangles, 2D shapes\n from which it is possible to build our goal polynomial.\nSince $x + y$ is symmetric in *x* and *y*, it is expected that the products have a similar sense of symmetry.\n\n\nFirst Results\n-------------\n\n![](./first_implicit.png)\n\nThe first explicit product I was able to find is above.\nIt can be decomposed as the folium of Descartes, but with an extra term to the upper-left of the pseudo-base.\nThe implicit carry (the left multiplicand) describes the rearrangement of coefficients\n in a backwards L-shape to and from a sparser upside-down L-shape.\nSince the coefficients of this factor sum to zero, it passes through $(1, 1)$.\n\n$$\n\\begin{gather*}\n \\text{Folium} & ~ & \\text{New carry} \\\\\n x^3 + y^3 - 2xy & ~ &\n x^3 + y^3 + 1 - 3xy \\\\\n \\begin{array}{|c} \\hline\n 0 & 0 & 0 & 1 \\\\\n 0 & \\bar{2} \\\\\n 0 \\\\\n 1\n \\end{array} & ~ &\n \\begin{array}{|c} \\hline\n 1 & 0 & 0 & 1 \\\\\n 0 & \\bar{3} \\\\\n 0 \\\\\n 1\n \\end{array}\n\\end{gather*}\n$$\n\n\n### Cousin Systems\n\nMy first thought upon seeing this carry was to see what makes counting in this system different\n from its \"neighbors\".\nBy this, I mean moving the $x^3$ and $y^3$ terms further inward and outward.\n\n$$\n\\begin{gather*}\n x + y + 1 - 3xy &\n x^2 + y^2 + 1 - 3xy \\\\\n \\begin{array}{|c} \\hline\n 1 & 1 \\\\\n 1 & \\bar{3} \\\\\n \\end{array} &\n \\begin{array}{|c} \\hline\n 1 & 0 & 1 \\\\\n 0 & \\bar{3} \\\\\n 1\n \\end{array} \\\\\n \\textcolor{red} {x^3 + y^3 + 1 - 3xy} &\n x^4 + y^4 + 1 - 3xy \\\\\n \\textcolor{red} {\n \\begin{array}{|c} \\hline\n 1 & 0 & 0 & 1 \\\\\n 0 & \\bar{3} \\\\\n 0 \\\\\n 1\n \\end{array}\n } &\n \\begin{array}{|c} \\hline\n 1 & 0 & 0 & 0 & 1 \\\\\n 0 & \\bar{3} \\\\\n 0 \\\\\n 0 \\\\\n 1\n \\end{array}\n\\end{gather*}\n$$\n\nAll polynomials besides the one under consideration (highlighted in red) are irreducible.\nThis means that these carries hide no implicit rules, and are as fundamental as the Laplacian or $x + y = 2$.\n\nAnalyzing the carry vectors, it is clear that the pattern produced by each should be different:\n\n$$\n\\begin{gather*}\n x^{-1} y^{0} + x^{-1} y^{-1} + x^{0} y^{-1} - 3 &\n x^{-1} y^{1} + x^{-1} y^{-1} + x^{1} y^{-1} - 3 \\\\\n \\begin{matrix}\n \\langle -1, 0 \\rangle \\\\\n \\langle -1, -1 \\rangle \\\\\n \\langle 0, -1 \\rangle\n \\end{matrix} &\n \\begin{matrix}\n \\langle -1, 1 \\rangle \\\\\n \\langle -1, -1 \\rangle \\\\\n \\langle 1, -1 \\rangle\n \\end{matrix} \\\\\n x^{-1} y^{2} + x^{-1} y^{-1} + x^{2} y^{-1} - 3 &\n x^{-1} y^{3} + x^{-1} y^{-1} + x^{3} y^{-1} - 3 \\\\\n \\begin{matrix}\n \\langle -1, 2 \\rangle \\\\\n \\langle -1, -1 \\rangle \\\\\n \\langle 2, -1 \\rangle\n \\end{matrix} &\n \\begin{matrix}\n \\langle -1, 3 \\rangle \\\\\n \\langle -1, -1 \\rangle \\\\\n \\langle 3, -1 \\rangle\n \\end{matrix} \\\\\n\\end{gather*}\n$$\n\nThe vectors in the top-left carry contain only negative numbers, so it will tend toward\n the quarter-plane case like $x + y = 2$.\nIn the top-right carry, all vectors are equidistant and meet at right (and straight) angles.\nThis means that it is a 45° rotation of the altered Laplacian, which spans a half-plane.\nThe remaining two should both propagate into the full plane. Is this reflected in the counting videos?\n\n::: {}\n\n::: {#126751d6 .cell execution_count=6}\n\n::: {.cell-output .cell-output-display execution_count=5}\n```{=html}\n\n```\n:::\n:::\n\n\nCounting in each of the $x^n + y^n + \\ldots$ systems\n:::\n\nIndeed it is.\nHowever, while the discovered carry remarkably remains centered, the final one tends more toward\n propagating to the lower right.\nIt has somehow exceeded a threshold that the centered one has not.\n\nIncidentally, the L-shapes in the implicit carry (which I noted can be interchanged) never turn up,\n and the \"initial rule\" is useless.\nPhinary, the simplest implicit case in one dimension, still requires the initial rule to go\n from the expansion of 2 (10.01) to 3 (100.01).\n\n\nIsosceles Rotations\n-------------------\n\nOne of the similar carries is a rotation of a pattern we were already familiar with,\n like the folium was to $x + y = 2$\nDoes this mean we can rotate the centered pattern?\nIf so, is will the carry polynomial still be factorable?\n\nNaively, the following carry might look similar...\n\n::: {layout-ncol=\"2\"}\n$$\n\\begin{array}{|c} \\hline\n & & \\textcolor{red}{1} \\\\\n & & \\bar{3} \\\\\n \\textcolor{green}{1} & & & & \\textcolor{blue}{1}\n \\end{array} \\\\\n \\begin{matrix}\n \\textcolor{red}{\\langle 0,-1 \\rangle} \\\\\n \\textcolor{green}{\\langle -2,1 \\rangle} \\\\\n \\textcolor{blue}{\\langle 2,1 \\rangle} \\\\\n \\text{Angle to top} \\approx 116°\n\\end{matrix}\n$$\n\n::: {#8d02f790 .cell execution_count=7}\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n:::\n\n\n:::\n\nBut there are only even numbers in the first component of each vector\nTherefore, the carry below will produce the same pattern.\n\n::: {layout-ncol=\"2\"}\n$$\n\\begin{array}{|c} \\hline\n & \\textcolor{red}{1} \\\\\n & \\bar{3} \\\\ \\textcolor{green}{1}\n && \\textcolor{blue}{1}\n\\end{array} \\\\\n\\begin{matrix}\n \\textcolor{red}{\\langle 0,-1 \\rangle} \\\\\n \\textcolor{green}{\\langle -1,1 \\rangle} \\\\\n \\textcolor{blue}{\\langle 1,1 \\rangle} \\\\\n \\text{Angle to top} = 135°\n\\end{matrix}\n$$\n\n::: {#e1f81157 .cell execution_count=8}\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n:::\n\n\n:::\n\nNeither of these are similar to the original.\nFor comparison, the largest angle in the nonrotated case is ~108°.\nIn fact, the shape is much closer to the similar orientation with $x^4 + y^4 + \\ldots$ terms.\n\n\n### Checking Magnitudes\n\nMeasuring these quantities as angles is a bit of a lie.\nSince all of these triangles are isosceles, two of the vectors have equal magnitude.\nFurther, each can be characterized by the ratio between them and the final vector's magnitude.\nThe previous two triangles have ratio:\n\n$$\n\\\\\n\\frac{m_1}{n_1} =\n\\frac{\\| \\langle -2, -1 \\rangle \\|}{\\| \\langle 0, -1 \\rangle \\|} =\n\\frac{\\sqrt 5}{1} =\n\\sqrt 5\n\\\\\n\\frac{m_2}{n_2} =\n\\frac{\\| \\langle -1, -1 \\rangle \\|}{\\| \\langle 0, -1 \\rangle \\|} =\n\\frac{\\sqrt 2}{1} =\n\\sqrt 2\n$$\n\nThe triangle we are trying to rotate has ratio:\n\n$$\n\\frac{m}{n} =\n\\frac{\\| \\langle 2, -1 \\rangle \\|}{\\| \\langle -1, -1 \\rangle \\|} =\n\\frac{\\sqrt 5}{\\sqrt 2} =\n\\frac{\\sqrt {10}}{2}\n$$\n\nObviously, one cannot express $\\sqrt 10$ from only one of $\\sqrt 2$ or $\\sqrt 5$.\nFortunately, this suggests the rotation:\n\n::: {layout-ncol=\"2\"}\n$$\n\\begin{gather*}\n \\begin{array}{|c} \\hline\n & & & \\textcolor{red}{\\bar{1}} \\\\\n \\\\\n & & & \\bar{3} \\\\\n \\textcolor{green}{1} & & & & & & \\textcolor{blue}{1}\n \\end{array} ~~\n \\begin{matrix}\n \\textcolor{red}{\\langle 0,-2 \\rangle} \\\\\n \\textcolor{green}{\\langle -3,1 \\rangle} \\\\\n \\textcolor{blue}{\\langle 3,1 \\rangle} \\\\\n \\end{matrix} \\\\\n \\frac{\\| \\langle -3, 1 \\rangle \\|}{\\| \\langle 0, -2 \\rangle \\|}\n = \\frac{\\sqrt {10}}{2} \\\\\n\\end{gather*}\n$$\n\n::: {#49bd454c .cell execution_count=9}\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n:::\n\n\n:::\n\nThe counting video looks very promising, but can the polynomial factored?\nFortunately, yes.\n\n$$\n\\begin{gather*}\n x^{6} y^{3} + x^{3} + y^{3} - 3 x^{3} y^{2} &=&\n (x^{4} y^{2} - x^{3} y - x^{2} y^{2} + x^{2} - x y + y^{2}) \\\\\n && (x^2 y + x + y ) \\\\\n \\begin{array}{|c} \\hline\n & & & 1 \\\\\n \\\\\n & & & \\bar{3} \\\\\n 1 & & & & & & \\bar{1}\n \\end{array} &=&\n \\begin{array}{|c} \\hline\n & & 1 & \\\\\n & \\bar{1} & & \\bar{1} & \\\\\n 1 & & \\bar{1} & & 1 \\\\\n \\end{array} ~~\\cdot~~\n \\begin{array}{|c} \\hline\n & 1 & \\\\\n 1 & & 1\n \\end{array} \\\\\n & & (x y^{2} + x + y ) = \\Phi_2 \\left ( \\frac{y}{x} + xy \\right ) x\n\\end{gather*}\n$$\n\nAs noted, the the rightmost polynomial can still be expressed from $\\Phi_2$.\n\nAll powers of *x* in the product are multiples of 3.\nWe can divide these out to produce a similar carry, as we did before.\nDoing so preserves the shape of counting, but destroys the factorization, as the result is irreducible.\n\n::: {layout-ncol=\"2\"}\n$$\n\\begin{array}{|c} \\hline\n & \\textcolor{red}{1} & \\\\\n \\\\\n & \\bar{3} & \\\\\n \\textcolor{green}{1} & & \\textcolor{blue}{1}\n\\end{array} ~~\n\\begin{matrix}\n \\textcolor{red}{\\langle 0,2 \\rangle} \\\\\n \\textcolor{green}{\\langle -1,-1 \\rangle} \\\\\n \\textcolor{blue}{\\langle 1,-1 \\rangle} \\\\\n\\end{matrix} \\\\\n\\frac{| \\langle -1, -1 \\rangle |}{| \\langle 0,2 \\rangle |}\n = \\frac{\\sqrt 2}{2}\n$$\n\n::: {#df9e93aa .cell execution_count=10}\n\n::: {.cell-output .cell-output-display}\n```{=html}\n\n```\n:::\n:::\n\n\n:::\n\nAll of these similar systems is share something in common: the pseudo-base is located at\n the centroid of the triangle formed by the remaining digits.\nThis is most obvious from the fact that the sum of all three vectors equals $\\vec 0$ in all three cases.\nThe \"threshold we exceeded\" when comparing the unrotated system's neighbors was the centroid transitioning\n between being closer to the upper point or the lower two points.\n\nThe position of the centroid is unchanged so long as the lower two points have the same midpoint as above.\nTherefore, all triangular barycentric carries should share this similar pattern.\n\n\nClosing\n-------\n\nCarries intrinsically possess a few invariants.\nFor one, they must apply at any location in an expansion, a form of translational symmetry.\nNo matter if we multiply or divide by *x* or *y*, the polynomial retains its general appearance,\n as well as whether or not it is irreducible.\nThe above method shows that rotational symmetry also exists for polynomials beyond interchanging *x* and *y*.\n\nCarries seem to possess a symmetry which polynomials do not: the ability to contract and expand bases,\n meaning that in some sense, $P(x) \\sim P(x^k)$ for any *k*.\nThis preserves the counting system despite expansions and contractions which pay no regard for reducibility.\nThis is also the reason that systems like base-$\\sqrt 2$ are so uninteresting:\n for integers, it's just spaced out binary.\n\nThree questions that immediately come to mind are:\n\n- Not all integers can be written as the sum of two squares.\n Are there any (reducible) polynomials which have no nontrivial rotation?\n - The [Brahmagupta-Fibonacci](https://en.wikipedia.org/wiki/Brahmagupta%E2%80%93Fibonacci_identity) identity\n implies that such numbers are closed under multiplication.\n This means that it is always possible to reorient the triangle in the method shown above.\n- After compacting the counting system, can reducibility be recovered for other scaling factors\n than the one started with?\n What about from an irrational scaling (as by a rotation)?\n - I am not equipped to answer this.\n- Some geometry is impossible in the 2D square lattice -- for example, it contains no equilateral triangles.\n Equilateral triangles do however exist in the 3D square lattice.\n Are there 2D systems which *must* be embedded in 3D dimensions, or can they always be rotated and reduced?\n - Again, I am not equipped to answer this.\n\nRegardless, it is pleasing that the exponents in polynomials can easily be interpreted as\n the components of vectors.\nThe primary geometrical approach to such objects is to plot the curve or surface containing points which\n (at least approximately) satisfies the equation.\nHere however, basic coordinate geometry exists without needing to define evaluation.\nMoreover, geometry, linear algebra, and polynomial number theory all at once have a role to play in\n the story of these bizarre fractal patterns.\n\n", + "supporting": [ + "index_files" + ], + "filters": [], + "includes": { + "include-in-header": [ + "\n\n\n" + ] + } + } +} \ No newline at end of file diff --git a/_freeze/polycount/cell2/index/figure-html/cell-3-output-1.png b/_freeze/polycount/cell2/index/figure-html/cell-3-output-1.png new file mode 100644 index 0000000..f69d821 Binary files /dev/null and b/_freeze/polycount/cell2/index/figure-html/cell-3-output-1.png differ diff --git a/_freeze/polycount/cell2/index/figure-html/cell-3-output-2.png b/_freeze/polycount/cell2/index/figure-html/cell-3-output-2.png new file mode 100644 index 0000000..461b90b Binary files /dev/null and b/_freeze/polycount/cell2/index/figure-html/cell-3-output-2.png differ diff --git a/_freeze/polycount/cell2/index/figure-html/cell-4-output-2.png b/_freeze/polycount/cell2/index/figure-html/cell-4-output-2.png new file mode 100644 index 0000000..3417064 Binary files /dev/null and b/_freeze/polycount/cell2/index/figure-html/cell-4-output-2.png differ diff --git a/_freeze/polycount/cell2/index/figure-html/cell-5-output-1.png b/_freeze/polycount/cell2/index/figure-html/cell-5-output-1.png new file mode 100644 index 0000000..f69d821 Binary files /dev/null and b/_freeze/polycount/cell2/index/figure-html/cell-5-output-1.png differ diff --git a/_freeze/polycount/cell2/index/figure-html/cell-5-output-2.png b/_freeze/polycount/cell2/index/figure-html/cell-5-output-2.png new file mode 100644 index 0000000..d4050f9 Binary files /dev/null and b/_freeze/polycount/cell2/index/figure-html/cell-5-output-2.png differ diff --git a/_freeze/polycount/cell2/index/figure-html/cell-6-output-2.png b/_freeze/polycount/cell2/index/figure-html/cell-6-output-2.png new file mode 100644 index 0000000..6783a8a Binary files /dev/null and b/_freeze/polycount/cell2/index/figure-html/cell-6-output-2.png differ diff --git a/_freeze/polycount/cell2/index/figure-html/cell-7-output-2.png b/_freeze/polycount/cell2/index/figure-html/cell-7-output-2.png new file mode 100644 index 0000000..fe55493 Binary files /dev/null and b/_freeze/polycount/cell2/index/figure-html/cell-7-output-2.png differ diff --git a/_freeze/polycount/cell2/index/figure-html/cell-8-output-2.png b/_freeze/polycount/cell2/index/figure-html/cell-8-output-2.png new file mode 100644 index 0000000..44079ba Binary files /dev/null and b/_freeze/polycount/cell2/index/figure-html/cell-8-output-2.png differ diff --git a/_freeze/polycount/cell2/index/figure-html/cell-9-output-2.png b/_freeze/polycount/cell2/index/figure-html/cell-9-output-2.png new file mode 100644 index 0000000..0c0c4a2 Binary files /dev/null and b/_freeze/polycount/cell2/index/figure-html/cell-9-output-2.png differ diff --git a/_freeze/site_libs/clipboard/clipboard.min.js b/_freeze/site_libs/clipboard/clipboard.min.js new file mode 100644 index 0000000..1103f81 --- /dev/null +++ b/_freeze/site_libs/clipboard/clipboard.min.js @@ -0,0 +1,7 @@ +/*! + * clipboard.js v2.0.11 + * https://clipboardjs.com/ + * + * Licensed MIT © Zeno Rocha + */ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return n={686:function(t,e,n){"use strict";n.d(e,{default:function(){return b}});var e=n(279),i=n.n(e),e=n(370),u=n.n(e),e=n(817),r=n.n(e);function c(t){try{return document.execCommand(t)}catch(t){return}}var a=function(t){t=r()(t);return c("cut"),t};function o(t,e){var n,o,t=(n=t,o="rtl"===document.documentElement.getAttribute("dir"),(t=document.createElement("textarea")).style.fontSize="12pt",t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px",o=window.pageYOffset||document.documentElement.scrollTop,t.style.top="".concat(o,"px"),t.setAttribute("readonly",""),t.value=n,t);return e.container.appendChild(t),e=r()(t),c("copy"),t.remove(),e}var f=function(t){var e=10?setTimeout((function(){e(r,n,s)}),1):(t.update(),n(s))}}},"./src/filter.js":function(t){t.exports=function(t){return t.handlers.filterStart=t.handlers.filterStart||[],t.handlers.filterComplete=t.handlers.filterComplete||[],function(e){if(t.trigger("filterStart"),t.i=1,t.reset.filter(),void 0===e)t.filtered=!1;else{t.filtered=!0;for(var r=t.items,n=0,s=r.length;nv.page,a=new g(t[s],void 0,n),v.items.push(a),r.push(a)}return v.update(),r}m(t.slice(0),e)}},this.show=function(t,e){return this.i=t,this.page=e,v.update(),v},this.remove=function(t,e,r){for(var n=0,s=0,i=v.items.length;s-1&&r.splice(n,1),v},this.trigger=function(t){for(var e=v.handlers[t].length;e--;)v.handlers[t][e](v);return v},this.reset={filter:function(){for(var t=v.items,e=t.length;e--;)t[e].filtered=!1;return v},search:function(){for(var t=v.items,e=t.length;e--;)t[e].found=!1;return v}},this.update=function(){var t=v.items,e=t.length;v.visibleItems=[],v.matchingItems=[],v.templater.clear();for(var r=0;r=v.i&&v.visibleItems.lengthe},innerWindow:function(t,e,r){return t>=e-r&&t<=e+r},dotted:function(t,e,r,n,s,i,a){return this.dottedLeft(t,e,r,n,s,i)||this.dottedRight(t,e,r,n,s,i,a)},dottedLeft:function(t,e,r,n,s,i){return e==r+1&&!this.innerWindow(e,s,i)&&!this.right(e,n)},dottedRight:function(t,e,r,n,s,i,a){return!t.items[a-1].values().dotted&&(e==n&&!this.innerWindow(e,s,i)&&!this.right(e,n))}};return function(e){var n=new i(t.listContainer.id,{listClass:e.paginationClass||"pagination",item:e.item||"
  • ",valueNames:["page","dotted"],searchClass:"pagination-search-that-is-not-supposed-to-exist",sortClass:"pagination-sort-that-is-not-supposed-to-exist"});s.bind(n.listContainer,"click",(function(e){var r=e.target||e.srcElement,n=t.utils.getAttribute(r,"data-page"),s=t.utils.getAttribute(r,"data-i");s&&t.show((s-1)*n+1,n)})),t.on("updated",(function(){r(n,e)})),r(n,e)}}},"./src/parse.js":function(t,e,r){t.exports=function(t){var e=r("./src/item.js")(t),n=function(r,n){for(var s=0,i=r.length;s0?setTimeout((function(){e(r,s)}),1):(t.update(),t.trigger("parseComplete"))};return t.handlers.parseComplete=t.handlers.parseComplete||[],function(){var e=function(t){for(var e=t.childNodes,r=[],n=0,s=e.length;n]/g.exec(t)){var e=document.createElement("tbody");return e.innerHTML=t,e.firstElementChild}if(-1!==t.indexOf("<")){var r=document.createElement("div");return r.innerHTML=t,r.firstElementChild}}},a=function(e,r,n){var s=void 0,i=function(e){for(var r=0,n=t.valueNames.length;r=1;)t.list.removeChild(t.list.firstChild)},function(){var r;if("function"!=typeof t.item){if(!(r="string"==typeof t.item?-1===t.item.indexOf("<")?document.getElementById(t.item):i(t.item):s()))throw new Error("The list needs to have at least one item on init otherwise you'll have to add a template.");r=n(r,t.valueNames),e=function(){return r.cloneNode(!0)}}else e=function(e){var r=t.item(e);return i(r)}}()};t.exports=function(t){return new e(t)}},"./src/utils/classes.js":function(t,e,r){var n=r("./src/utils/index-of.js"),s=/\s+/;Object.prototype.toString;function i(t){if(!t||!t.nodeType)throw new Error("A DOM element reference is required");this.el=t,this.list=t.classList}t.exports=function(t){return new i(t)},i.prototype.add=function(t){if(this.list)return this.list.add(t),this;var e=this.array();return~n(e,t)||e.push(t),this.el.className=e.join(" "),this},i.prototype.remove=function(t){if(this.list)return this.list.remove(t),this;var e=this.array(),r=n(e,t);return~r&&e.splice(r,1),this.el.className=e.join(" "),this},i.prototype.toggle=function(t,e){return this.list?(void 0!==e?e!==this.list.toggle(t,e)&&this.list.toggle(t):this.list.toggle(t),this):(void 0!==e?e?this.add(t):this.remove(t):this.has(t)?this.remove(t):this.add(t),this)},i.prototype.array=function(){var t=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(s);return""===t[0]&&t.shift(),t},i.prototype.has=i.prototype.contains=function(t){return this.list?this.list.contains(t):!!~n(this.array(),t)}},"./src/utils/events.js":function(t,e,r){var n=window.addEventListener?"addEventListener":"attachEvent",s=window.removeEventListener?"removeEventListener":"detachEvent",i="addEventListener"!==n?"on":"",a=r("./src/utils/to-array.js");e.bind=function(t,e,r,s){for(var o=0,l=(t=a(t)).length;o32)return!1;var a=n,o=function(){var t,r={};for(t=0;t=p;b--){var j=o[t.charAt(b-1)];if(C[b]=0===m?(C[b+1]<<1|1)&j:(C[b+1]<<1|1)&j|(v[b+1]|v[b])<<1|1|v[b+1],C[b]&d){var x=l(m,b-1);if(x<=u){if(u=x,!((c=b-1)>a))break;p=Math.max(1,2*a-c)}}}if(l(m+1,a)>u)break;v=C}return!(c<0)}},"./src/utils/get-attribute.js":function(t){t.exports=function(t,e){var r=t.getAttribute&&t.getAttribute(e)||null;if(!r)for(var n=t.attributes,s=n.length,i=0;i=48&&t<=57}function i(t,e){for(var i=(t+="").length,a=(e+="").length,o=0,l=0;o=i&&l=a?-1:l>=a&&o=i?1:i-a}i.caseInsensitive=i.i=function(t,e){return i((""+t).toLowerCase(),(""+e).toLowerCase())},Object.defineProperties(i,{alphabet:{get:function(){return e},set:function(t){r=[];var s=0;if(e=t)for(;s { + // category is URI encoded in EJS template for UTF-8 support + category = decodeURIComponent(atob(category)); + if (categoriesLoaded) { + activateCategory(category); + setCategoryHash(category); + } +}; + +window["quarto-listing-loaded"] = () => { + // Process any existing hash + const hash = getHash(); + + if (hash) { + // If there is a category, switch to that + if (hash.category) { + // category hash are URI encoded so we need to decode it before processing + // so that we can match it with the category element processed in JS + activateCategory(decodeURIComponent(hash.category)); + } + // Paginate a specific listing + const listingIds = Object.keys(window["quarto-listings"]); + for (const listingId of listingIds) { + const page = hash[getListingPageKey(listingId)]; + if (page) { + showPage(listingId, page); + } + } + } + + const listingIds = Object.keys(window["quarto-listings"]); + for (const listingId of listingIds) { + // The actual list + const list = window["quarto-listings"][listingId]; + + // Update the handlers for pagination events + refreshPaginationHandlers(listingId); + + // Render any visible items that need it + renderVisibleProgressiveImages(list); + + // Whenever the list is updated, we also need to + // attach handlers to the new pagination elements + // and refresh any newly visible items. + list.on("updated", function () { + renderVisibleProgressiveImages(list); + setTimeout(() => refreshPaginationHandlers(listingId)); + + // Show or hide the no matching message + toggleNoMatchingMessage(list); + }); + } +}; + +window.document.addEventListener("DOMContentLoaded", function (_event) { + // Attach click handlers to categories + const categoryEls = window.document.querySelectorAll( + ".quarto-listing-category .category" + ); + + for (const categoryEl of categoryEls) { + // category needs to support non ASCII characters + const category = decodeURIComponent( + atob(categoryEl.getAttribute("data-category")) + ); + categoryEl.onclick = () => { + activateCategory(category); + setCategoryHash(category); + }; + } + + // Attach a click handler to the category title + // (there should be only one, but since it is a class name, handle N) + const categoryTitleEls = window.document.querySelectorAll( + ".quarto-listing-category-title" + ); + for (const categoryTitleEl of categoryTitleEls) { + categoryTitleEl.onclick = () => { + activateCategory(""); + setCategoryHash(""); + }; + } + + categoriesLoaded = true; +}); + +function toggleNoMatchingMessage(list) { + const selector = `#${list.listContainer.id} .listing-no-matching`; + const noMatchingEl = window.document.querySelector(selector); + if (noMatchingEl) { + if (list.visibleItems.length === 0) { + noMatchingEl.classList.remove("d-none"); + } else { + if (!noMatchingEl.classList.contains("d-none")) { + noMatchingEl.classList.add("d-none"); + } + } + } +} + +function setCategoryHash(category) { + setHash({ category }); +} + +function setPageHash(listingId, page) { + const currentHash = getHash() || {}; + currentHash[getListingPageKey(listingId)] = page; + setHash(currentHash); +} + +function getListingPageKey(listingId) { + return `${listingId}-page`; +} + +function refreshPaginationHandlers(listingId) { + const listingEl = window.document.getElementById(listingId); + const paginationEls = listingEl.querySelectorAll( + ".pagination li.page-item:not(.disabled) .page.page-link" + ); + for (const paginationEl of paginationEls) { + paginationEl.onclick = (sender) => { + setPageHash(listingId, sender.target.getAttribute("data-i")); + showPage(listingId, sender.target.getAttribute("data-i")); + return false; + }; + } +} + +function renderVisibleProgressiveImages(list) { + // Run through the visible items and render any progressive images + for (const item of list.visibleItems) { + const itemEl = item.elm; + if (itemEl) { + const progressiveImgs = itemEl.querySelectorAll( + `img[${kProgressiveAttr}]` + ); + for (const progressiveImg of progressiveImgs) { + const srcValue = progressiveImg.getAttribute(kProgressiveAttr); + if (srcValue) { + progressiveImg.setAttribute("src", srcValue); + } + progressiveImg.removeAttribute(kProgressiveAttr); + } + } + } +} + +function getHash() { + // Hashes are of the form + // #name:value|name1:value1|name2:value2 + const currentUrl = new URL(window.location); + const hashRaw = currentUrl.hash ? currentUrl.hash.slice(1) : undefined; + return parseHash(hashRaw); +} + +const kAnd = "&"; +const kEquals = "="; + +function parseHash(hash) { + if (!hash) { + return undefined; + } + const hasValuesStrs = hash.split(kAnd); + const hashValues = hasValuesStrs + .map((hashValueStr) => { + const vals = hashValueStr.split(kEquals); + if (vals.length === 2) { + return { name: vals[0], value: vals[1] }; + } else { + return undefined; + } + }) + .filter((value) => { + return value !== undefined; + }); + + const hashObj = {}; + hashValues.forEach((hashValue) => { + hashObj[hashValue.name] = decodeURIComponent(hashValue.value); + }); + return hashObj; +} + +function makeHash(obj) { + return Object.keys(obj) + .map((key) => { + return `${key}${kEquals}${obj[key]}`; + }) + .join(kAnd); +} + +function setHash(obj) { + const hash = makeHash(obj); + window.history.pushState(null, null, `#${hash}`); +} + +function showPage(listingId, page) { + const list = window["quarto-listings"][listingId]; + if (list) { + list.show((page - 1) * list.page + 1, list.page); + } +} + +function activateCategory(category) { + // Deactivate existing categories + const activeEls = window.document.querySelectorAll( + ".quarto-listing-category .category.active" + ); + for (const activeEl of activeEls) { + activeEl.classList.remove("active"); + } + + // Activate this category + const categoryEl = window.document.querySelector( + `.quarto-listing-category .category[data-category='${btoa( + encodeURIComponent(category) + )}']` + ); + if (categoryEl) { + categoryEl.classList.add("active"); + } + + // Filter the listings to this category + filterListingCategory(category); +} + +function filterListingCategory(category) { + const listingIds = Object.keys(window["quarto-listings"]); + for (const listingId of listingIds) { + const list = window["quarto-listings"][listingId]; + if (list) { + if (category === "") { + // resets the filter + list.filter(); + } else { + // filter to this category + list.filter(function (item) { + const itemValues = item.values(); + if (itemValues.categories !== null) { + const categories = decodeURIComponent( + atob(itemValues.categories) + ).split(","); + return categories.includes(category); + } else { + return false; + } + }); + } + } + } +} diff --git a/_quarto.yml b/_quarto.yml new file mode 100644 index 0000000..21423c0 --- /dev/null +++ b/_quarto.yml @@ -0,0 +1,24 @@ +project: + type: website + +website: + title: "Zenzicubi.co" + navbar: + right: + # - about.qmd + - icon: github + href: https://github.com/queue-miscreant + background: primary + search: true + draft-mode: unlinked + +format: + html: + theme: + light: + - default + dark: + - darkly + +execute: + cache: true diff --git a/index.qmd b/index.qmd new file mode 100644 index 0000000..c3f57a1 --- /dev/null +++ b/index.qmd @@ -0,0 +1,6 @@ +--- +title: "Categories" +listing: + contents: polycount/index.* + sort: "date desc" +--- diff --git a/polycount/5/canonical_tables/canonical_addition.gif b/polycount/5/canonical_tables/canonical_addition.gif new file mode 100644 index 0000000..8c47bf8 Binary files /dev/null and b/polycount/5/canonical_tables/canonical_addition.gif differ diff --git a/polycount/5/canonical_tables/canonical_multiplication.gif b/polycount/5/canonical_tables/canonical_multiplication.gif new file mode 100644 index 0000000..58a1365 Binary files /dev/null and b/polycount/5/canonical_tables/canonical_multiplication.gif differ diff --git a/polycount/5/series_tables/catalan_oplus_mod_2.png b/polycount/5/series_tables/catalan_oplus_mod_2.png new file mode 100644 index 0000000..f981fa1 Binary files /dev/null and b/polycount/5/series_tables/catalan_oplus_mod_2.png differ diff --git a/polycount/5/series_tables/factorial_oplus_mod_8.png b/polycount/5/series_tables/factorial_oplus_mod_8.png new file mode 100644 index 0000000..f380c30 Binary files /dev/null and b/polycount/5/series_tables/factorial_oplus_mod_8.png differ diff --git a/polycount/5/series_tables/fibonacci_odot.gif b/polycount/5/series_tables/fibonacci_odot.gif new file mode 100644 index 0000000..7e4fc64 Binary files /dev/null and b/polycount/5/series_tables/fibonacci_odot.gif differ diff --git a/polycount/5/series_tables/fibonacci_oplus.gif b/polycount/5/series_tables/fibonacci_oplus.gif new file mode 100644 index 0000000..276bcd1 Binary files /dev/null and b/polycount/5/series_tables/fibonacci_oplus.gif differ diff --git a/polycount/5/series_tables/jacobsthal_oplus.gif b/polycount/5/series_tables/jacobsthal_oplus.gif new file mode 100644 index 0000000..bb942df Binary files /dev/null and b/polycount/5/series_tables/jacobsthal_oplus.gif differ diff --git a/polycount/5/series_tables/padovan_oplus.gif b/polycount/5/series_tables/padovan_oplus.gif new file mode 100644 index 0000000..8fe3d6d Binary files /dev/null and b/polycount/5/series_tables/padovan_oplus.gif differ diff --git a/polycount/5/series_tables/pell_oplus.gif b/polycount/5/series_tables/pell_oplus.gif new file mode 100644 index 0000000..45d7386 Binary files /dev/null and b/polycount/5/series_tables/pell_oplus.gif differ diff --git a/polycount/5/series_tables/recurrence_1_1_2_oplus.gif b/polycount/5/series_tables/recurrence_1_1_2_oplus.gif new file mode 100644 index 0000000..397349b Binary files /dev/null and b/polycount/5/series_tables/recurrence_1_1_2_oplus.gif differ diff --git a/polycount/5/series_tables/square_oplus.gif b/polycount/5/series_tables/square_oplus.gif new file mode 100644 index 0000000..23d8451 Binary files /dev/null and b/polycount/5/series_tables/square_oplus.gif differ diff --git a/polycount/5/series_tables/tetranacci_oplus.gif b/polycount/5/series_tables/tetranacci_oplus.gif new file mode 100644 index 0000000..f26bfcd Binary files /dev/null and b/polycount/5/series_tables/tetranacci_oplus.gif differ diff --git a/polycount/5/series_tables/triangular_oplus.gif b/polycount/5/series_tables/triangular_oplus.gif new file mode 100644 index 0000000..c1576f0 Binary files /dev/null and b/polycount/5/series_tables/triangular_oplus.gif differ diff --git a/polycount/5/series_tables/tribonacci_oplus.gif b/polycount/5/series_tables/tribonacci_oplus.gif new file mode 100644 index 0000000..d39ba9b Binary files /dev/null and b/polycount/5/series_tables/tribonacci_oplus.gif differ diff --git a/polycount/_metadata.yml b/polycount/_metadata.yml new file mode 100644 index 0000000..0512054 --- /dev/null +++ b/polycount/_metadata.yml @@ -0,0 +1,5 @@ +# freeze computational output +freeze: true + +# Enable banner style title blocks +title-block-banner: true diff --git a/polycount/index.qmd b/polycount/index.qmd new file mode 100644 index 0000000..c9fdf1e --- /dev/null +++ b/polycount/index.qmd @@ -0,0 +1,10 @@ +--- +title: "Polynomial Counting" +listing: + contents: . + sort: "date desc" +--- + +Articles about generalizations of positional number systems, explained using the concept of counting on polynomials. + +Publication dates correspond to the original WordPress publication dates.