---
format:
  html:
    html-math-method: katex
---


Counting in 2D: Reorienting Polynomials
=======================================

[Previously](), I explored some very basic 2D counting systems, inspired by sandpiles. As the name suggests, these planar numbers require a discrete grid of numbers to contain them. What follows is a deeper investigation into this natural extension of positional systems.


Direction of Propagation
------------------------

Given a carry (expressed as a polynomial in two variables or a grid) and an increasing sequence of integers, the expansions of the sequence will appear to propagate in a certain direction. Consider that from the last post, it is known that $x + y = 2$ and a certain case of the Folium of Descartes will make the same pattern:

$$
\begin{gather*}
& ~ & \text{Folium}\\
2 - x - y & ~ &
2xy - x^3 - y^3 \\
\begin{array}{|c} \hline
2 & \bar{1} \\ \bar{1}
\end{array} & ~ &
\begin{array}{|c} \hline
0 & 0 & 0 & \bar{1} \\
0 & 2 \\ 0 \\ \bar{1}
\end{array}
\end{gather*}
$$

Connecting a vector that extends from the largest digit (hereafter pseudo-base) to every other digit in the carry, it is clear that the carry can extend only in a linear combination of these directions. However, they cannot propagate in the reverse direction, as there is no sense of "backwards".

$$
\begin{gather*}
\begin{array}{|c} \hline
2 & \bar{1} \vphantom{2^{2^2}} \\ \bar{1}
\end{array} & ~ &
\begin{array}{|c} \hline
0 & 0 & 0 & \bar{1} \vphantom{2^{2^2}} \\
0 & 2 \\ 0 \\ \bar{1}
\end{array} \\
\begin{matrix}
\langle 1, 0 \rangle \\
\langle 0, 1 \rangle
\end{matrix}
& ~ &
\begin{matrix}
\langle 2, -1 \rangle \\
\langle -1, 2 \rangle
\end{matrix}
\end{gather*}
$$


### Balancing Act

We can naively "balance" the carry by adding additional carry digits at the additive inverses of these vectors and doubling the pseudo-base. Equivalently, this adds to the original carry the polynomial obtained by reflecting these points in the pseudo-base. If we balance the left carry, it yields the Laplacian. But what about the right? Unsurprisingly, it just stretches the expansions along the different "base" vectors.

:::{.column width="40%"}
$$
4 x^{2} y^{2} - x^{4} y - x^{3} - x y^{4} - y^{3} \\
\begin{array}{|c} \hline
0 & 0 & 0 & \textcolor{red}{\bar{1}} \vphantom{2^{2^2}} \\
0 & 0 & 0 & 0 & \textcolor{blue}{\bar{1}} \\
0 & 0 & 4 & 0 \\
\textcolor{blue}{\bar{1}} & 0 & 0 \\ & \textcolor{red}{\bar{1}}
\end{array} \\
\text{Added Vectors:} \\
\begin{matrix}
\textcolor{blue}{
\langle -2, 1 \rangle} \\
\textcolor{red}{
\langle 1, -2 \rangle
}
\end{matrix}
$$
:::

:::{.column width="40%"}
![]()
:::


### Half-Balanced

The Laplacian carry is remarkably balanced, but it provokes the question of what the expansions look like if there are only 3 directions to propagate. The intuition from above says that it should span a half-plane, up from the quarter-plane that $x + y = 2$ spans.

:::{.column width="40%"}
$$
3 x - xy - x^2 - 1 \\
\begin{array}{|c} \hline
\textcolor{red}{\bar{1}} \vphantom{2^{2^2}}& 3 & \textcolor{red}{\bar{1}} \\
0 & \bar{1} & 0
\end{array} \\
\text{Added Vector:} \\
\begin{matrix}
\textcolor{red}{
\langle -1, 0 \rangle
}
\end{matrix}
$$
:::

:::{.column width="40%"}
:::

Fortunately, this is the case.


### 2D Carry Types

Based on the extent of the vectors, in general there appear to be four possibilities:

1. The degenerate one-dimensional case
    - The carry is equivalent to the product of a polynomial in a single variable and any power *x* and/or *y*.
2. Quarter-planes, like $x + y = 2$
    - Arises when the inverses of the vectors are inaccessible.
3. Half-planes, like the above altered Laplacian
    - Arises when two vectors are collinear and point in opposite directions, but every other vector is either on one side of this line or are also collinear.
4. Full-planes, like the Laplacian
    - Arises when the inverses of both vectors are accessible.

Quarter-plane is a bit of a misnomer. Technically, the fraction of the plane spanned is between 0 and 1/2 noninclusive (as these bounds correspond to the previous and next cases respectively). For example, $x + y = 2$ certainly expands to the entire quarter-plane, as the first row/column, which contain binary expansions, are unbounded. However, the Folium encompasses slightly more of the plane, or...

$$
\frac{1}{2\pi}\arccos \left (
\frac{\langle 2, -1 \rangle \cdot \langle -1, 2 \rangle}
{\| \langle 2, -1 \rangle \| \| \langle -1, 2 \rangle \|} \right)
= \frac{1}{2\pi} \arccos \left ( -\frac 4 5 \right )
\approx 0.397584
$$

about 40% of the plane. This is still smaller than the half-plane case.

With these categories in mind, I would now like to shift focus. All systems discussed thus far have been explicit and irreducible, meaning they are not derived from any "simpler" implicit rules. Do such rules exist, and cam we find any?


Hunting for Implicitness
------------------------

I mentioned previously how one might go about producing these carries. The gist is to form an explicit carry from the product of some input polynomial and cyclotomic polynomials in x and y. However, I would like to leverage the visual representation used previously, since working with coefficients is linear, unintuitive, and most importantly, annoying.

![]()

Above is my (admittedly low-effort) attempt to ameliorate these shortcomings (downloadable [here]()). The left image is clickable, with the coefficients incrementing with left clicks and decrementing with right. The text box controls the second multiplicand in the center image by selecting a cyclotomic polynomial and evaluating it with a particular expression. The right image is the product.

It could obviously be improved by showing the coefficients in the picture and using color to only indicate sign. However, there is a benefit to hiding coefficients behind solid colors. For instance, I don't need to recognize numerals to pinpoint what the product should look like.


### Degenerate Expressions

I have chosen to evaluate the right term (center image) at *x* + *y* for a reason. Choosing *x* or *y* on their own is a poor decision because they change nothing from the one dimensional case. Put another way, when arranged in a grid, the coefficients are all collinear. At first blush, *xy* seems like a decent pick, but it has the exact same problem; the line simply extends along the diagonal instead. The opposite case $\frac x y$ might not make sense, but the denominators can be cleared by multiplying by the appropriate power of *y*. However, this makes the polynomial homogeneous, or in other words, collinear along the anti-diagonals, and has the exact same problem as the product.

![]()

It should go without saying that these are all degenerate, and can only span a line. On the other hand, expressions like the sum of *x* and *y* form triangles, 2D shapes from which it is possible to build our goal polynomial. Since *x* + *y* is symmetric in *x* and *y*, it is expected that the products have a similar sense of symmetry.


First Results
-------------

![]()

The first explicit product I found is above, which is reminiscent of the Folium of Descartes. The implicit carry (the left multiplicand) describes the rearrangement of coefficients in a backwards L-shape to and from a sparser upside-down L-shape. The property of passing through (1, 1) comes from this factor; this also illustrates that unlike polynomials in a single variable, the sum of the coefficients being zero does not imply the existence of a one-variable factor like *x* - 1.

$$
\begin{gather*}
\text{Folium} & ~ & \text{New carry} \\
2xy - x^3 - y^3 & ~ &
3xy - x^3 - y^3 - 1 \\
\begin{array}{|c} \hline
0 & 0 & 0 & \bar{1} \\
0 & 2 \\ 0 \\ \bar{1}
\end{array} & ~ &
\begin{array}{|c} \hline
\bar{1} & 0 & 0 & \bar{1} \\
0 & 3 \\ 0 \\ \bar{1}
\end{array}
\end{gather*}
$$


### Cousin Systems

My first thought upon seeing this carry was to see what makes counting in this system different from "neighbors", by which I mean moving the $x^3$ and $y^3$ terms further inward and outward.

$$
\begin{gather*}
3xy - x - y - 1 &
3xy - x^2 - y^2 - 1 \\
\begin{array}{|c} \hline
\bar{1} & \bar{1}  \vphantom{2^{2^2}} \\
\bar{1} & 3 \\
\end{array} &
\begin{array}{|c} \hline
\bar{1} & 0 & \bar{1} \vphantom{2^{2^2}} \\
0 & 3 \\ \bar{1}
\end{array} \\
\textcolor{red} {3xy - x^3 - y^3 - 1} &
3xy - x^4 - y^4 - 1 \\
\textcolor{red} { \begin{array}{|c} \hline
\bar{1} & 0 & 0 & \bar{1} \vphantom{2^{2^2}} \\
0 & 3 \\ 0 \\ \bar{1}
\end{array} } &
\begin{array}{|c} \hline
\bar{1} & 0 & 0 & 0 & \bar{1} \vphantom{2^{2^2}} \\
0 & 3 \\ 0 \\ 0 \\ \bar{1}
\end{array}
\end{gather*}
$$

All polynomials besides the one under consideration (highlighted in red) are irreducible. This means that these carries hide no implicit rules, and are as fundamental as the Laplacian or $x + y = 2$.

Analyzing the carry vectors, it is clear that the pattern produced by each should be different:

$$
\begin{gather*}
3xy - x - y - 1 &
3xy - x^2 - y^2 - 1 \\
\begin{matrix}
\langle -1, 0 \rangle \\
\langle -1, -1 \rangle \\
\langle 0, -1 \rangle
\end{matrix} &
\begin{matrix}
\langle -1, 1 \rangle \\
\langle -1, -1 \rangle \\
\langle 1, -1 \rangle
\end{matrix} \\
3xy - x^3 - y^3 - 1 &
3xy - x^4 - y^4 - 1 \\
\begin{matrix}
\langle -1, 2 \rangle \\
\langle -1, -1 \rangle \\
\langle 2, -1 \rangle
\end{matrix} &
\begin{matrix}
\langle -1, 3 \rangle \\
\langle -1, -1 \rangle \\
\langle 3, -1 \rangle
\end{matrix} \\
\end{gather*}
$$

The top-left tends toward a similar shape as the $x + y = 2$ case, since we can't reach the vector inverses. In the top-right carry, all vectors are equidistant and meet at right (and straight) angles. This means that it is a 45° rotation of the altered Laplacian, which spans a half-plane. The remaining two should both propagate into the full plane. Is this reflected in the counting videos?

:::{}
Counting in each of the $\ldots - x^n - y^n + \ldots$ systems
:::

Indeed it is. The first two propagate toward the upper-left, and the remaining two span the entire plane. However, while the discovered carry remarkably remains centered, the final one tends more toward propagating to the lower right. It has somehow exceeded a threshold  that the centered one has not.

Notably, the L-shapes (which I noted can be interchanged) never turn up, and the "initial rule" is useless. Phinary, the simplest implicit case in one dimension, still requires the initial rule to go from the expansion of 2 (10.01) to 3 (100.01).


Isosceles Rotations
-------------------

Since one of the similar carries produces a rotation of a familiar pattern, it provokes additional questions, such as if we can rotate the centered pattern. If so, is its polynomial also factorable? Naively, the following carry might look similar...

:::{.column width="40%"}
$$
\begin{array}{|c} \hline
& & \textcolor{red}{\bar{1}} \\
& & 3 \\ \textcolor{green}{\bar{1}}
&&& & \textcolor{blue}{\bar{1}}
\end{array} \\
\begin{matrix}
\textcolor{red}{\langle 0,1 \rangle} \\
\textcolor{green}{\langle -2,-1 \rangle} \\
\textcolor{blue}{\langle 2,-1 \rangle} \\
\text{Angle to top} \approx 116°
\end{matrix}
$$
:::

:::{.column width="40%"}
:::

There are only even numbers in the first component, so we can describe the carry more succinctly as...

:::{.column width="40%"}
$$
\begin{array}{|c} \hline
& \textcolor{red}{\bar{1}} \\
& 3 \\ \textcolor{green}{\bar{1}}
&& \textcolor{blue}{\bar{1}}
\end{array} \\
\begin{matrix}
\textcolor{red}{\langle 0,1 \rangle} \\
\textcolor{green}{\langle -1,-1 \rangle} \\
\textcolor{blue}{\langle 1,-1 \rangle} \\
\text{Angle to top} = 135°
\end{matrix}
$$
:::

:::{.column width="40%"}
:::

Though both of these videos are the same, neither are similar to the original. For comparison, the largest angle in the nonrotated triangle is ~108°. In fact, the shape is much closer to the similar orientation with $\ldots - x^4 - y^4 + \ldots$ terms.


### Checking Magnitudes

Measuring these quantities as angles is a bit of a lie. More fundamentally, two of the vectors have equal magnitude, and the ratio between they and the final vector's magnitude is irrational. This means that the unequal lengths are incommensurable. Importantly though, they way in which they are incommensurable is different for each polynomial.

$$
\textcolor{red}{
\frac{m_1}{n_1} =
\frac{\| \langle 2, -1 \rangle \|}{\| \langle -1, -1 \rangle \|} =
\frac{\sqrt 5}{\sqrt 2} =
\frac{\sqrt {10}}{2}
}
\\
\frac{m_2}{n_2} =
\frac{\| \langle -2, -1 \rangle \|}{\| \langle 0, -1 \rangle \|} =
\frac{\sqrt 5}{1} =
\sqrt 5
\\
\frac{m_3}{n_3} =
\frac{\| \langle -1, -1 \rangle \|}{\| \langle 0, -1 \rangle \|} =
\frac{\sqrt 2}{1} =
\sqrt 2
$$

Obviously, one cannot express $\sqrt 10$ from only one of $\sqrt 2$ or $\sqrt 5$. Fortunately, this suggests the rotation:

:::{.column width="40%"}
$$
\begin{array}{|c} \hline
& \textcolor{red}{\bar{1}} \\
& 3 \\ \textcolor{green}{\bar{1}}
&& \textcolor{blue}{\bar{1}}
\end{array} \\
\begin{matrix}
\textcolor{red}{\langle 0,1 \rangle} \\
\textcolor{green}{\langle -1,-1 \rangle} \\
\textcolor{blue}{\langle 1,-1 \rangle} \\
\text{Angle to top} = 135°
\end{matrix}
$$
:::

:::{.column width="40%"}
:::

The counting video looks very promising, but can the polynomial factorized? Indeed it can, since all the vectors are in least terms and are incommensurable in the same way.

$$
\begin{gather*}
3 x^{3} y^{2} - x^{6} y^{3} - x^{3} - y^{3} &=&
(- x^{4} y^{2} + x^{3} y + x^{2} y^{2} - x^{2} + x y - y^{2}) \\
&& (x^2 y + x + y ) \\
\begin{array}{|c} \hline
&&& \bar{1} \\ \\
&&& 3 \\ \bar{1}
&&&&&& \bar{1}
\end{array} &=&
\begin{array}{|c} \hline
& & \bar{1} & \\
& 1 & & 1 & \\
\bar{1} & & 1 & & \bar{1} \\
\end{array} ~~\cdot~~
\begin{array}{|c} \hline
& 1 & \\ 1 & & 1
\end{array} \\
&&(x y^{2} + x + y ) = \Phi_2 \left ( \frac{y}{x} + xy \right ) x
\end{gather*}
$$

As noted, the the rightmost polynomial can be expressed from $\Phi_2$.

All powers of *x* in the product are multiples of 3. We can divide these out to produce a similar carry, as we did before. Doing so preserves the shape of counting, but destroys the factorization, as the result is irreducible.

:::{.column width="40%"}
$$
\begin{array}{|c} \hline
& \textcolor{red}{\bar{1}} & \\ \\
& 3 & \\
\textcolor{green}{\bar{1}} & & \textcolor{blue}{\bar{1}}
\end{array} ~~
\begin{matrix}
\textcolor{red}{\langle 0,2 \rangle} \\
\textcolor{green}{\langle -1,-1 \rangle} \\
\textcolor{blue}{\langle 1,-1 \rangle} \\
\end{matrix} \\
\frac{| \langle -1, -1 \rangle |}{| \langle 0,2 \rangle |}
= \frac{\sqrt 2}{2}
$$
:::

:::{.column width="40%"}
:::

All of these similar systems is share something in common: the pseudo-base is located at the centroid of the triangle formed by the remaining digits. This is most obvious from the fact that the sum of all three vectors equals $\vec 0$ in all three cases. The "threshold we exceeded" when comparing its neighbors was the centroid transitioning between being closer to the upper point or the lower two points.

The position of the centroid is unchanged so long as the lower two points have the same midpoint as above. Therefore, all such barycentric carries share this similar pattern.


Closing
-------

Since the pseudo-base will be positioned at the one's place to start, it makes sense to consider the vectors that stretch from it to the "spread" digits. If the carry is reducible, then preserving the ratios of the lengths of the vectors appears to preserve the reducibility of the polynomial (and obviously, the counting system). However, further compacting the counting system by dividing components by a common factor tends to destroy reducibility.

Two questions that immediately come to mind are:

- Not all integers can be written as the sum of two squares. Are there any (reducible) polynomials which have no rotation other than by swapping components and orientation?
  - The [Brahmagupta-Fibonacci](https://en.wikipedia.org/wiki/Brahmagupta%E2%80%93Fibonacci_identity) identity implies that such numbers are closed under multiplication. This means that it is always possible to reorient the triangle in the method shown above.
- After compacting the counting system, can reducibility be recovered for other scaling factors than the one started with? What about from an irrational scaling (as by a rotation)?
  - I am not equipped to answer this.

It is very pleasing that the exponents of polynomials should correlate so well to the components of vectors. The primary geometrical approach to such objects is to plot all points which (at least approximately) satisfy the root, but basic coordinate geometry exists without needing to define evaluation. All at once, geometry, linear algebra, and polynomial number theory play a role in the story of these bizarre fractal patterns.
