---
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;
  }

  /* #long-trunc-figures .figure-img { */
  .figure-img {
    max-width: 512px;
    object-fit: contain;
    height: 100%;
  }
</style>

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.


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.

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}]
\end{gather*}
$$

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| ~~\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}]
\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.


### 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
$$

:::: {.row .text-center}
::: {#canonical-cendree-table .column width="60%"}

| *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
------------------

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.

$$
0\textcolor{red}{11} = \textcolor{red}{1}\bar{1}\bar{1}
$$

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} + \dots
  = \frac{1}{1 - (1/x)}
  = \frac{x}{x - 1}
  \\
  1.\underline{\bar{1}1}_x
  = 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 \iff \langle 2, 2 |
\end{gather*}
$$
:::

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

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".

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]).

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.


:::: {.row .text-center}
::: {#canonical-balanced-cendree-table .column width="100%"}

<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{
      \underline{\textcolor{blue}{69}}_{10}
    }_{\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
  = \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).
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}_p}{11_p}
  & \substack{
    \phantom{11}{\underline{\phantom{)1}1\bar{1}}} \\[3pt]
    11)10\bar{1} \\
    \phantom{11)}\underline{11} \phantom{0} \\[3pt]
    \phantom{11)1}{\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}_p}{11_p}
  & \substack{
    \phantom{11}{\underline{\phantom{)1}1\bar{1}1\bar{1}}} \\[3pt]
    11)1000\bar{1} \\
    \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} \\[3pt]
    \phantom{11)10}10 \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}} \\[3pt]
    \phantom{11)100} 00 \\
  }
\end{align*}
$$

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.\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.
We might also remember what [we did earlier with geometric series](#geometric-series-2) and just do

$$
\begin{align*}
  \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
  ~=~ \dots\bar{1}1\bar{1}100_\kappa \\
\end{align*}
$$

We can check this expansion by power series manipulations:

$$
\begin{align*}
  2 = \dots\bar{1}1\bar{1}100_\kappa
    &=\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} \\[8pt]
  {2\kappa + 2}
    &= \kappa^2
\end{align*}
$$

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 have a necessarily limited view,
  which we can at best combat by marking repeating sections.

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:

$$
\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 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, 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, 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)

- Increment the least significant digit in the expansion of 2 twice (Addition)
  $$
  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 = 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{\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 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}{}
  {\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 &&
  \dots\bar{2}2\bar{2}2\bar{2}200 \\[4pt]
  \dots\bar{1}1\bar{1}3\bar{6}000 &&
  \dots\bar{2}2\bar{2}3\bar{4}000 \\[4pt]
  \dots\bar{1}1\bar{4}90000 &&
  \dots\bar{2}2\bar{4}70000 \\[4pt]
  \dots\bar{1}5\bar{\text C}10000 &&
  \dots\bar{1}5\bar{\text A}10000 &&
  \dots\bar{4}3\bar{2}10000 \\[4pt]
  \dots\bar{7}{\text H}010000 &&
  \dots\bar{6}\text F010000 &&
  \dots\bar{5}5010000 \\[4pt]
  \dots\bar{\text N}1010000 &&
  \dots\bar{\text L}1010000 &&
  \dots\bar{9}1010000 \\[4pt]
  \textcolor{green}{\dots\bar{1}1010000} &&
  \textcolor{green}{\dots\bar{1}1010000} &&
  \textcolor{green}{\dots\bar{1}1010000}
\end{array}
$$

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 = \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](./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.
For example,

$$
\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](./cendree_adic_4_binary.csv).

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.
- Because infinite precision is required, the minimal alphabet can become (possibly arbitrarily) small.


Searching for Repetition
------------------------

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.

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:

```{python}
#| code-fold: true

from itertools import cycle, islice
from matplotlib import pyplot as plt
import numpy as np

one_seventh = list(islice(cycle([1,4,2,8,5,7]), 256))

plt.title("DFT of first 256 digits of decimal expansion of 1/7")
plt.plot(abs(np.fft.fft(one_seventh))[:129])
```

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 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.

The [next post](../5) will return to integral sequences, and the patterns produced from their
  "erroneousness" as an actual base.

[^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>
