From ed3c8a331c1fa28e51676c976afc0c02fa804098 Mon Sep 17 00:00:00 2001 From: queue-miscreant Date: Thu, 6 Mar 2025 01:44:14 -0600 Subject: [PATCH] fix typos in 4.appendix --- .../4/appendix/index/execute-results/html.json | 4 ++-- posts/polycount/4/appendix/index.qmd | 18 +++++++++--------- .../polycount/4/appendix/showAdicWithKappa.ojs | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/_freeze/posts/polycount/4/appendix/index/execute-results/html.json b/_freeze/posts/polycount/4/appendix/index/execute-results/html.json index aada927..8420d57 100644 --- a/_freeze/posts/polycount/4/appendix/index/execute-results/html.json +++ b/_freeze/posts/polycount/4/appendix/index/execute-results/html.json @@ -1,8 +1,8 @@ { - "hash": "5f66bbee17534185099afe8ee7108433", + "hash": "aa6be74cf2b25008676feea358e2a9ba", "result": { "engine": "jupyter", - "markdown": "---\ntitle: \"Polynomial Counting 4, Addendum\"\ndescription: |\n Additional notes on irrational -adic expansions, including complex embeddings thereof.\nformat:\n html:\n html-math-method: katex\ndate: \"2025-03-03\"\ncategories:\n - algebra\n - haskell\n - interactive\n---\n\n\n\nAfter converting my original [Two 2's post](../), I grew pleased with making its diagrams\n and content more reproducible.\nHowever, I noticed some things which required further examination.\n\nFirst, let's write out a double-width carry function more concretely in Haskell.\n\n::: {#6043b2f0 .cell execution_count=2}\n``` {.haskell .cell-code}\n-- Widened carry of a particular repeated amount\n-- i.e., for carry2 2, the carry is 22 = 100\ncarry2 b = carry2' []\n where carry2' zs (x:y:z:xs)\n | q == 0 = carry2' (x:zs) (y:z:xs) -- try carrying at a higher place value\n | otherwise = foldl (flip (:)) ys zs -- carry here\n where ys = r : y-x+r : z+q : xs\n (q, r) = x `quotRem` b\n```\n:::\n\n\nIn the parent post, it was discussed that the integer four has a non-repeating expansion\n when expressed as an *κ*-adic integer.\nLet's put this to the test by writing out each step for producing expansions of two and four.\nWe'll also test these expansions by evaluating them at an approximation of $\\kappa = \\sqrt 3 + 1$.\nWe should roughly get two and four at each step.\n\n::: {#61215a8d .cell layout-ncol='2' execution_count=3}\n``` {.haskell .cell-code code-fold=\"true\"}\n-- Directly expand the integer `n`, using the `carry` showing each step for `count` steps\nexpandSteps count carry n = take count $ iterate carry $ n:replicate count 0\n\n-- Horner evaluation on polynomials of ascending powers\nhornerEval x = foldr (\\c a -> a * x + c) 0\n-- Pair a polynomial with its evaluation at x\npairEval x = (,) <*> hornerEval x . map fromIntegral\n\nadicTwoSteps = map (pairEval (sqrt 3 + 1)) $ expandSteps 10 (carry2 2) 2\nadicFourSteps = map (pairEval (sqrt 3 + 1)) $ expandSteps 10 (carry2 2) 4\n\nmarkdown \"Iteratively carrying \\\"2\\\"\"\nmarkdown \"Iteratively carrying \\\"4\\\"\"\n\nputStrLn . unlines . map show $ adicTwoSteps\nputStrLn . unlines . map show $ adicFourSteps\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\nIteratively carrying \"2\"\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\nIteratively carrying \"4\"\n:::\n\n::: {.cell-output .cell-output-display}\n```\n([2,0,0,0,0,0,0,0,0,0,0],2.0)\n([0,-2,1,0,0,0,0,0,0,0,0],1.9999999999999996)\n([0,0,3,-1,0,0,0,0,0,0,0],2.0000000000000004)\n([0,0,1,-3,1,0,0,0,0,0,0],1.9999999999999982)\n([0,0,1,-1,3,-1,0,0,0,0,0],2.000000000000005)\n([0,0,1,-1,1,-3,1,0,0,0,0],1.9999999999999867)\n([0,0,1,-1,1,-1,3,-1,0,0,0],2.0000000000000364)\n([0,0,1,-1,1,-1,1,-3,1,0,0],1.9999999999999005)\n([0,0,1,-1,1,-1,1,-1,3,-1,0],2.000000000000272)\n([0,0,1,-1,1,-1,1,-1,1,-3,1],1.999999999999257)\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```\n([4,0,0,0,0,0,0,0,0,0,0],4.0)\n([0,-4,2,0,0,0,0,0,0,0,0],3.999999999999999)\n([0,0,6,-2,0,0,0,0,0,0,0],4.000000000000001)\n([0,0,0,-8,3,0,0,0,0,0,0],4.000000000000003)\n([0,0,0,0,11,-4,0,0,0,0,0],4.000000000000021)\n([0,0,0,0,1,-14,5,0,0,0,0],3.9999999999998543)\n([0,0,0,0,1,0,19,-7,0,0,0],4.000000000000845)\n([0,0,0,0,1,0,1,-25,9,0,0],4.000000000000486)\n([0,0,0,0,1,0,1,-1,33,-12,0],3.9999999999982596)\n([0,0,0,0,1,0,1,-1,1,-44,16],3.999999999986544)\n```\n:::\n:::\n\n\nNote that when an list is displayed in this post, it should be interpreted as an expansion\n in increasing powers.\n\n\nExpansions of *κ*-adics\n-----------------------\n\nIn the original post, we ignored expansions other than the chaotic expansions of four.\nConsider that we can use *two different* expansions for three, since we are using a balanced alphabet:\n\n::: {#342e241c .cell layout-ncol='2' execution_count=4}\n``` {.haskell .cell-code code-fold=\"true\"}\nmarkdown \"Increment two:\"\nmarkdown \"Decrement three:\"\n\nadicThree = (1:) $ tail $ fst $ last adicTwoSteps\nprint adicThree\n\nadicThree' = ((-1):) $ tail $ fst $ last adicFourSteps\nprint adicThree'\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\nIncrement two:\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\nDecrement three:\n:::\n\n::: {.cell-output .cell-output-display}\n```\n[1,0,1,-1,1,-1,1,-1,1,-3,1]\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```\n[-1,0,0,0,1,0,1,-1,1,-44,16]\n```\n:::\n:::\n\n\nFor convenience (and correctness), we'll retain the carry heads rather than truncating them.\n\nHow can we be sure that both of these are expansions of three?\nEasy. Just negate every term of one of them, then add them together to see if they cancel.\n\n::: {#777b162e .cell execution_count=5}\n``` {.haskell .cell-code}\nmaybeZero = take 10 $ iterate (carry2 2) $ zipWith (+) adicThree (map negate adicThree')\nputStrLn . unlines . map show $ maybeZero\n```\n\n::: {.cell-output .cell-output-display}\n```\n[2,0,1,-1,0,-1,0,0,0,41,-15]\n[0,-2,2,-1,0,-1,0,0,0,41,-15]\n[0,0,4,-2,0,-1,0,0,0,41,-15]\n[0,0,0,-6,2,-1,0,0,0,41,-15]\n[0,0,0,0,8,-4,0,0,0,41,-15]\n[0,0,0,0,0,-12,4,0,0,41,-15]\n[0,0,0,0,0,0,16,-6,0,41,-15]\n[0,0,0,0,0,0,0,-22,8,41,-15]\n[0,0,0,0,0,0,0,0,30,30,-15]\n[0,0,0,0,0,0,0,0,0,0,0]\n```\n:::\n:::\n\n\nAs you can see, eventually we completely clear the number and just get list of zeros.\n\nWhich of these expansions is more valid?\nI would argue that we should prefer expansions obtained by incrementing, since the natural numbers\n are built in the same way.\nThis is flimsy, though. By doing this, negative one will never appear in the one's place.\n\nIt's also worth pointing out that we only have this choice at odd numbers.\nAt even numbers, the one's place is always zero.\nIt's easy to see why this is the case -- if there's a \"2\" in the one's place, it can be carried,\n just like in binary.\n\n\nBalanced vs. Binary *κ*-adics\n-----------------------------\n\nA more unusual consequence of the carry is that despite the initial choice of alphabet,\n [negative numerals can be cleared](../#all-positive)\n from the expansion by using an extra-greedy borrow.\n\nThere is only one significant difference in how the two are implemented:\n the choice of integer division function.\nIn Haskell, there exists both `quotRem` and `divMod`, with the two disagreeing on negative remainders.\n\n::: {#369099de .cell layout-ncol='2' execution_count=6}\n``` {.haskell .cell-code code-fold=\"true\"}\nmarkdown \"`quotRem`\"\nmarkdown \"`divMod`\"\n\nprint $ quotRem (-27) 5\nprint $ divMod (-27) 5\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n`quotRem`\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n`divMod`\n:::\n\n::: {.cell-output .cell-output-display}\n```\n(-5,-2)\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```\n(-6,3)\n```\n:::\n:::\n\n\nWe can factor our choice out of our two digit-wide carry function by passing it as an argument:\n\n::: {#c93283a5 .cell execution_count=7}\n``` {.haskell .cell-code}\ncarry2QR qr b = carry2QR' []\n where carry2QR' zs (x:y:z:xs)\n | q == 0 = carry2QR' (x:zs) (y:z:xs) -- try carrying at a higher place value\n | otherwise = foldl (flip (:)) ys zs -- carry here\n where ys = r : y-x+r : z+q : xs\n (q, r) = x `qr` b\n```\n:::\n\n\nNow, let's compare the iterates of the two options by applying them to \"4\":\n\n::: {#50e75b41 .cell layout-ncol='2' execution_count=8}\n``` {.haskell .cell-code code-fold=\"true\"}\ncendree4QuotRem10Steps = map (pairEval (sqrt 3 + 1)) $ expandSteps 10 (carry2QR quotRem 2) 4\ncendree4DivMod10Steps = map (pairEval (sqrt 3 + 1)) $ expandSteps 10 (carry2QR divMod 2) 4\n\nmarkdown \"`quotRem`\"\nmarkdown \"`divMod`\"\n\nputStrLn . unlines . map show $ cendree4QuotRem10Steps\nputStrLn . unlines . map show $ cendree4DivMod10Steps\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n`quotRem`\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n`divMod`\n:::\n\n::: {.cell-output .cell-output-display}\n```\n([4,0,0,0,0,0,0,0,0,0,0],4.0)\n([0,-4,2,0,0,0,0,0,0,0,0],3.999999999999999)\n([0,0,6,-2,0,0,0,0,0,0,0],4.000000000000001)\n([0,0,0,-8,3,0,0,0,0,0,0],4.000000000000003)\n([0,0,0,0,11,-4,0,0,0,0,0],4.000000000000021)\n([0,0,0,0,1,-14,5,0,0,0,0],3.9999999999998543)\n([0,0,0,0,1,0,19,-7,0,0,0],4.000000000000845)\n([0,0,0,0,1,0,1,-25,9,0,0],4.000000000000486)\n([0,0,0,0,1,0,1,-1,33,-12,0],3.9999999999982596)\n([0,0,0,0,1,0,1,-1,1,-44,16],3.999999999986544)\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```\n([4,0,0,0,0,0,0,0,0,0,0],4.0)\n([0,-4,2,0,0,0,0,0,0,0,0],3.999999999999999)\n([0,0,6,-2,0,0,0,0,0,0,0],4.000000000000001)\n([0,0,0,-8,3,0,0,0,0,0,0],4.000000000000003)\n([0,0,0,0,11,-4,0,0,0,0,0],4.000000000000021)\n([0,0,0,0,1,-14,5,0,0,0,0],3.9999999999998543)\n([0,0,0,0,1,0,19,-7,0,0,0],4.000000000000845)\n([0,0,0,0,1,0,1,-25,9,0,0],4.000000000000486)\n([0,0,0,0,1,0,1,1,35,-13,0],4.000000000005557)\n([0,0,0,0,1,0,1,1,1,-47,17],3.9999999999669607)\n```\n:::\n:::\n\n\nFortunately, regardless of which function we pick, the evaluation roughly gives four at each step.\nNote that since `quotRem` allows negative remainders, implementing the carry with it causes\n negative numbers to show up in our expansions.\nConversely, negative numbers *cannot* show up if we use `divMod`.\n\n\n### Chaos before Four\n\nRecall again the series for two in the *κ*-adics:\n\n$$\n2 = ...1\\bar{1}1\\bar{1}1\\bar{1}100_{\\kappa}\n$$\n\nSince the `divMod` implementation clears negative numbers from expansions, we can try using it on this series.\nThe result is another chaotic series:\n\n::: {#d9f2437c .cell execution_count=9}\n``` {.haskell .cell-code}\ncendree2DivModCycleExpansion = take 11 $\n iterate (carry2QR divMod 2) $ take 15 $ 0:0:cycle [1,-1]\nputStrLn . unlines . map show $ cendree2DivModCycleExpansion\n```\n\n::: {.cell-output .cell-output-display}\n```\n[0,0,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1]\n[0,0,1,1,3,-2,1,-1,1,-1,1,-1,1,-1,1]\n[0,0,1,1,1,-4,2,-1,1,-1,1,-1,1,-1,1]\n[0,0,1,1,1,0,6,-3,1,-1,1,-1,1,-1,1]\n[0,0,1,1,1,0,0,-9,4,-1,1,-1,1,-1,1]\n[0,0,1,1,1,0,0,1,14,-6,1,-1,1,-1,1]\n[0,0,1,1,1,0,0,1,0,-20,8,-1,1,-1,1]\n[0,0,1,1,1,0,0,1,0,0,28,-11,1,-1,1]\n[0,0,1,1,1,0,0,1,0,0,0,-39,15,-1,1]\n[0,0,1,1,1,0,0,1,0,0,0,1,55,-21,1]\n[0,0,1,1,1,0,0,1,0,0,0,1,1,-75,28]\n```\n:::\n:::\n\n\nNote that in this case, we're truncating the alternating series!\nThis means that naively evaluating the series as before will not give the correct value.\n\nTo check the validity of this series, we can check that we get the same series before the truncated elements\n by expanding 2 directly:\n\n::: {#87820447 .cell execution_count=10}\n``` {.haskell .cell-code}\ncendree2DivMod15Steps = map (pairEval (sqrt 3 + 1)) $\n expandSteps 15 (carry2QR divMod 2) 2\nputStrLn . unlines . map show $ cendree2DivMod15Steps\n```\n\n::: {.cell-output .cell-output-display}\n```\n([2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],2.0)\n([0,-2,1,0,0,0,0,0,0,0,0,0,0,0,0,0],1.9999999999999996)\n([0,0,3,-1,0,0,0,0,0,0,0,0,0,0,0,0],2.0000000000000004)\n([0,0,1,-3,1,0,0,0,0,0,0,0,0,0,0,0],1.9999999999999982)\n([0,0,1,1,5,-2,0,0,0,0,0,0,0,0,0,0],2.0000000000000115)\n([0,0,1,1,1,-6,2,0,0,0,0,0,0,0,0,0],1.9999999999999758)\n([0,0,1,1,1,0,8,-3,0,0,0,0,0,0,0,0],1.9999999999999394)\n([0,0,1,1,1,0,0,-11,4,0,0,0,0,0,0,0],1.9999999999995541)\n([0,0,1,1,1,0,0,1,16,-6,0,0,0,0,0,0],1.999999999999047)\n([0,0,1,1,1,0,0,1,0,-22,8,0,0,0,0,0],1.999999999993247)\n([0,0,1,1,1,0,0,1,0,0,30,-11,0,0,0,0],2.000000000015452)\n([0,0,1,1,1,0,0,1,0,0,0,-41,15,0,0,0],2.0000000000454636)\n([0,0,1,1,1,0,0,1,0,0,0,1,57,-21,0,0],1.9999999998345677)\n([0,0,1,1,1,0,0,1,0,0,0,1,1,-77,28,0],1.9999999961807242)\n([0,0,1,1,1,0,0,1,0,0,0,1,1,1,106,-39],1.999999997642363)\n```\n:::\n:::\n\n\nUp to the carry head, the series are the same.\nWe can do the same thing to get a series for negative one, a number which has a terminating expansion\n in the balanced alphabet.\n\n::: {#38586303 .cell execution_count=11}\n``` {.haskell .cell-code}\ncendreeNeg1DivMod15Steps = map (pairEval (sqrt 3 + 1)) $\n expandSteps 15 (carry2QR divMod 2) (-1)\nputStrLn . unlines . map show $ cendreeNeg1DivMod15Steps\n```\n\n::: {.cell-output .cell-output-display}\n```\n([-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],-1.0)\n([1,2,-1,0,0,0,0,0,0,0,0,0,0,0,0,0],-0.9999999999999996)\n([1,0,-3,1,0,0,0,0,0,0,0,0,0,0,0,0],-1.0000000000000004)\n([1,0,1,5,-2,0,0,0,0,0,0,0,0,0,0,0],-0.9999999999999958)\n([1,0,1,1,-6,2,0,0,0,0,0,0,0,0,0,0],-1.0000000000000089)\n([1,0,1,1,0,8,-3,0,0,0,0,0,0,0,0,0],-1.0000000000000222)\n([1,0,1,1,0,0,-11,4,0,0,0,0,0,0,0,0],-1.000000000000163)\n([1,0,1,1,0,0,1,16,-6,0,0,0,0,0,0,0],-1.0000000000003486)\n([1,0,1,1,0,0,1,0,-22,8,0,0,0,0,0,0],-1.0000000000024718)\n([1,0,1,1,0,0,1,0,0,30,-11,0,0,0,0,0],-0.9999999999943441)\n([1,0,1,1,0,0,1,0,0,0,-41,15,0,0,0,0],-0.9999999999833591)\n([1,0,1,1,0,0,1,0,0,0,1,57,-21,0,0,0],-1.0000000000605525)\n([1,0,1,1,0,0,1,0,0,0,1,1,-77,28,0,0],-1.000000001397952)\n([1,0,1,1,0,0,1,0,0,0,1,1,1,106,-39,0],-1.000000000862955)\n([1,0,1,1,0,0,1,0,0,0,1,1,1,0,-145,53],-1.0000000211727116)\n```\n:::\n:::\n\n\nThe most natural property of negative one should be that if we add one to it, we get zero.\nIf we take the last iterate of this, increment the zeroth place value, and apply the carry,\n we find that everything clears properly.\n\n::: {#94e3bbca .cell execution_count=12}\n``` {.haskell .cell-code}\ncendree0FromNeg1DivMod = (\\(x:xs) -> (x + 1):xs) $ fst $ last cendreeNeg1DivMod15Steps\ncendree0IncrementSteps = map (pairEval (sqrt 3 + 1)) $ take 15 $\n iterate (carry2QR divMod 2) cendree0FromNeg1DivMod\n\nputStrLn . unlines . map show $ cendree0IncrementSteps\n```\n\n::: {.cell-output .cell-output-display}\n```\n([2,0,1,1,0,0,1,0,0,0,1,1,1,0,-145,53],-2.117271158397216e-8)\n([0,-2,2,1,0,0,1,0,0,0,1,1,1,0,-145,53],-2.117271183049399e-8)\n([0,0,4,0,0,0,1,0,0,0,1,1,1,0,-145,53],-2.1172712567825478e-8)\n([0,0,0,-4,2,0,1,0,0,0,1,1,1,0,-145,53],-2.1172716608068815e-8)\n([0,0,0,0,6,-2,1,0,0,0,1,1,1,0,-145,53],-2.11727015296754e-8)\n([0,0,0,0,0,-8,4,0,0,0,1,1,1,0,-145,53],-2.117275780300572e-8)\n([0,0,0,0,0,0,12,-4,0,0,1,1,1,0,-145,53],-2.1172363115313245e-8)\n([0,0,0,0,0,0,0,-16,6,0,1,1,1,0,-145,53],-2.1172322503707736e-8)\n([0,0,0,0,0,0,0,0,22,-8,1,1,1,0,-145,53],-2.1172474068282878e-8)\n([0,0,0,0,0,0,0,0,0,-30,12,1,1,0,-145,53],-2.1179440228212383e-8)\n([0,0,0,0,0,0,0,0,0,0,42,-14,1,0,-145,53],-2.1235751278905916e-8)\n([0,0,0,0,0,0,0,0,0,0,0,-56,22,0,-145,53],-2.1138031916672377e-8)\n([0,0,0,0,0,0,0,0,0,0,0,0,78,-28,-145,53],-1.9659634780718795e-8)\n([0,0,0,0,0,0,0,0,0,0,0,0,0,-106,-106,53],-2.0141670404689492e-8)\n([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],0.0)\n```\n:::\n:::\n\n\nNaturally, it should be possible to use the the expansions of negative one and two in tandem on any\n series in the balanced alphabet to convert it to the binary alphabet.\nActually demonstrating this and proving it is left as an exercise.\n\n\nAre these really -adic?\n-----------------------\n\nPerhaps it is still unconvincing that expanding the integers in this way gives something\n indeed related to *p*-adics.\nIn fact, since the expansions are in binary or (balanced) ternary, the integers should just\n be a subset of the 2-adics or 3-adics.\n\nStill, wanted to see what these numbers actually \"look\" like, so I whipped up an interactive diagram.\nYou should definitely see [this page](/interactive/adic/) for more information, but\n the gist is that *p*-adics can be sent into the complex plane in a fractal-like way.\n\n\n```{ojs}\n// | echo: false\n\n/*\nFileAttachments:\n ./cendree_DivMod_count_1024_256_digits.csv: ./cendree_DivMod_count_1024_256_digits.csv\n ./cendree_QuotRem_count_1024_256_digits.csv: ./cendree_QuotRem_count_1024_256_digits.csv\n*/\n\n// Import expansions from file.\n// Odd numbers are injected by replacing the first entry of each row with \"1\"\nasIntegers = (x) => {\n let xs = x.split(\"\\n\").map((y) => y.split(\",\").map((z) => +z))\n return [...xs, ...(xs.map((ys) => ys.with(0, 1)))]\n};\n\nadicExpansionsDivMod = FileAttachment(\n \"./cendree_DivMod_count_1024_256_digits.csv\"\n).text().then(asIntegers);\nadicExpansionsQuotRem = FileAttachment(\n \"./cendree_QuotRem_count_1024_256_digits.csv\"\n).text().then(asIntegers);\n\nimport { expansions as oldExpansions } with { base as base } from \"../../../../interactive/p-adics/showAdic.ojs\";\n\nexpansionsOrAdics = baseSelector == \"b-adic\"\n ? oldExpansions\n : baseSelector == \"κ-adic, balanced\"\n ? adicExpansionsDivMod\n : baseSelector == \"κ-adic, binary\"\n ? adicExpansionsQuotRem\n : d3.range(adicExpansionsQuotRem.length / 10).map(() => d3.range(15).map(() => +(Math.random() > 0.5)))\n\nimport { plot } with {\n expansionsOrAdics as expansions,\n embedBase as embedBase,\n geometric as geometric,\n} from \"../../../../interactive/p-adics/showAdic.ojs\";\n\nviewof baseSelector = Inputs.radio([\n \"b-adic\",\n \"κ-adic, balanced\",\n \"κ-adic, binary\",\n \"Random Binary\",\n], {\n value: \"b-adic\",\n label: \"Expansions\",\n});\n\nviewof base = Inputs.range([2, 5], {\n value: 2,\n step: 1,\n label: \"Base of expansions (b)\",\n disabled: baseSelector != \"b-adic\",\n});\n\nviewof embedBase = Inputs.range([2, 5], {\n value: 2,\n step: 0.1,\n label: \"Embedding base (p)\",\n});\n\nviewof geometric = Inputs.range([0.005, 0.995], {\n value: 0.9,\n step: 0.005,\n label: \"Geometric ratio (c)\",\n});\n\nplot\n\n```\n\nFirst, notice that with $b = 2$ and $p = 2$, switching between the \"b-adic\" option\n and the \"*κ*-adic\" option appears cause some points to appear and disappear.\nIt is easiest to see this when $c \\approx 0.5$.\nThis corresponds with the intuition that these are subsets of the 2- and 3-adics.\n\nNext, notice that when plotting the *κ*-adics, there is some self-similarity different\n from the 2- and 3-adics.\nTo see this, try setting $c \\approx 0.75$.\nThere appear to be four clusters, with the topmost and rightmost appearing to be similar to one another.\nWithin these two clusters, the rightmost portion of them appears to be the same shape\n as the larger figure.\nIf you try switching between the *κ*-adic options, you can even see the smaller\n and larger shapes changing in the same way as one another.\n\nIf you prefer not to use JavaScript, I also prepared a [Python script](./kadic.py) to run locally[^1].\nYou can trace out images from this version can be seen below:\n\n:::: {.row .centered}\n::: {layout-ncol=\"2\"}\n![`quotRem`](./cendree_quotrem_fractal.png)\n\n![`divMod`](./cendree_divmod_fractal.png)\n:::\n\nClusters of *κ*-adics, with self-similar patterns boxed in red.\n::::\n\nThis is actually great news -- if you switch between the *κ*-adics and the \"random binary\" option,\n you can see that the latter option tends to the same pattern as the 2-adics.\nThus, even if the expansions for the integers are individually chaotic, together they possess a\n much different structure than pure randomness.\n\n[^1]: You will also need the [`divMod`](./cendree_DivMod_count_1024_256_digits.csv)\n and [`quotRem`](./cendree_QuotRem_count_1024_256_digits.csv) data files.\n\n", + "markdown": "---\ntitle: \"Polynomial Counting 4, Addendum\"\ndescription: |\n Additional notes on irrational -adic expansions, including complex embeddings thereof.\nformat:\n html:\n html-math-method: katex\ndate: \"2025-03-03\"\ncategories:\n - algebra\n - haskell\n - interactive\n---\n\n\n\nAfter converting my original [Two 2's post](../), I grew pleased with making its diagrams\n and content more reproducible.\nHowever, I noticed some things which required further examination.\n\nFirst, let's write out a double-width carry function more concretely in Haskell.\n\n::: {#0676e879 .cell execution_count=3}\n``` {.haskell .cell-code}\n-- Widened carry of a particular repeated amount\n-- i.e., for carry2 2, the carry is 22 = 100\ncarry2 b = carry2' []\n where carry2' zs (x:y:z:xs)\n | q == 0 = carry2' (x:zs) (y:z:xs) -- try carrying at a higher place value\n | otherwise = foldl (flip (:)) ys zs -- carry here\n where ys = r : y-x+r : z+q : xs\n (q, r) = x `quotRem` b\n```\n:::\n\n\nIn the parent post, it was discussed that the integer four has a non-repeating expansion\n when expressed as an *κ*-adic integer.\nLet's put this to the test by writing out each step for producing expansions of two and four.\nWe'll also test these expansions by evaluating them at an approximation of $\\kappa = \\sqrt 3 + 1$.\nWe should roughly get two and four at each step.\n\n::: {#3d716217 .cell layout-ncol='2' execution_count=4}\n``` {.haskell .cell-code code-fold=\"true\"}\n-- Directly expand the integer `n`, using the `carry` showing each step for `count` steps\nexpandSteps count carry n = take count $ iterate carry $ n:replicate count 0\n\n-- Horner evaluation on polynomials of ascending powers\nhornerEval x = foldr (\\c a -> a * x + c) 0\n-- Pair a polynomial with its evaluation at x\npairEval x = (,) <*> hornerEval x . map fromIntegral\n\nadicTwoSteps = map (pairEval (sqrt 3 + 1)) $ expandSteps 10 (carry2 2) 2\nadicFourSteps = map (pairEval (sqrt 3 + 1)) $ expandSteps 10 (carry2 2) 4\n\nmarkdown \"Iteratively carrying \\\"2\\\"\"\nmarkdown \"Iteratively carrying \\\"4\\\"\"\n\nputStrLn . unlines . map show $ adicTwoSteps\nputStrLn . unlines . map show $ adicFourSteps\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\nIteratively carrying \"2\"\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\nIteratively carrying \"4\"\n:::\n\n::: {.cell-output .cell-output-display}\n```\n([2,0,0,0,0,0,0,0,0,0,0],2.0)\n([0,-2,1,0,0,0,0,0,0,0,0],1.9999999999999996)\n([0,0,3,-1,0,0,0,0,0,0,0],2.0000000000000004)\n([0,0,1,-3,1,0,0,0,0,0,0],1.9999999999999982)\n([0,0,1,-1,3,-1,0,0,0,0,0],2.000000000000005)\n([0,0,1,-1,1,-3,1,0,0,0,0],1.9999999999999867)\n([0,0,1,-1,1,-1,3,-1,0,0,0],2.0000000000000364)\n([0,0,1,-1,1,-1,1,-3,1,0,0],1.9999999999999005)\n([0,0,1,-1,1,-1,1,-1,3,-1,0],2.000000000000272)\n([0,0,1,-1,1,-1,1,-1,1,-3,1],1.999999999999257)\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```\n([4,0,0,0,0,0,0,0,0,0,0],4.0)\n([0,-4,2,0,0,0,0,0,0,0,0],3.999999999999999)\n([0,0,6,-2,0,0,0,0,0,0,0],4.000000000000001)\n([0,0,0,-8,3,0,0,0,0,0,0],4.000000000000003)\n([0,0,0,0,11,-4,0,0,0,0,0],4.000000000000021)\n([0,0,0,0,1,-14,5,0,0,0,0],3.9999999999998543)\n([0,0,0,0,1,0,19,-7,0,0,0],4.000000000000845)\n([0,0,0,0,1,0,1,-25,9,0,0],4.000000000000486)\n([0,0,0,0,1,0,1,-1,33,-12,0],3.9999999999982596)\n([0,0,0,0,1,0,1,-1,1,-44,16],3.999999999986544)\n```\n:::\n:::\n\n\nNote that when an list is displayed in this post, it should be interpreted as an expansion\n in increasing powers.\n\n\nExpansions of *κ*-adics\n-----------------------\n\nIn the original post, we ignored expansions other than the chaotic expansions of four.\nConsider that we can use *two different* expansions for three, since we are using a balanced alphabet:\n\n::: {#8b74477c .cell layout-ncol='2' execution_count=5}\n``` {.haskell .cell-code code-fold=\"true\"}\nmarkdown \"Increment two:\"\nmarkdown \"Decrement three:\"\n\nadicThree = (1:) $ tail $ fst $ last adicTwoSteps\nprint adicThree\n\nadicThree' = ((-1):) $ tail $ fst $ last adicFourSteps\nprint adicThree'\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\nIncrement two:\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\nDecrement three:\n:::\n\n::: {.cell-output .cell-output-display}\n```\n[1,0,1,-1,1,-1,1,-1,1,-3,1]\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```\n[-1,0,0,0,1,0,1,-1,1,-44,16]\n```\n:::\n:::\n\n\nFor convenience (and correctness), we'll retain the carry heads rather than truncating them.\n\nHow can we be sure that both of these are expansions of three?\nEasy. Just negate every term of one of them, then add them together to see if they cancel.\n\n::: {#5b125f65 .cell execution_count=6}\n``` {.haskell .cell-code}\nmaybeZero = take 10 $ iterate (carry2 2) $ zipWith (+) adicThree (map negate adicThree')\nputStrLn . unlines . map show $ maybeZero\n```\n\n::: {.cell-output .cell-output-display}\n```\n[2,0,1,-1,0,-1,0,0,0,41,-15]\n[0,-2,2,-1,0,-1,0,0,0,41,-15]\n[0,0,4,-2,0,-1,0,0,0,41,-15]\n[0,0,0,-6,2,-1,0,0,0,41,-15]\n[0,0,0,0,8,-4,0,0,0,41,-15]\n[0,0,0,0,0,-12,4,0,0,41,-15]\n[0,0,0,0,0,0,16,-6,0,41,-15]\n[0,0,0,0,0,0,0,-22,8,41,-15]\n[0,0,0,0,0,0,0,0,30,30,-15]\n[0,0,0,0,0,0,0,0,0,0,0]\n```\n:::\n:::\n\n\nAs you can see, eventually we completely clear the number and just get list of zeros.\n\nWhich of these expansions is more valid?\nI would argue that we should prefer expansions obtained by incrementing, since the natural numbers\n are built in the same way.\nThis is flimsy, though. By doing this, negative one will never appear in the one's place.\n\nIt's also worth pointing out that we only have this choice at odd numbers.\nAt even numbers, the one's place is always zero.\nIt's easy to see why this is the case -- if there's a \"2\" in the one's place, it can be carried,\n just like in binary.\n\n\nBalanced vs. Binary *κ*-adics\n-----------------------------\n\nA more unusual consequence of the carry is that despite the initial choice of alphabet,\n [negative numerals can be cleared](../#all-positive)\n from the expansion by using an extra-greedy borrow.\n\nThere is only one significant difference in how the two are implemented:\n the choice of integer division function.\nIn Haskell, there exists both `quotRem` and `divMod`, with the two disagreeing on negative remainders.\n\n::: {#50408001 .cell layout-ncol='2' execution_count=7}\n``` {.haskell .cell-code code-fold=\"true\"}\nmarkdown \"`quotRem`\"\nmarkdown \"`divMod`\"\n\nprint $ quotRem (-27) 5\nprint $ divMod (-27) 5\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n`quotRem`\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n`divMod`\n:::\n\n::: {.cell-output .cell-output-display}\n```\n(-5,-2)\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```\n(-6,3)\n```\n:::\n:::\n\n\nWe can factor our choice out of our two digit-wide carry function by passing it as an argument:\n\n::: {#f7b54625 .cell execution_count=8}\n``` {.haskell .cell-code}\ncarry2QR qr b = carry2QR' []\n where carry2QR' zs (x:y:z:xs)\n | q == 0 = carry2QR' (x:zs) (y:z:xs) -- try carrying at a higher place value\n | otherwise = foldl (flip (:)) ys zs -- carry here\n where ys = r : y-x+r : z+q : xs\n (q, r) = x `qr` b\n```\n:::\n\n\nNow, let's compare the iterates of the two options by applying them to \"4\":\n\n::: {#e8249842 .cell layout-ncol='2' execution_count=9}\n``` {.haskell .cell-code code-fold=\"true\"}\ncendree4QuotRem10Steps = map (pairEval (sqrt 3 + 1)) $ expandSteps 10 (carry2QR quotRem 2) 4\ncendree4DivMod10Steps = map (pairEval (sqrt 3 + 1)) $ expandSteps 10 (carry2QR divMod 2) 4\n\nmarkdown \"`quotRem`\"\nmarkdown \"`divMod`\"\n\nputStrLn . unlines . map show $ cendree4QuotRem10Steps\nputStrLn . unlines . map show $ cendree4DivMod10Steps\n```\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n`quotRem`\n:::\n\n::: {.cell-output .cell-output-display .cell-output-markdown}\n`divMod`\n:::\n\n::: {.cell-output .cell-output-display}\n```\n([4,0,0,0,0,0,0,0,0,0,0],4.0)\n([0,-4,2,0,0,0,0,0,0,0,0],3.999999999999999)\n([0,0,6,-2,0,0,0,0,0,0,0],4.000000000000001)\n([0,0,0,-8,3,0,0,0,0,0,0],4.000000000000003)\n([0,0,0,0,11,-4,0,0,0,0,0],4.000000000000021)\n([0,0,0,0,1,-14,5,0,0,0,0],3.9999999999998543)\n([0,0,0,0,1,0,19,-7,0,0,0],4.000000000000845)\n([0,0,0,0,1,0,1,-25,9,0,0],4.000000000000486)\n([0,0,0,0,1,0,1,-1,33,-12,0],3.9999999999982596)\n([0,0,0,0,1,0,1,-1,1,-44,16],3.999999999986544)\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```\n([4,0,0,0,0,0,0,0,0,0,0],4.0)\n([0,-4,2,0,0,0,0,0,0,0,0],3.999999999999999)\n([0,0,6,-2,0,0,0,0,0,0,0],4.000000000000001)\n([0,0,0,-8,3,0,0,0,0,0,0],4.000000000000003)\n([0,0,0,0,11,-4,0,0,0,0,0],4.000000000000021)\n([0,0,0,0,1,-14,5,0,0,0,0],3.9999999999998543)\n([0,0,0,0,1,0,19,-7,0,0,0],4.000000000000845)\n([0,0,0,0,1,0,1,-25,9,0,0],4.000000000000486)\n([0,0,0,0,1,0,1,1,35,-13,0],4.000000000005557)\n([0,0,0,0,1,0,1,1,1,-47,17],3.9999999999669607)\n```\n:::\n:::\n\n\nFortunately, regardless of which function we pick, the evaluation roughly gives four at each step.\nNote that since `quotRem` allows negative remainders, implementing the carry with it causes\n negative numbers to show up in our expansions.\nConversely, negative numbers *cannot* show up if we use `divMod`.\n\n\n### Chaos before Four\n\nRecall again the series for two in the *κ*-adics:\n\n$$\n2 = ...1\\bar{1}1\\bar{1}1\\bar{1}100_{\\kappa}\n$$\n\nSince the `divMod` implementation clears negative numbers from expansions, we can try using it on this series.\nThe result is another chaotic series:\n\n::: {#27acbab0 .cell execution_count=10}\n``` {.haskell .cell-code}\ncendree2DivModCycleExpansion = take 11 $\n iterate (carry2QR divMod 2) $ take 15 $ 0:0:cycle [1,-1]\nputStrLn . unlines . map show $ cendree2DivModCycleExpansion\n```\n\n::: {.cell-output .cell-output-display}\n```\n[0,0,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1]\n[0,0,1,1,3,-2,1,-1,1,-1,1,-1,1,-1,1]\n[0,0,1,1,1,-4,2,-1,1,-1,1,-1,1,-1,1]\n[0,0,1,1,1,0,6,-3,1,-1,1,-1,1,-1,1]\n[0,0,1,1,1,0,0,-9,4,-1,1,-1,1,-1,1]\n[0,0,1,1,1,0,0,1,14,-6,1,-1,1,-1,1]\n[0,0,1,1,1,0,0,1,0,-20,8,-1,1,-1,1]\n[0,0,1,1,1,0,0,1,0,0,28,-11,1,-1,1]\n[0,0,1,1,1,0,0,1,0,0,0,-39,15,-1,1]\n[0,0,1,1,1,0,0,1,0,0,0,1,55,-21,1]\n[0,0,1,1,1,0,0,1,0,0,0,1,1,-75,28]\n```\n:::\n:::\n\n\nNote that in this case, we're truncating the alternating series!\nThis means that naively evaluating the series as before will not give the correct value.\n\nTo check the validity of this series, we can check that we get the same series before the truncated elements\n by expanding 2 directly:\n\n::: {#e8d9f36e .cell execution_count=11}\n``` {.haskell .cell-code}\ncendree2DivMod15Steps = map (pairEval (sqrt 3 + 1)) $\n expandSteps 15 (carry2QR divMod 2) 2\nputStrLn . unlines . map show $ cendree2DivMod15Steps\n```\n\n::: {.cell-output .cell-output-display}\n```\n([2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],2.0)\n([0,-2,1,0,0,0,0,0,0,0,0,0,0,0,0,0],1.9999999999999996)\n([0,0,3,-1,0,0,0,0,0,0,0,0,0,0,0,0],2.0000000000000004)\n([0,0,1,-3,1,0,0,0,0,0,0,0,0,0,0,0],1.9999999999999982)\n([0,0,1,1,5,-2,0,0,0,0,0,0,0,0,0,0],2.0000000000000115)\n([0,0,1,1,1,-6,2,0,0,0,0,0,0,0,0,0],1.9999999999999758)\n([0,0,1,1,1,0,8,-3,0,0,0,0,0,0,0,0],1.9999999999999394)\n([0,0,1,1,1,0,0,-11,4,0,0,0,0,0,0,0],1.9999999999995541)\n([0,0,1,1,1,0,0,1,16,-6,0,0,0,0,0,0],1.999999999999047)\n([0,0,1,1,1,0,0,1,0,-22,8,0,0,0,0,0],1.999999999993247)\n([0,0,1,1,1,0,0,1,0,0,30,-11,0,0,0,0],2.000000000015452)\n([0,0,1,1,1,0,0,1,0,0,0,-41,15,0,0,0],2.0000000000454636)\n([0,0,1,1,1,0,0,1,0,0,0,1,57,-21,0,0],1.9999999998345677)\n([0,0,1,1,1,0,0,1,0,0,0,1,1,-77,28,0],1.9999999961807242)\n([0,0,1,1,1,0,0,1,0,0,0,1,1,1,106,-39],1.999999997642363)\n```\n:::\n:::\n\n\nUp to the carry head, the series are the same.\nWe can do the same thing to get a series for negative one, a number which has a terminating expansion\n in the balanced alphabet.\n\n::: {#7600aa54 .cell execution_count=12}\n``` {.haskell .cell-code}\ncendreeNeg1DivMod15Steps = map (pairEval (sqrt 3 + 1)) $\n expandSteps 15 (carry2QR divMod 2) (-1)\nputStrLn . unlines . map show $ cendreeNeg1DivMod15Steps\n```\n\n::: {.cell-output .cell-output-display}\n```\n([-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],-1.0)\n([1,2,-1,0,0,0,0,0,0,0,0,0,0,0,0,0],-0.9999999999999996)\n([1,0,-3,1,0,0,0,0,0,0,0,0,0,0,0,0],-1.0000000000000004)\n([1,0,1,5,-2,0,0,0,0,0,0,0,0,0,0,0],-0.9999999999999958)\n([1,0,1,1,-6,2,0,0,0,0,0,0,0,0,0,0],-1.0000000000000089)\n([1,0,1,1,0,8,-3,0,0,0,0,0,0,0,0,0],-1.0000000000000222)\n([1,0,1,1,0,0,-11,4,0,0,0,0,0,0,0,0],-1.000000000000163)\n([1,0,1,1,0,0,1,16,-6,0,0,0,0,0,0,0],-1.0000000000003486)\n([1,0,1,1,0,0,1,0,-22,8,0,0,0,0,0,0],-1.0000000000024718)\n([1,0,1,1,0,0,1,0,0,30,-11,0,0,0,0,0],-0.9999999999943441)\n([1,0,1,1,0,0,1,0,0,0,-41,15,0,0,0,0],-0.9999999999833591)\n([1,0,1,1,0,0,1,0,0,0,1,57,-21,0,0,0],-1.0000000000605525)\n([1,0,1,1,0,0,1,0,0,0,1,1,-77,28,0,0],-1.000000001397952)\n([1,0,1,1,0,0,1,0,0,0,1,1,1,106,-39,0],-1.000000000862955)\n([1,0,1,1,0,0,1,0,0,0,1,1,1,0,-145,53],-1.0000000211727116)\n```\n:::\n:::\n\n\nThe most natural property of negative one should be that if we add one to it, we get zero.\nIf we take the last iterate of this, increment the zeroth place value, and apply the carry,\n we find that everything clears properly.\n\n::: {#32d73dbb .cell execution_count=13}\n``` {.haskell .cell-code}\ncendree0FromNeg1DivMod = (\\(x:xs) -> (x + 1):xs) $ fst $ last cendreeNeg1DivMod15Steps\ncendree0IncrementSteps = map (pairEval (sqrt 3 + 1)) $ take 15 $\n iterate (carry2QR divMod 2) cendree0FromNeg1DivMod\n\nputStrLn . unlines . map show $ cendree0IncrementSteps\n```\n\n::: {.cell-output .cell-output-display}\n```\n([2,0,1,1,0,0,1,0,0,0,1,1,1,0,-145,53],-2.117271158397216e-8)\n([0,-2,2,1,0,0,1,0,0,0,1,1,1,0,-145,53],-2.117271183049399e-8)\n([0,0,4,0,0,0,1,0,0,0,1,1,1,0,-145,53],-2.1172712567825478e-8)\n([0,0,0,-4,2,0,1,0,0,0,1,1,1,0,-145,53],-2.1172716608068815e-8)\n([0,0,0,0,6,-2,1,0,0,0,1,1,1,0,-145,53],-2.11727015296754e-8)\n([0,0,0,0,0,-8,4,0,0,0,1,1,1,0,-145,53],-2.117275780300572e-8)\n([0,0,0,0,0,0,12,-4,0,0,1,1,1,0,-145,53],-2.1172363115313245e-8)\n([0,0,0,0,0,0,0,-16,6,0,1,1,1,0,-145,53],-2.1172322503707736e-8)\n([0,0,0,0,0,0,0,0,22,-8,1,1,1,0,-145,53],-2.1172474068282878e-8)\n([0,0,0,0,0,0,0,0,0,-30,12,1,1,0,-145,53],-2.1179440228212383e-8)\n([0,0,0,0,0,0,0,0,0,0,42,-14,1,0,-145,53],-2.1235751278905916e-8)\n([0,0,0,0,0,0,0,0,0,0,0,-56,22,0,-145,53],-2.1138031916672377e-8)\n([0,0,0,0,0,0,0,0,0,0,0,0,78,-28,-145,53],-1.9659634780718795e-8)\n([0,0,0,0,0,0,0,0,0,0,0,0,0,-106,-106,53],-2.0141670404689492e-8)\n([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],0.0)\n```\n:::\n:::\n\n\nNaturally, it should be possible to use the the expansions of negative one and two in tandem on any\n series in the balanced alphabet to convert it to the binary alphabet.\nActually demonstrating this and proving it is left as an exercise.\n\n\nAre these really -adic?\n-----------------------\n\nPerhaps it is still unconvincing that expanding the integers in this way gives something\n indeed related to *p*-adics.\nIn fact, since the expansions are in binary or (balanced) ternary, the integers should just\n be a subset of the 2-adics or 3-adics.\n\nStill, I wanted to see what these numbers actually \"look\" like, so I whipped up an interactive diagram.\nYou should definitely see [this page](/interactive/adic/) for more information, but\n the gist is that *p*-adics can be sent into the complex plane in a fractal-like way.\n\n\n```{ojs}\n// | echo: false\n\n/*\nFileAttachments:\n ./cendree_DivMod_count_1024_256_digits.csv: ./cendree_DivMod_count_1024_256_digits.csv\n ./cendree_QuotRem_count_1024_256_digits.csv: ./cendree_QuotRem_count_1024_256_digits.csv\n*/\n\n// Import expansions from file.\n// Odd numbers are injected by replacing the first entry of each row with \"1\"\nasIntegers = (x) => {\n let xs = x.split(\"\\n\").map((y) => y.split(\",\").map((z) => +z))\n return [...xs, ...(xs.map((ys) => ys.with(0, 1)))]\n};\n\nadicExpansionsDivMod = FileAttachment(\n \"./cendree_DivMod_count_1024_256_digits.csv\"\n).text().then(asIntegers);\nadicExpansionsQuotRem = FileAttachment(\n \"./cendree_QuotRem_count_1024_256_digits.csv\"\n).text().then(asIntegers);\n\nimport { expansions as oldExpansions } with { base as base } from \"../../../../interactive/p-adics/showAdic.ojs\";\n\nexpansionsOrAdics = baseSelector == \"b-adic\"\n ? oldExpansions\n : baseSelector == \"κ-adic, balanced\"\n ? adicExpansionsQuotRem\n : baseSelector == \"κ-adic, binary\"\n ? adicExpansionsDivMod\n : d3.range(adicExpansionsQuotRem.length / 10).map(() => d3.range(15).map(() => +(Math.random() > 0.5)))\n\nimport { plot } with {\n expansionsOrAdics as expansions,\n embedBase as embedBase,\n geometric as geometric,\n} from \"../../../../interactive/p-adics/showAdic.ojs\";\n\nviewof baseSelector = Inputs.radio([\n \"b-adic\",\n \"κ-adic, balanced\",\n \"κ-adic, binary\",\n \"Random Binary\",\n], {\n value: \"b-adic\",\n label: \"Expansions\",\n});\n\nviewof base = Inputs.range([2, 5], {\n value: 2,\n step: 1,\n label: \"Base of expansions (b)\",\n disabled: baseSelector != \"b-adic\",\n});\n\nviewof embedBase = Inputs.range([2, 5], {\n value: 2,\n step: 0.1,\n label: \"Embedding base (p)\",\n});\n\nviewof geometric = Inputs.range([0.005, 0.995], {\n value: 0.9,\n step: 0.005,\n label: \"Geometric ratio (c)\",\n});\n\nplot\n\n```\n\nFirst, notice that with $b = 2$ and $p = 2$, switching between the \"b-adic\" option\n and the \"*κ*-adic\" option appears cause some points to appear and disappear.\nIt is easiest to see this when $c \\approx 0.5$.\nThis corresponds with the intuition that these are subsets of the 2- and 3-adics.\n\nNext, notice that when plotting the *κ*-adics, there is some self-similarity different\n from the 2- and 3-adics.\nTo see this, try setting $c \\approx 0.75$.\nThere appear to be four clusters, with the topmost and rightmost appearing to be similar to one another.\nWithin these two clusters, the rightmost portion of them appears to be the same shape\n as the larger figure.\nIf you try switching between the *κ*-adic options, you can even see the smaller\n and larger shapes changing in the same way as one another.\n\nThis is actually great news -- if you switch between the *κ*-adics and the \"random binary\" option,\n you can see that the latter option tends to the same pattern as the 2-adics.\nThus, even if the expansions for the integers are individually chaotic, together they possess a\n much different structure than pure randomness.\n\nIf you prefer not to use JavaScript, I also prepared a [Python script](./kadic.py) using Matplotlib.[^1]\nHere are a couple of screenshots from the script, which demonstrates the self-similarity mentioned above.\n\n:::: {.row}\n::: {layout-ncol=\"2\"}\n![`quotRem`](./cendree_quotrem_fractal.png)\n\n![`divMod`](./cendree_divmod_fractal.png)\n:::\n\nClusters of *κ*-adics, with self-similar patterns boxed in red.\n::::\n\n[^1]: You will also need the [`divMod`](./cendree_DivMod_count_1024_256_digits.csv)\n and [`quotRem`](./cendree_QuotRem_count_1024_256_digits.csv) data files.\n\n", "supporting": [ "index_files" ], diff --git a/posts/polycount/4/appendix/index.qmd b/posts/polycount/4/appendix/index.qmd index f97be8d..621aab0 100644 --- a/posts/polycount/4/appendix/index.qmd +++ b/posts/polycount/4/appendix/index.qmd @@ -233,7 +233,7 @@ Perhaps it is still unconvincing that expanding the integers in this way gives s In fact, since the expansions are in binary or (balanced) ternary, the integers should just be a subset of the 2-adics or 3-adics. -Still, wanted to see what these numbers actually "look" like, so I whipped up an interactive diagram. +Still, I wanted to see what these numbers actually "look" like, so I whipped up an interactive diagram. You should definitely see [this page](/interactive/adic/) for more information, but the gist is that *p*-adics can be sent into the complex plane in a fractal-like way. @@ -258,10 +258,15 @@ Within these two clusters, the rightmost portion of them appears to be the same If you try switching between the *κ*-adic options, you can even see the smaller and larger shapes changing in the same way as one another. -If you prefer not to use JavaScript, I also prepared a [Python script](./kadic.py) to run locally[^1]. -You can trace out images from this version can be seen below: +This is actually great news -- if you switch between the *κ*-adics and the "random binary" option, + you can see that the latter option tends to the same pattern as the 2-adics. +Thus, even if the expansions for the integers are individually chaotic, together they possess a + much different structure than pure randomness. -:::: {.row .centered} +If you prefer not to use JavaScript, I also prepared a [Python script](./kadic.py) using Matplotlib.[^1] +Here are a couple of screenshots from the script, which demonstrates the self-similarity mentioned above. + +:::: {.row} ::: {layout-ncol="2"} ![`quotRem`](./cendree_quotrem_fractal.png) @@ -271,10 +276,5 @@ You can trace out images from this version can be seen below: Clusters of *κ*-adics, with self-similar patterns boxed in red. :::: -This is actually great news -- if you switch between the *κ*-adics and the "random binary" option, - you can see that the latter option tends to the same pattern as the 2-adics. -Thus, even if the expansions for the integers are individually chaotic, together they possess a - much different structure than pure randomness. - [^1]: You will also need the [`divMod`](./cendree_DivMod_count_1024_256_digits.csv) and [`quotRem`](./cendree_QuotRem_count_1024_256_digits.csv) data files. diff --git a/posts/polycount/4/appendix/showAdicWithKappa.ojs b/posts/polycount/4/appendix/showAdicWithKappa.ojs index 218c612..1b86a6f 100644 --- a/posts/polycount/4/appendix/showAdicWithKappa.ojs +++ b/posts/polycount/4/appendix/showAdicWithKappa.ojs @@ -23,9 +23,9 @@ import { expansions as oldExpansions } with { base as base } from "../../../../i expansionsOrAdics = baseSelector == "b-adic" ? oldExpansions : baseSelector == "κ-adic, balanced" - ? adicExpansionsDivMod + ? adicExpansionsQuotRem : baseSelector == "κ-adic, binary" - ? adicExpansionsQuotRem + ? adicExpansionsDivMod : d3.range(adicExpansionsQuotRem.length / 10).map(() => d3.range(15).map(() => +(Math.random() > 0.5))) import { plot } with {