revisions to polycount.4

This commit is contained in:
queue-miscreant 2025-02-12 07:11:18 -06:00
parent 5a2bd81bfc
commit 4b77479028
4 changed files with 627 additions and 225 deletions

44
polycount/4/cendree.hs Normal file
View File

@ -0,0 +1,44 @@
-- widened borrow of a particular repeated amount
-- i.e., for borrow2 2, the borrow is 22 = 100
borrow2 b | b == 1 = error "Cannot borrow 1: implies positional symbol zero disallowed"
| otherwise = borrow' [] b
where borrow' zs b (x:y:z:xs) | abs x >= b = zipUp ys zs
| otherwise = borrow' (x:zs) b (y:z:xs)
where ys = r : y-x+r : z+q : xs
(q, r) = x `quotRem` b
zipUp = foldl (flip (:))
--degenerate `borrow2 1 `that remedies inadequacies in below for 1, i.e., the borrow is 11 = 100
--this system is VERY bad because we invoke the place value '0' to expand into
--borrow1' zs (x:y:z:xs) | abs x > 1 = zipUp ys zs
-- | otherwise = borrow1' (x:zs) (y:z:xs)
-- where ys = (signum x):(y-x+signum x):z+(x-1):xs
-- truncate the adic expansion to n digits, for a system where borrows are 2 wide and both b
truncadic b n = take n . (!! n) . iterate (borrow2 b)
--same but, produce a list of expansions, taking modulo m in between borrows
truncadicmod b m n = map (take n) . take n . iterate (map (`rem` m) . borrow2 2)
-- find moduli starting from s where truncations agree
-- caveat: the last of truncadicmod is not guaranteed to exhaust terms outside alphabet
-- i.e., for b = 2, the alphabet {-1, 0, 1}
findaccurate b n s xs = map fst $ filter ((==good) . snd) bads
where good = truncadic b n xs
bads = map (\m -> (,) m $ last $ truncadicmod b m n xs) [s..]
--given an amount of digits `n`, a 2-wide borrow `b`, and a canonical representation of `b`
--construct integer multiples of `b`
evens n b = ([0]:) . map (take n) . iterate addb
--add b to an adic expansion
where addb = (!! n ) . iterate (borrow2 b) . (b:) . tail
--first 200 digits of cendree-adic expansions of even numbers
adics = evens 200 2 $ 0:0:cycle [1,-1]
adic2 = adics !! 1
adic4 = adics !! 2
adic4' = truncadic 2 200 $ (++repeat 0) $ map (*2) adic2
-- note: `truncadic 2 n $ 4:repeat 0` is the aggressive application of the carry to 4
-- but this could be done better since there are only 3 terms in the head, and no higher
-- series terms get in the way; the remainders would be emitted while the thunk continued

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,223 +1,390 @@
---
title: "Polynomial Counting 4: Two 2's"
format:
html:
html-math-method: katex
date: "2021-02-09"
date-modified: "2/12/2025"
jupyter: python3
categories:
- algebra
- python
---
<style>
.cell-output-display .figure {
text-align: center;
}
Polynomial Counting: Two 2's
============================
/* #long-trunc-figures .figure-img { */
.figure-img {
max-width: 512px;
object-fit: contain;
height: 100%;
}
</style>
This post assumes you have read [the first](), which introduces generalized polynomial counting, and [the second](), which restricts the focus and specifies the general aim.
This post assumes you have read [the first](../1), which introduces generalized polynomial counting,
and [the second](../2), which restricts the focus and specifies the general aim.
Gray Silver
-----------
Extra Metals
------------
As previously shown, the golden ratio (recurrence $\langle 1, 1|$) can be generalized in several ways. The silver ratio was introduced as the next "metallic mean", a sequence of quadratic roots of the form $\langle n, 1|$, and the limiting ratios of the corresponding recurrences. These roots have a (simple) [*continued fraction*](https://en.wikipedia.org/wiki/Continued_fraction) expansion:
As previously shown, the golden ratio (recurrence $\langle 1, 1|$) can be generalized in several ways.
The silver ratio was introduced as the next "metallic mean",
a sequence of quadratic roots of the form $\langle n, 1|$,
and the limiting ratios of the corresponding recurrences.
The metallic ratios have simple [*continued fraction*](https://en.wikipedia.org/wiki/Continued_fraction) expansions:
$$
\begin{gather*}
\langle n, 1| ~~\iff~~ x^2 - nx - 1 \\
x^2 = nx + 1 ~~\implies~~
x = n + \frac{1}{x} \\
x = n + \cfrac{1}{n + \cfrac{1}{n + \cfrac{1}{n + \cfrac{1}{\ddots}}}} = [n; \underline{n}]
x = n + \cfrac{1}
{n + \cfrac{1}
{n + \cfrac{1}
{n + \cfrac{1}{\ddots}}
}
}
= [n; \underline{n}]
\end{gather*}
$$
Again, the underline denotes repetition, since the overbar has been used for negation. When we examined the Jacobsthal base, we tried flipping n and 1 before seeing that the system was hard to manipulate. However, parametrizing in both terms (recurrence $\langle n, n|$) demonstrates a strange duality with the above continued fraction:
Again, the underline denotes repetition, since the overbar has been used for negation.
Parametrizing the carry in both terms (recurrence $\langle n, n|$) demonstrates a strange duality
with the above continued fraction:
$$
\begin{gather*}
\langle n, n| ~~\Leftrightarrow~~ x^2 - nx - n \\
x^2 = nx + n ~~\Rightarrow~~
\langle n, n| ~~\iff~~ x^2 - nx - n \\
x^2 = nx + n ~~\implies~~
x = n + \frac{n}{x} \\
x = n + \cfrac{n}{n + \cfrac{n}{n + \cfrac{n}{n + \cfrac{n}{\ddots}}}} =
n + \cfrac{\textcolor{red}{\cancel{n}}}{\textcolor{red}{\cancel{n}} + \cfrac{\textcolor{red}{\cancel{n}}}
{n + \cfrac{\textcolor{blue}{\cancel{n}}}{\textcolor{blue}{\cancel{n}} + \cfrac{\textcolor{blue}{\cancel{n}}}{\ddots}}}}
\\
x = n + \cfrac{1}{1 + \cfrac{1}{n + \cfrac{1}{1 + \cfrac{1}{\ddots}}}} =
[n; \underline{1, n}]
n + \cfrac{\textcolor{red}{\cancel{n}}}
{\textcolor{red}{\cancel{n}} + \cfrac{\textcolor{red}{\cancel{n}}}
{n + \cfrac{\textcolor{blue}{\cancel{n}}}
{\textcolor{blue}{\cancel{n}} + \cfrac{\textcolor{blue}{\cancel{n}}}{\ddots}}
}
} \\
x = n + \cfrac{1}
{1 + \cfrac{1}
{n + \cfrac{1}
{1 + \cfrac{1}{\ddots}}
}
}
= [n; \underline{1, n}]
\end{gather*}
$$
In other words, the root of $\langle n, 1|$ has continued fraction n repeating, and the root of $\langle n, n|$ has continued fraction $n, 1$ repeating.
In other words, the root of $\langle n, 1|$ has continued fraction n repeating,
and the root of $\langle n, n|$ has continued fraction $n, 1$ repeating.
After the golden ratio, the next term in in the latter series is the recurrence $\langle 2,2 |$. It produces the series $0, 1, 2, 6, 16\dots$ ([OEIS A002605](http://oeis.org/A002605)), and the limiting ratio of its successive terms is $1 + \sqrt 3 \approx 2.7321\dots$. This value and the polynomial coefficients are bounded above by 3, so it stands to reason that a ternary alphabet is suitable. The trick for expanding 3 works as before:
### Gray Silver
The golden ratio belongs to both series.
After it, the next term in in the non-metallic series is the recurrence $\langle 2, 2 |$.
It produces the series $0, 1, 2, 6, 16\dots$ ([OEIS A002605](http://oeis.org/A002605)),
and the limiting ratio of its successive terms is $1 + \sqrt 3 \approx 2.7321\dots$.
This value and the polynomial coefficients are bounded above by 3, so it stands to reason that
a ternary alphabet is suitable.
The trick for expanding 3 works as before:
$$
\textcolor{red}{3}00 = 2\textcolor{red}{22}
= \textcolor{blue}{22}2 = \textcolor{blue}{1}002
$$
```{}
Unnamed Unnamed
Ratio Sequence
____
210 1234 6 2 1
0 0 0
1 1 1
2 2 1 0
3 10.02 1 1
4 11.02 2 0
5 12.02 2 1
6 20.1102 1 0 0
7 21.1102 1 0 1
8 100.1102 1 1 0
9 101.1102 1 1 1
10 102.1102 1 2 0
```
:::: {.row .text-center}
::: {#canonical-cendree-table .column width="60%"}
In an homage to heraldry terminology, I choose to call this system cendrée, and the root of the polynomial the ashen ratio (abbreviated $\kappa$). Gold and silver ("or" and "argent") are "metals"; cendrée is a non-standard color referring to an ashen gray, which reflects its relationship to the metallic means.
| *n* <br> (Decimal) | *n* <br> (Unnamed Ratio) | *n* <br> (Unnamed Sequence) |
|:------------------:|:------------------------:|:---------------------------:|
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 2 | 2 | 10 |
| 3 | 10.02 | 11 |
| 4 | 11.02 | 20 |
| 5 | 12.02 | 21 |
| 6 | 20.1102 | 100 |
| 7 | 21.1102 | 101 |
| 8 | 100.1102 | 110 |
| 9 | 101.1102 | 111 |
| 10 | 102.1102 | 120 |
:::
::::
As an homage to heraldry terminology, I choose to call this system cendrée,
and the root of the polynomial the ashen ratio (abbreviated *κ*).
Gold and silver ("or" and "argent") are "metals"; cendrée is a non-standard color
referring to an ashen gray, which reflects its relationship to the metallic means.
Ash on the Fulcrum
------------------
Each fractional expansion in the table above appears to end in "2". I've actually checked this for the first 1000 integers and found no expansions which do not terminate in "2" besides 0 and 1. In contrast, the silver ratio expansions end in both 1 and 2. While it isn't a problem with the fractional base on its own, things get complicated when considering a balanced alphabet.
Just like the silver ratio base, we can try expressing these using a balanced alphabet
{-1, 0, 1} instead of the standard one {0, 1, 2}.
There, we had the choice of forbidding either the string "11" or "10", because when the carry
was applied to either, the negative of the other would appear.
Just like then, we must choose whether to forbid "11" or "TT" (its negative), since carrying
at one produces the other.
$$
\begin{gather*}
\textcolor{red}{2.0} =
\textcolor{red}{1}0.\textcolor{blue}{\bar{2}0} =
1\textcolor{blue}{\bar{1}}.0\textcolor{orange}{20} =
1\bar{1}.\textcolor{orange}{1}0\bar{2} = \dots =
1\bar{1}.\underline{1\bar{1}}
\\
\textcolor{green}{2} =
1\bar{1}.0\textcolor{green}{2} =
1\bar{1}.1\bar{1}0\textcolor{green}{2} = \dots =
1\bar{1}.\underline{1\bar{1}}\\
\end{gather*}
0\textcolor{red}{11} = \textcolor{red}{1}\bar{1}\bar{1}
$$
The number 2 happens to have an repeating balanced expansion. The first approach is the iterative application of the carry, while the second notices the recursion induced by the symbol "2". Both of these derivations involve an infinite number of steps, so there might still be a nagging suspicion that this is invalid. In fact, the we can derive the carry polynomial directly from this series (and vice versa) using a geometric series argument:
I choose to permit "11" since both terms of the carry are positive.
### Intractible Repetition
Our first target for conversion into a balanced form is "2".
$$
\textcolor{red}{2.0}_{\kappa}
= \textcolor{red}{1}0.\textcolor{blue}{\bar{2}0}_{\kappa}
= 1\textcolor{blue}{\bar{1}}.0\textcolor{orange}{20}_{\kappa}
= 1\bar{1}.\textcolor{orange}{1}0\bar{2} _{\kappa}
= \dots
= 1\bar{1}.\underline{1\bar{1}}_{\kappa}
$$
By iteratively applying the carry, we get a repeating balanced expansion.
Instead of this, we could derive an expansion by decrementing the expansion of three
$$
2 = 3 - 1 = 10.02_{\kappa} + \bar{1}
= 1\bar{1}.0\textcolor{green}{2}_{\kappa}
= 1\bar{1}.1\bar{1}0\textcolor{green}{2}_{\kappa}
= \dots
= 1\bar{1}.\underline{1\bar{1}}_{\kappa}
$$
for which we get the same expansion after recursing on the symbol "2".
Both of the above derivations involve an infinite number of steps, so there might still be some nagging suspicion
that the methods used are invalid.
To put it on firm(er) ground, we can derive the carry polynomial directly from this series (and vice versa)
using a geometric series argument:
::: {#geometric-series-2}
$$
\begin{gather*}
1.\underline{\vphantom{\bar{1}}1}_x
= 1 + x^{-1} + x^{-2} + x^{-3} + x^{-4} + \dots
= \frac{1}{1 - (1/x)} = \frac{x}{x - 1}
= 1 + x^{-1} + x^{-2} + x^{-3} + \dots
= \frac{1}{1 - (1/x)}
= \frac{x}{x - 1}
\\
1.\underline{\bar{1}1}_x
= 1 -\ x^{-1} + x^{-2} -\ x^{-3} + x^{-4} - \dots
= \frac{-x}{-x -\ 1}
= 1 -\ x^{-1} + x^{-2} -\ x^{-3} + \dots
= \frac{1}{1 + (1/x)}
= \frac{x}{x + 1}
\\
2 = 1\bar{1}.\underline{1\bar{1}}_x
= \frac{x^2}{x + 1}
\\
x^2 = 2x + 2
x^2 = 2x + 2 \iff \langle 2, 2 |
\end{gather*}
$$
:::
We assume both series converge, since $\kappa > 1$. Repeating expansions in integral bases are typically strange-looking expressions like $0.\underline{9} = 1$, and their only use is for rational numbers. For example, we can evaluate this expression $\frac{x^2}{x + 1}$ at $x = 3$ to interpret "$1.\underline{\bar{1}1}$" as a ternary (base 3) expansion. I happens to be the rational value $9/4 = 2.25_{10}$. But the irrational base $\kappa$ breaks that rule, and a repeating expansion is necessary to represent an integer.
We assume both series converge, since $\kappa > 1$.
Recall that in decimal, repeating expansions usually signify rational numbers, like $0.\underline{3}_{10} = 1/3$.
Similarly, we can interpret "$1\bar{1}.\underline{1\bar{1}}$" as a base three expansion by evaluating
$x^2 / ( x + 1 )$ at three, getting $1\bar{1}.\underline{1\bar{1}}_3 = 9/4 = 2.25_{10}$.
Normally, the rule is that when the denominator of a rational number and base are coprime
(in the first example, three and ten; in the second, four and three), its expansion repeats.
But two in the irrational base *κ* breaks that rule in a balanced alphabet.
### Mixing Ashes
In the balanced silver ratio base, we had the choice of forbidding either of "$11$" or "$10$". This was because when the carry was applied to either string, the negative of the other would appear. In this system, the dilemma is instead whether to forbid "$11$" or its negative, since carrying at one produces the other. I choose to permit positive adjacent 1's since both terms of the carry are positive.
Naively, we can convert each entry of the earlier table to a balanced form by replacing "2"s with
(shifts of) the repeating expansion.
But notice that each listed fractional expansion above three appears to end in "2".
In contrast, the [silver ratio expansions](../2#canonical-silver-table) ended in both "1" and "2".
I suspect that the only repeating string which occurs in the integers is $0.\underline{1\bar{1}}$ and shifts thereof, but have no proof. If we use the digit "2" to represent the repeating string, we can write mixed balanced expansions of integers. However, we must remember to forbid "102", since it would expand to "$11\bar{1}.\underline{1\bar{1}}$", which has two adjacent 1's.
While this isn't a problem with the fractional base on its own, it complicates things
when considering the balanced alphabet.
In fact, it seems to be the case that *all* base *κ* expansions of integers above three terminate in "2",
but I won't bother proving it (see note for a sketch[^1]).
```{}
Mixed Cendree Balanced Cendree
______ ____|__
3210 123456 3210 1234|56 (repeating)
0 0 0
1 1 1
2 2 1T.1T1T 1T...
2 1T.02 1T.1T1T 1T...
3 10.02 10.1T1T 1T...
4 1TT.02 1TT.1T1T 1T...
5 1T0.02 1T0.1T1T 1T...
6 10T.TT02 10T.TT1T 1T...
7 100.TT02 100.TT1T 1T...
8 101.TT02 101.TT1T 1T...
9 101.1102 101.111T 1T...
9 1TTT.0TTT02 1TTT.0TTT 1T...
10 1TT0.0TTT02 1TT0.0TTT 1T...
```
Note that at the transition from 8 to 9, instead of incrementing the 1, the string "$0.\bar{1}\bar{1}$" was incremented to "$0.11$". Similar strategies must be used for larger numbers.
Instead of converting directly, we can also just try counting from zero again, remembering the aforementioned
trick for converting "2", but we may get problems when "2" appears multiple times in the expansion.
Alternatively, by applying a finite version of the rule, we can move "2" further and further to the right.
Flip it Radix-ways
------------------
:::: {.row .text-center}
::: {#canonical-balanced-cendree-table .column width="100%"}
Repeating expansions usually come from fractions whose denominator is coprime to the base. It is possible to convert such numbers into the ratio of two integers by using a fairly simple procedure. Here it is applied to both $0.\underline{69}_{10}$ and the string in question, "$0.1\bar{1}$":
<style>
#canonical-balanced-cendree-table td > em
{
color: red !important;
font-style: normal !important;
}
</style>
| *n* <br> (Decimal) | *n* <br> (Mixed Cendrée) | *n* <br> (Balanced Cendrée) | Remark |
|-------------------:|:------------------------:|:---------------------------:|:------------------------------------------|
| 0 | 0 | 0 | |
| 1 | 1 | 1 | |
| *2* | *2* | *1T. 1T...* | |
| 2 | 1T.02 | 1T. 1T... | Example of pushing "2" to the right |
| 3 | 10.02 | 10. 1T... | |
| 4 | 11.02 | 11. 1T... | |
| *5* | *12.02* | *11. 1T...* | |
| 5 | 1T0.02 | 1T0. 1T... | Carry "012" to "1T0" |
| 6 | 1T1.02 | 1T1. 1T... | |
| *7* | *1T2.02* | *1T2. 1T...* | |
| 7 | 10T.1102 | 10T.11 1T... | Push "02000" to "1T1T02" |
| 8 | 100.1102 | 100.11 1T... | |
| 9 | 101.1102 | 101.11 1T... | |
| *10* | *102.1102* | *102.11 1T...* | |
| 10 | 110.T102 | 110.T1 1T... | Carry "2.1" to "10.T" |
| 11 | 111.T102 | 111.T1 1T... | |
| *12* | *112.T102* | *112.T1 1T...* | |
| *12* | *2T0.T102* | | Carry "012" to "1T0" |
| 12 | 1T0T.001102 | 1T0T.0011 1T... | Push "0200000000" to "1T1T1T1T02" |
: {tbl-colwidths="[15,20,25,40]"}
:::
::::
Between some rows of the table, we have to apply the carry slightly more greedily --
on the strings "21" and "12" as well as "22".
In fact, looking slightly ahead to fifteen, we have to use another trick:
$$
\begin{align*}
15_{10} = 1\bar{1}0\textcolor{red}{2}.001102_{\kappa}
&= 1\bar{1}\textcolor{red}{1\bar{1}.02}1102_{\kappa} \\
&= 1\bar{1}1\bar{1}.0\textcolor{blue}{21}102_{\kappa}
= 1\bar{1}1\bar{1}.\textcolor{blue}{10\bar{1}}102_{\kappa}
\end{align*}
$$
In other words, "2" should only be pushed to the right as far as an occurrence of "11", since at that point we can carry.
It remains to be proven that all but the rightmost "2" can be eliminated from a balanced expansion,
but good "pushes" appear to suffice.
-ary to -adic
-------------
We can convert a repeating expansions back into the ratio of two integers by using a fairly simple procedure.
Here, we apply that procuedure is applied to both $0.\underline{69}_{10}$
and the string in question, "$0.\underline{1\bar{1}}_{p}$", for generic $p$:
$$
\begin{gather*}
{0.\underbrace{
{
0.\underbrace{
\underline{\textcolor{blue}{69}}_{10}
}_{\text{length } \textcolor{red}{2}}}
}_{\text{length } \textcolor{red}{2}}
}
= \frac{\textcolor{blue}{69}_{10}}{10^{\textcolor{red}{2}} - 1}
= \frac{\textcolor{blue}{69}_{10}}{99_{10}}
= \frac{23_{10}}{33_{10}}
\\
0.\underline{
\textcolor{blue}{1\bar{1}}}_p
0.\underline{\textcolor{blue}{1\bar{1}}}_p
= \frac{\textcolor{blue}{1\bar{1}}_p}{p^2 - 1}
= \frac{p - 1}{p^2 - 1}
= \frac{1}{p + 1}
\end{gather*}
$$
These fractions can be used to construct [*p-adic numbers*](https://en.wikipedia.org/wiki/P-adic_number). For our purpose, this essentially places a $p^n - 1$ in the numerator and asserts that that $p^\infty \rightarrow 0$. For a length-2 repeating expansion, n is even, and the following quotients produce truncations:
These fractions can be used to construct [p-*adic numbers*](https://en.wikipedia.org/wiki/P-adic_number).
Doing so requires us to realize that $p + 1$ always divides $p^{2n} - 1$.
Doing the long division directly for some small $n$, we get:
$$
\begin{align*}
&\frac{p^2 - 1}{p+1} = \frac{10\bar{1}}{11}
&\frac{p^2 - 1}{p+1} = \frac{10\bar{1}_p}{11_p}
& \substack{
\phantom{11}{\underline{\phantom{)1}
1\bar{1}}} \\
\phantom{11}{\underline{\phantom{)1}1\bar{1}}} \\[3pt]
11)10\bar{1} \\
\phantom{11)}\underline{11} \phantom{0} \\
\phantom{11)}\underline{11} \phantom{0} \\[3pt]
\phantom{11)1}{\bar{1}\bar{1}} \\
\phantom{11)1}{\underline{\bar{1}\bar{1}}} \\
\phantom{11)1}{\underline{\bar{1}\bar{1}}} \\[3pt]
\phantom{11)1}00
} \\
\\
&\frac{p^4 - 1}{p+1} = \frac{1000\bar{1}}{11}
&\frac{p^4 - 1}{p+1} = \frac{1000\bar{1}_p}{11_p}
& \substack{
\phantom{11}{\underline{\phantom{)1}
1\bar{1}1\bar{1}}} \\
\phantom{11}{\underline{\phantom{)1}1\bar{1}1\bar{1}}} \\[3pt]
11)1000\bar{1} \\
\phantom{11)} \underline{11} \phantom{000} \\
\phantom{11)} \underline{11} \phantom{000} \\[3pt]
\phantom{11)1} \bar{1}0 \phantom{00}\\
\phantom{11)1} \underline{\bar{1}\bar{1}} \phantom{00} \\
\phantom{11)1} \underline{\bar{1}\bar{1}} \phantom{00} \\[3pt]
\phantom{11)10}10 \phantom{0} \\
\phantom{11)10} \underline{11} \phantom{0} \\
\phantom{11)10} \underline{11} \phantom{0} \\[3pt]
\phantom{11)100} \bar{1}\bar{1} \\
\phantom{11)100} \underline{\bar{1}\bar{1}} \\
\phantom{11)100} \underline{\bar{1}\bar{1}} \\[3pt]
\phantom{11)100} 00 \\
}
\end{align*}
$$
In the limit, the quotient is "$…1\bar{1}1\bar{1}1\bar{1}$", which is actually the negative of ${1 \over p+1}$ due to the negative sign in the numerator. Since we're using a balanced alphabet, negation is simply replacing "$\bar{1}$" with "$1$" and vice versa, producing...
If we assert $p^\infty$ approaches zero (regardless of whether $p$ is greater than or less than 1),
then in the limit we have the quotient $\bar{1}_p / 11_p = \dots 1\bar{1}1\bar{1}1\bar{1}_p$.
### Flip it Radix-ways
The series we're actually interested in is $1_p / 11_p$, which is the negative of the above series.
Since we're using a balanced alphabet, we can negate this by simply replacing $\bar{1}$ with $1$
(and vice versa), producing...
$$
0.1\bar{1}1\bar{1}1\bar{1}\dots\kappa = \dots\bar{1}1\bar{1}1\bar{1}1\bar{1}1_\kappa \\
0.\underline{1\bar{1}}_\kappa = \underline{\bar{1}1}\bar{1}1_\kappa
0.\underline{1\bar{1}}_p
= \frac{1_p}{11_p}
= \underline{\bar{1}1}\bar{1}1_p
$$
...which is the initial expansion, but flipped about the radix point. The final balanced $\kappa$-adic expansion for 2 can then be acquired through simple addition:
...which is the initial expansion, but flipped about the radix point.
We might also remember what [we did earlier with geometric series](#geometric-series-2) and just do
$$
\begin{align*}
&\phantom{+} 1\bar{1}.000000\dots\kappa
~=~ \dots\bar{1}_\kappa \\
&+ \underline{00.1\bar{1}1\bar{1}1\bar{1}\dots\kappa
\underline{1}1_p
&= 1 + p + p^2 + p^3 + ...
= \frac{1}{1 - p} \\
\underline{\bar{1}1}\bar{1}1_p
&= 1 - p + p^2 - p^3 + ...
= \frac{1}{1 + p}
\end{align*}
$$
Contrary to the usual case, in a *p*-adic sense, these series always converge,
since $p^n$ is considered to always shrink as $n$ grows.
### Back to *κ*
Returning to base *κ*, we can create the *κ*-adic expansion for two through simple addition:
$$
\begin{align*}
&\phantom{+} 1\bar{1}.000000\dots_\kappa
~=~ \dots00001\bar{1}_\kappa \\
&+ \underline{00.1\bar{1}1\bar{1}1\bar{1}\dots_\kappa
~=~ \dots\bar{1}1\bar{1}1\bar{1}1}_\kappa \\
& \phantom{+} 1\bar{1}.1\bar{1}1\bar{1}1\bar{1}\dots\kappa
& \phantom{+} 1\bar{1}.1\bar{1}1\bar{1}1\bar{1}\dots_\kappa
~=~ \dots\bar{1}1\bar{1}100_\kappa \\
\end{align*}
$$
Reading these expansions as power series, we can convert them into a rational expression
We can check this expansion by power series manipulations:
$$
\begin{align*}
@ -225,69 +392,93 @@ $$
&=\kappa^2 - \kappa^3 + \kappa^4 - \kappa^5 +\dots \\
&= \kappa^2(1 - \kappa + \kappa^2 - \kappa^3 +\dots) \\
&= \kappa^2 \cdot \frac{1}{1 - (-\kappa)} \\
&= \frac{\kappa^2}{\kappa + 1}
&= \frac{\kappa^2}{\kappa + 1} \\[8pt]
{2\kappa + 2}
&= \kappa^2
\end{align*}
$$
This is the same as the previous expression for 2. In a roundabout way, by borrowing *p*-adic ideas, we showed another way this is true by using power series manipulations. This also means that the long division above is in fact *polynomial* long division.
This gives us the defining relation of *κ*, so the expansion appears to be correct.
Two Plus Two Equals Chaos
-------------------------
*p*-adic expansions are still expressions in the base *p*, so the carry rule still applies. However, since the carry continues to infinity, we must at some point truncate the expansions to keep them within view. When *p* is an integer, the carry is a single digit wide, and we can demarcate a repeating section.
*p*-adic expansions are still expressions in the base *p*, so the carry rule still applies.
However, since the carry continues to infinity, we have a necessarily limited view,
which we can at best combat by marking repeating sections.
$\kappa$ is not an integer, and its carry has length 2. While the $\kappa$-adic expansion for 2 can be incremented once to produce a valid one one for 3, problems arise when attempting to construct 4. The most direct method is to start with the symbol "4" and manipulate it:
While the *κ*-adic expansion for two can be incremented once to produce a valid expansion one for three,
problems arise when attempting to construct four.
The most direct method is to start with the symbol "4" and manipulate it:
$$
4 = 2\bar{4}0
= \bar{2}600
= 3\bar{8}000
= \bar{4}\text{B}0000
= 5\bar{\text E}10000
= \text{J}0\textcolor{red}{1}0000
\begin{align*}
4_{\kappa}
&= 2\bar{4}0_{\kappa}
= \bar{2}600_{\kappa}
= 3\bar{8}000_{\kappa}
= \bar{4}\text{B}0000_{\kappa} \\
&= 5\bar{\text E}10000_{\kappa}
= \bar{7}\text{J}0\textcolor{red}{1}0000_{\kappa}
= \dots
\end{align*}
$$
(Latin characters used as digits start at A for ten, as in hexadecimal). Even though the most significant digit grows larger, a residual "1" (marked in red) is left behind. We can produce more terms indefinitely, but as shown, the "head digit" where the carry takes place starts to grow.
Latin characters used as numerals start at A for ten, as in hexadecimal.
As we carry to the left, the most significant digits (which I call the "carry head") grow larger without bound.
However, in doing so, a residual "1" (marked in red) is left behind in the fourth place value.
In typical *p*-adics, *p* is an integer, and the carry head is a single digit wide.
*κ* is not an integer, and the carry head here is two digits wide.
This may seem a little dubious, but truncating immediately to the right of the carry head
will produce the same effect regardless of its size.
### Alternative Constructions
To keep the head small, it would be nice if it were taken mod an integer. Both $\bar{1}$ and $1$ are odd, so one might hope that in between carries, mod 2 can be applied somewhere. Unfortunately, this is not the case. To produce the "3" seen in "$3\bar{8}000$", "6" must be carried appropriately. To capture this difference, we must upgrade the modulus to 8 (as 7 would ruin the parity). But this means that the expansion of 4 is "$30000$", so 8 must also be upgraded. Such upgrades occur ad infinitum, since the carry applies across all higher place values.
To keep the head small, it would be nice if it were taken mod an integer.
Both $\bar{1}$ and $1$ are odd, so one might hope that in between carries, we could mod out by two.
Unfortunately, this is not the case.
All of the expansions above are identically four, and manipulating the digits directly would just
give a different number.
Instead of expanding "4" directly, we have other options available.
Instead, we could try representing "4" in a more direct manner
There are a few other options available.
- Add the nonrepeating part of the mixed balanced expansion of 4 with the $\kappa$-adic version of the repeating part (Another direct manipulation)
- Add the nonrepeating part of the mixed balanced expansion of 4 with the
$\kappa$-adic version of the repeating part (Another direct manipulation)
- Increment the least significant digit in the expansion of 2 twice (Addition)
$$
4 = 2 + 2 = \frac{x^2}{1 + x} + 2 = \dots\bar{1}1\bar{1}102_x
4 = 2 + 2 = \frac{\kappa^2}{1 + \kappa} + 2 = \dots\bar{1}1\bar{1}102_{\kappa}
$$
- Add the expansion of 2 to itself (Multiplication)
$$
4 = 2 \cdot 2 = \frac{2x^2}{1 + x} = \dots\bar{2}2\bar{2}200_x
4 = 2 \cdot 2 = 2 \cdot \frac{\kappa^2}{1 + \kappa} = \dots\bar{2}2\bar{2}200_{\kappa}
$$
- Square the power series expansion of 2 (Exponentiation)
$$
\begin{gather*}
4 = 2^2 = \left(\frac{x^2}{1 + x}\right)^2 =
-x^4 \left(\frac{d}{dx}\frac{1}{1 + x}\right) = \dots\bar{4}3\bar{2}10000_x
4 = 2^2 = \left(\frac{\kappa^2}{1 + \kappa}\right)^2 =
-\kappa^4 \left(
\frac{d}{dx} \frac{1}{1 + x}
\right)_{x = \kappa}
= \dots\bar{4}3\bar{2}10000_{\kappa}
\end{gather*}
$$
If all of these series are expansions of 4, then they should produce the same string after applying the carry enough times. Fortunately, this seems to be the case, as this table demonstrates:
If all of these series are expansions of four, then they should produce the same string after
applying the carry enough times.
Fortunately, this seems to be the case, as this table demonstrates:
$$
\begin{array}{}
{x^2 \over 1 + x} + 2 &\phantom{00}&
{2x^2 \over 1 + x} &\phantom{00}&
\left({x^2 \over 1 + x}\right)^2 \\[10pt] \hline
{\kappa^2 \over 1 + \kappa} + 2 &\phantom{00}&
{2\kappa^2 \over 1 + \kappa} &\phantom{00}&
\left({\kappa^2 \over 1 + \kappa}\right)^2 \\[10pt] \hline
\vphantom{2^{2^{2^2}}}\dots\bar{1}1\bar{1}1\bar{1}102 \\[4pt]
\dots\bar{1}1\bar{1}1\bar{1}2\bar{2}0 \\[4pt]
\dots\bar{1}1\bar{1}1\bar{2}400 &&
@ -311,56 +502,221 @@ $$
\end{array}
$$
The rightmost series is the most resilient to the carry head growth, but this comes at the cost of not operating on a repeating series. In the range shown, all three columns converge to the same digit sequence, which truncated to 20 terms is:
The rightmost series is the most resilient to the carry head growth, but it comes at
the cost of not operating on a repeating series.
In the range shown, all three columns converge to the same digit sequence, which truncated to 20 terms is:
$$
4 = \bar{1}00000\bar{1}00001\bar{1}1010000_\kappa = \kappa^4 + \kappa^6 -\ \kappa^7 + \dots
4 = \dots \bar{1}00000\bar{1}00001\bar{1}1010000_\kappa = \kappa^4 + \kappa^6 -\ \kappa^7 + \dots
$$
Contrary to the sequence used to build it, this expansion appears to be nonrepeating. As of writing, there are [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) in the OEIS, even if the leading 0's are ignored. The Haskell used to generate each expansion above can be found [here](), and the first 8192 digits be found in a CSV [here]().
Contrary to the sequence used to build it, this expansion appears to be nonrepeating.
As of writing, there are
[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)
in the OEIS, even if the leading 0's are ignored.
The Haskell used to generate each expansion above can be found [here](./cendree.hs),
and the first 8192 digits be found in a CSV [here](./cendree_adic_4.csv).
### All Positive
If we are slightly greedier with the carry, we can clear it of all negative digits. The initial terms are the same, but diverge after the first $\bar{1}$ which appears in the sequence.
If we are slightly greedier with the carry, we can clear it of all negative digits.
For example,
$$
4 = \dots\kappa = \kappa^4 + \kappa^6 + \kappa^7 + \kappa^8 + \dots
\begin{align*}
4 &= \dots \bar{1}00000\bar{1}00001\bar{1}1010000_\kappa \\
&= \dots \bar{1}00000\bar{1}000\bar{1}311010000_\kappa \\
&= \dots \bar{1}00000\bar{1}001\bar{3}111010000_\kappa \\
&= \dots \bar{1}00000\bar{1}0\bar{2}51111010000_\kappa \\
&= \dots \bar{1}00000\bar{1}2\bar{6}11111010000_\kappa \\
&= \dots \bar{1}00000\bar{4}8011111010000_\kappa \\
&= \quad \vdots \\
&= \dots 0 11000 0 0011111010000_\kappa \\
&= \kappa^4 + \kappa^6 + \kappa^7 + \kappa^8 + \kappa^9 \dots
\end{align*}
$$
Again, it appears to be possible to achieve this sequence by applying the carry enough times, starting with any of the alternative expansions. A similar CSV containing 8192 terms is available [here]().
Again, it appears to be possible to achieve this sequence by applying the carry enough times,
starting with any of the alternative expansions.
A similar CSV containing 8192 terms is available [here](./cendree_adic_4_binary.csv).
This alternate expansion is somewhat confounding, since $\kappa$ is bounded above by the integer 3 and should therefore require three symbols in its alphabet. I can think of two explanations, and do not know whether either of them are correct:
This alternate expansion is somewhat confounding, since *κ* is bounded above by the
integer three and should therefore require three symbols in its alphabet.
I can think of two explanations, and do not know whether either of them are correct:
- The expansion is related to the conjugate root $\kappa^* = 1 -\ \sqrt 3 \approx -0.73205\dots$. The reciprocal of this number is less than two.
- The expansion is related to the conjugate root $\kappa^* = 1 -\ \sqrt 3 \approx -0.73205\dots$.
The reciprocal of this number is less than two.
- Because infinite precision is required, the minimal alphabet can become (possibly arbitrarily) small.
Four-ier Transforms
-------------------
Searching for Repetition
------------------------
The [discrete Fourier transform](https://en.wikipedia.org/wiki/Discrete_Fourier_transform) is an operation on regular samples of a function, or more generally, numeric sequences. It converts highly repetitive sequences to sequences with peaks. Since we're dealing with infinite expansions, we'll need to truncate at some point. If the period is very large, so must be the truncation.
The [discrete Fourier transform](https://en.wikipedia.org/wiki/Discrete_Fourier_transform)
is an operation on a discrete signal (i.e., a sequence of numbers).
It has the desirable property that it converts highly repetitive signals sequences into ones with peaks.
We can use this to assess whether an expansion repeats or not.
For example, the digits in the decimal expansion of 1/7 form the string "1, 4, 2, 8, 5, 7", repeating. The graph below is the plot of the DFT of the first 256 terms of the sequence. The clear peak between terms 42 and 43 is because the expansion repeats every 6 terms and $\frac{256}{43} < 6 < \frac{256}{42}$.
Since our expansions are infinite, we'll need to truncate them.
Unfortunately, this renders us unable to pick up on repetitions larger than a certain size.
In other words, to detect very large periods, we need to truncate our sequence to a large number of terms.
![]()
For example, the digits in the decimal expansion of 1/7 form the string "142857", repeating.
Truncating this sequence to 256 terms, we can plot its DFT:
If the $\kappa$-adic expansion of 4 is nonrepeating, then its DFT should not have any noticeable peaks. The DFT of the first 256 terms shows it to be very noisy.
```{python}
#| code-fold: true
![]()
from itertools import cycle, islice
from matplotlib import pyplot as plt
import numpy as np
There is a pronounced spike at the right edge of the graph (the Nyquist frequency), but it has a simple explanation: "1" appears only at even place values and "$\bar{1}$" at odd. At Nyquist, the DFT degenerates into an alternating sum, so its value is simply the number of nonzero digits. If we map the negatives out of the sequence, the peak is destroyed.
one_seventh = list(islice(cycle([1,4,2,8,5,7]), 256))
Even in the 8192-term truncation, there are no noticeable spikes in its DFT, lending further credence to its aperiodicity. Though I will not show it here, the same applies to the binary sequence shown previously.
plt.title("DFT of first 256 digits of decimal expansion of 1/7")
plt.plot(abs(np.fft.fft(one_seventh))[:129])
```
Much like the expansion of irrational numbers in integral bases, the balanced $\kappa$-adic expansion of 4 is(?) nonrepeating. This is surprising, especially since 4 has a terminating expansion in a non-balanced alphabet and a repeating expansion in a balanced one.
The clear peak near forty is because the expansion repeats every 6 terms and
$\frac{256}{43} < 6 < \frac{256}{42}$.
### Four-ier Transforms
If the $\kappa$-adic expansion of four is nonrepeating, then its DFT should not have any noticeable peaks.
```{python}
#| code-fold: true
import csv
with open("cendree_adic_4.csv") as f:
cendree_adic_4 = [int(i) for i in list(csv.reader(f))[0]]
plt.title("DFT of first 256 digits of $\\kappa$-adic expansion of 4")
plt.plot(abs(np.fft.fft(cendree_adic_4[:256]))[:129])
```
The DFT of the first 256 terms shows it to be very noisy.
There is a pronounced spike at the right edge of the graph (the Nyquist frequency),
but it has a simple explanation: $1$ appears only at even place values and $\bar{1}$ at odd.
At Nyquist, the DFT degenerates into an alternating sum, so its value is simply the number of nonzero digits.
If we map the negatives out of the sequence, the peak moves to the left edge (where the DFT degenerates into a sum).
```{python}
#| code-fold: true
plt.title("DFT of $4_{\\kappa}$ after mapping $\\bar{1}$ to $1$")
plt.plot(abs(np.fft.fft([abs(i) for i in cendree_adic_4[:256]]))[:129])
```
If you look closely, you'll notice that this plot is a mirror of the other.
### Longer Truncations
Even in the 8192-term truncation, there are no noticeable spikes in its DFT,
lending further credence to its aperiodicity.
If it feels like we're doing something wrong, we might also try the "all-positive" variant of the expansion.
Unfortunately, we're not so lucky.
Even then, we just end up with pure noise.
:::: {#long-trunc-figures .row layout-ncol="2"}
::: {.column width="40%"}
```{python}
#| code-fold: true
plt.title("DFT of first 8192 digits of $4_{\\kappa}$")
plt.plot(abs(np.fft.fft(cendree_adic_4))[:len(cendree_adic_4) // 2])
#
```
:::
::: {.column width="40%"}
```{python}
#| code-fold: true
# Alternatively, with the non-balanced expansion
with open("cendree_adic_4_binary.csv") as f:
cendree_adic_4_binary = [int(i) for i in list(csv.reader(f))[0]]
plt.title("DFT of first 8192 digits of $4_\\kappa$ (binary)")
plt.plot(abs(np.fft.fft(cendree_adic_4_binary))[1:len(cendree_adic_4_binary) // 2])
```
:::
::::
Much like the expansion of irrational numbers in integral bases, the balanced
*κ*-adic expansion of four seems to be nonrepeating.
This is surprising, considering four is an integer, and especially since its expansion terminates
in a normal alphabet and repeats in a balaced alphabet.
Closing
-------
This concludes the discussion of $\kappa$-adic numbers. The [next post]() will return to integral sequences, and the patterns produced from their "erroneousness" as an actual base.
This concludes the discussion of base *κ* and the *κ*-adics.
Remember, we only bothered investigating *κ*-adic expansions for the number four.
Greater integers suffer the same issues, and other bases are certainly possible.
Hopefully, four provides an illuminating enough example of the general chaos induced by irrational bases.
Update: I am unsure whether $\kappa$'s proximity to e produces some of these effects, or if it is somehow more ideal than other roots whose repeating fraction expansion is $[n; \underline{1, n}]$ (for integral n). It is easy to see that repeating expressions like $n = 10.\bar{n} = 1\bar{1}.\underline{1\bar{1}}$ will occur in each of these, but $\kappa$ still bears the distinction of needing only $0.1\bar{1}$ as a repeating element for integers.
The [next post](../5) will return to integral sequences, and the patterns produced from their
"erroneousness" as an actual base.
Base *e*, while it lacks an explicit carry, has the lowest [radix economy](https://en.wikipedia.org/wiki/Radix_economy), meaning it takes the fewest digits to express a number with respect to the size of its minimal alphabet. I would be interested to know if other monic polynomials whose root is approximately e share some of $\kappa$'s strange properties.
[^1]:
<details>
<summary>
Proof sketch that base *κ* expansions of integers above three end in "2"
</summary>
Recall that $3 = 10.02_{\kappa}$ and $4 = 11.02_{\kappa}$.
We can add two expansion together to produce a new valid expansion.
Hence,
:::: {.row layout-ncol="2"}
::: {.column width="40%"}
$$
\begin{align*}
8 &= 4 + 4
= 11.02_{\kappa} + 11.02_{\kappa} \\
&= \textcolor{red}{22}.04_{\kappa}
= \textcolor{red}{1}00.0\textcolor{blue}{4}_{\kappa}
= 100.\textcolor{blue}{1102}_{\kappa}
\end{align*}
$$
:::
::: {.column width="40%"}
$$
\begin{align*}
11_{10} &= 8 + 3
= 100.1102_{\kappa} + 10.02_{\kappa} \\
&= 110.1\textcolor{red}{3}02_{\kappa}
= 110.\textcolor{red}{2004}_{\kappa} \\
&= 110.200\textcolor{blue}{4}_{\kappa}
= 110.20\textcolor{blue}{1102}_{\kappa}
\end{align*}
$$
:::
::::
From these examples, we see that adding small numbers like three will, at most,
produce a "3" or "4" in the negative second place value.
If there is a "2" in the negative first place value, then expanding "3" or "4" in the negative
second will give a "3" there, which is troublesome.
But we got in this position by adding three; by adding two first, we can apply the carry
across the zeroth and negative first place values instead, which produces
at most a "3" in the first place value.
Expanding "3" at this place value places a "2" back in the negative first place value,
and we don't have to worry about modifying digits in other negative place values.
If there is *not* a "2" in the negative first place value, then expanding the "3" or "4"
in the negative second place value pushes a "2" into the negative fourth place value.
From here "2" is either in the terminal position, or causes another expansion of "3" or "4".
In the latter cases, we recurse, eventually pushing a "2" into a negative even place value in terminal position.
</details>