**Update $(2020)$**

I've observed a possible characterization and a possible parametrization of the pattern, and I've additionally rewritten the entire post with more details and better definitions.

It remains to prove the observed possible characterization, and then complete it by finding the sequences for locations of the "parabolic shapes" that live in the characterized regions.

**Table of contents:**

**Visualization of factorizations****Inside prime visualizations****The pattern and the question****Pattern parametrization**

## Visualization of factorizations

Here I will explain how we can visualize positive integers in an interesting way which also has the property that the factorization of $n$ is encoded into it in the form of a fractal-like pattern.

**$2$-digit palindromes represent factorizations**

We say that a positive integer is palindromic in some integer number base (*number-system*) $b\ge 2$ if when written in that number base, its digits are read the same forward and backwards.

The $2$-digit palindrome is an integer $n=(a,a)_b=ab^1+ab^0=a(b+1),a\lt b,a\ge 1$, where in the $(n_1,n_2,\dots)_b$ notation, $n_1,n_2,\dots$ stand for digits of $n$ in the integer base $b\ge 2$.

Factorizations of positive integers $n$ are related to $2$-digit palindromes. That is, if $n$ can be factorized as $n=p\cdot q$ where $p\lt q-1$, this means that $n$ is a $2$-digit palindrome in the number base $q-1$, which we write as:

$$ n=p q=p(q-1)+p=(p, p)_{q-1}, p<q-1, $$

where $(p,p)$ are digits of $n=pq$ in the number base $q-1$.

**Representing $n\in\mathbb N$ as a sum of $n\times n$ images (matrices)**

First we define a "matrix of point", then we define the "sum" of these matrices.

Let $x_0,y_0$ be nonnegative integers. Let $P_n(x_0,y_0)$ be a $n$ by $n$ matrix "of point $(x_0,y_0)$" whose top left entry is denoted with $P_n(x_0,y_0)(0,0)$ and whose bottom right entry is denoted with $P_n(x_0,y_0)(n-1,n-1)$. It is defined for $x,y\in[0,n)$ as:

$$ P_n(x_0,y_0)(x,y)= \begin{cases} 1, & \text{if }x+nx_0\text{ is a two digit palindrome in base }y+ny_0\\ 0, & \text{else} \end{cases} $$

We can visualize these "point" matrices as images by coloring different entries with different colors. For example, "$P_{100}(x_0,y_0)$"'s for $(x_0,x_0)=(0,0),(1,0),(2,0),(3,0)$ are:

Where the green pixels represent the matrix entries that are $1$.

Notice that $P_n(x_0,y_0)$ in point $(x_0,y_0)=(0,0)$ contains "dotted lines" $L_t$ of points from

$$\{(t^2-1+(t-1)r,t+r),t\ge 2, r\ge 0\}$$

and that if we look at $P_n(x_0,y_0)$ in some other point, we get continuations of these lines.

**Visualization of the "image of $n$" matrix**

We define $N_n(y_0)=\sum\limits_{k=0}^{\infty} P_n(k,y_0)$ as "entry-wise sum of $P_n$'s along the $x$-axis at level $y_0$". Notice that this sum always sums finitely many matrices because for large enough $k=x_0$, all entries of the matrix are $0$.

To visualize $N_n(y_0)$ we will color all $0$ entries white, and all other entries blue. This visualization remains the same for all $y_0\ge 1$ except in the top left entry which is zero only for $y_0=1$. If we choose $y_0=0$, then the visualization is "degenerated".

This motivates us to write $N_n=f(N_n(1))$ and call $N_n$ the "image of $n$", where $f$ returns the same matrix but all nonzero entries are set to "blue" and all zero entries are set to "white".

For example, below is the image showing the $N_n$'s for $n=7,\dots,31$. Notice that the **prime numbers** are solid blue squares with no additional details, and that other numbers have visualizations that correspond to their factorizations.

**Patterns in $N_n$ based on factorizations of $n$**

For example, notice that even semi-primes $n=2p$ where $p$ is prime, all have the following look:

Or for example, notice that squares of primes $n=p^2$ have the least details:

On the other hand, numbers with a lot of factors such as factorials like $4!=2\cdot3\cdot4 = 24$ or primorials like $p_3\#=2\cdot 3\cdot 5 = 30$ have much more details (factors), and numbers such as powers of primes like $27=3^3$ and $32=2^5$ have regular fractal-like patterns.

One might ask if we can for $n$ in general compute the matrix $N_n$ more efficiently than calculating and summing up all those $P_n$'s. That is, is there an efficient test to get a $N_n(x,y)$ entry directly? $-$ *This question does not need to be answered, it's just my thought on the current chapter.*

## Inside prime visualizations

The $N_p$ where $p$ is a prime number resembles a solid blue square and looks boring. But, we can **"look inside"** this solid blue square by replacing our $f$ function.

Recall that we are WLOG observing $y_0=1$ because all $y_0\ge 1$ yield equivalent images.

**"Heat-image" matrix of prime number $p$**

We will write $\overline{N}_p=h(N_p(1))$ and call $\overline{N}_p$ the "heat-image of prime $p$", where $h$ assigns distinct colors to distinct values of entries of $N_p(1)$ and returns such matrix. Let the zero value be "black", the smallest nonzero value be "red" and the second-smallest nonzero value be "yellow". Other values can be "white" or represented in shades of "grey".

For example, here are $\overline{N}_p$'s of primes $p=101,103,109$:

At first glance these appear to be different sizes of the same image, but this is not the case.

Within different $M_p$'s we find different patterns in certain regions of the image. Thanks to Hyperplane's comment, we can "enhance" these regions by removing the needless details.

That is, if we ignore the last row then these $\overline{N}_p$'s appear to be symmetric along the central horizontal line. In other words, if an entry $(x,y)$ is red then the mirrored entry $(x,|p-y-2|)$ is yellow, and vice versa. However, this is not true for all entries.

This motivates us to observe the "non-mirrored" entries, and set the other ones to $0$.

**The pattern inside prime number $p$**

We will observe the irregularities in the "heat-image". That is, we define a new matrix $M_p$:

$$ M_p(x,y)= \begin{cases} 1, & \text{if }N_p(1)(x,y) = N_p(1)(x,|p-y-2|)\\ 0, & \text{else} \end{cases} $$

We will represent these entries by coloring $1$'s and $0$'s with white and black, respectively.

For example, here are $M_p$'s of primes $p=101,103,109$:

Observe the white pixels near the central horizontal line. Notice that there we can distinguish between a "thick dotted parabola" and a "thin dotted parabola".

For example, zooming into the central horizontal line of $109$ shows

that the "thick dotted parabola" one is on the left side, and that the "thin dotted parabola" one is on the right side. It is the same for the prime $101$, but not for the prime $103$ which has it the other way around.

It turns out that primes of the form $p=4k+1$ are "left-handed" (have the "thick" parabola on the left side) and that the primes of the form $p=4k-1$ are "right-handed" (have the "thick" parabola on the right side).

It also turns out that these are not the only "parabolic" groups of pixels that exist. I've tried tracing the prime $p=101$ from different groups of pixels and found a set of three distinct parabolas. Observe the last (fourth) image below.

These have one of the following "shapes" of pixels at their "head":

- The first ("green parabola") has $I_{2}$ - "I shape of height of 2 pixels"
- The second ("blue parabola") has $J_{2,1}$ - "J shape of height of $2+1$ pixels"
- The third ("red parabola") has $I_{3}$ - "I shape of height of $3$ pixels"

Note that these "shapes" are mirrored below/above the central horizontal line.

All $6$ permutations of these "shapes" can appear in some prime number $p$ (in some $M_p$). Depending on the permutation that appears in the image (the matrix), we can determine if the prime number is of form $p=18k+m$ where $m\in\{-1,1,5,7,11,13\}$.

For example, all primes of the form $p=18k+11$ have the same $(I_{2},J_{2,1},I_{3})$ permutation of these parabolic patterns as the prime $101=18\cdot 5+11$, in that region of $M_p$.

The larger the prime $p$, the more of these regions we can find.

For example, in primes as large as $p=997$ I've highlighted four of these regions. Some regions repeat multiple times. For example, notice that there are four instances of the yellow region highlighted.

If the picture above isn't clear, we can alternatively color (highlight) the regions by connecting the pixels (entries) that represent ("belong to") corresponding "parabolic" shapes:

In every region $R$, we can observe a set of "parabolic" shapes. Different permutations of those shapes will appear in different primes $p$ (in different $M_p$'s), depending on the remainder $m$ from division of $p$ by some constant $c_R$.

The question is now, can we characterize every such region and its shapes?

## The pattern and the question

I think I'm having a hard time characterizing all these regions, because I'm actually not sure how to properly define them.

Essentially, it appears $M_p$ contains "regions $R_s$" and within those regions we can find one of the possible permutations $P=(p^{(s)}_1,p^{(s)}_2,\dots,p^{(s)}_s)$ of $s$ "parabolic shapes".

It seems that region $R_s$ contains some permutation $P_m$ if and only if $p\equiv m\pmod{c_s}$ where $c_s$ is some constant related to the $s$th region.

Question. $1.$Can we characterize all regions $R_s$ and their $P_m$'s and $c_s$ ?

The "pattern inside a prime $p$" would be the collection of all regions $R_s$ of the matrix $M_p$.

Note that this is related to Moiré pattern's, as this user pointed out.

*Below are the regions I've observed so far.*

**Characterization of regions $R_s$ for small $s$**

I will be using $P=(1,2,\dots,s)$ as a shortened notation for $P=(p^{(s)}_1,p^{(s)}_2,\dots,p^{(s)}_s)$. Also, the interpretation of this notation is that $p^{(s)}_1$ is in the leftmost part of the region, and that $p^{(s)}_s$ is in the rightmost part of the region.

$$ (s=1) $$

In every $M_p$, if you look either at the very top or at the very bottom, you will find the same "half-parabola" shape $p^{(1)}_1$. This gives the trivial region:

$$ R_1 : P=(1) \iff p \equiv 1\pmod{2} $$

That is, there is only one possible permutation within $R_1$, and every prime $p$ has it.

$$ (s=2) $$

Given a $M_p$ and looking around the central horizontal line we can find $2$ distinct parabolic shapes. These are the "thick parabola" $p^{(2)}_1$ and the "thin parabola" $p^{(2)}_2$. I've observed that:

$$\begin{align} R_2 : P=(1,2) &\iff p \equiv 1\pmod{4} \\ R_2 : P=(2,1) &\iff p \equiv 3\pmod{4} \\ \end{align}$$

This region splits the primes into two sets.

$$ (s=3) $$

In the previous chapter we've observed $R_3$ to contain parabolic shapes characterized by a "short I shape" = $p^{(3)}_1$, a "long I shape" = $p^{(3)}_2$ and a "J shape" = $p^{(3)}_3$. It appears that:

$$\begin{align} R_3 : P=(1,2,3) &\iff p \equiv 1\pmod{18} \\ R_3 : P=(2,1,3) &\iff p \equiv 5\pmod{18} \\ R_3 : P=(2,3,1) &\iff p \equiv 7\pmod{18} \\ R_3 : P=(1,3,2) &\iff p \equiv 11\pmod{18} \\ R_3 : P=(3,1,2) &\iff p \equiv 13\pmod{18} \\ R_3 : P=(3,2,1) &\iff p \equiv 17\pmod{18} \\ \end{align}$$

This region splits the primes into six sets. Unlike $R_2$ that appears only once, this $R_3$ region appears twice in the image: above and (mirrored) below the central horizontal line.

$$ (s=4) $$

The region $R_4$ is similar to $R_3$ but of course has more permutations. This region contains parabolic shapes characterized by following shapes (groups of pixels): "3 long pixels" = $p^{(4)}_1$, "2 short pixels" = $p^{(4)}_2$, "2 long pixels" = $p^{(4)}_3$ and "3 short pixels" = $p^{(4)}_4$. The corresponding congurences are:

$$\begin{align} R_4 : P=(1,2,3,4) &\iff p \equiv 1\pmod{16} \\ R_4 : P=(1,4,3,2) &\iff p \equiv 3\pmod{16} \\ R_4 : P=(4,1,2,3) &\iff p \equiv 5\pmod{16} \\ R_4 : P=(2,1,4,3) &\iff p \equiv 7\pmod{16} \\ R_4 : P=(3,4,1,2) &\iff p \equiv 9\pmod{16} \\ R_4 : P=(3,2,1,4) &\iff p \equiv 11\pmod{16} \\ R_4 : P=(2,3,4,1) &\iff p \equiv 13\pmod{16} \\ R_4 : P=(4,3,2,1) &\iff p \equiv 15\pmod{16} \\ \end{align}$$

Interestingly, not all permutations of four shapes are possible to appear in this region. That is, we can see that only $8$ out of theoretical $24=4!$ appear. Also notice that we alternate even and odd numbers ("short" and "long" shapes) in all of these permutations.

$$ (s\ge 5) $$

Unexpectedly, unlike $R_3$ and $R_4$ that appear only once (on each mirrored side), we can say that the $R_5$ appears twice (on each mirrored side). But, in each of those two mirrored pairs we have different parabolic shapes. Therefore, we can also say that there are two different $R_5$ regions.

So far, I've been manually tracing pixels in many consecutive primes to observe these regions and their permutations. Can we characterize these regions more efficiently?

I've examined the $R_5$ region(s) and found that $c_5=50$, which gives $20$ possible permutations. I've also examined $R_6$ and found $c_6=36$, which gives $12$ possible permutations.

Notice that a pattern emerges here. The $c_s $appears to follow the sequence:

$$ c_s=2, 4, 18, 16, 50, 36,\dots $$

Which corresponds to only one OEIS sequence, namely the A137933(s) = $c_s = \DeclareMathOperator{\lcm}{lcm}\lcm(s^2,2)$. If this is true, then the number of possible permutations is $s\phi(s)$, which is A002618.

In other words, it appears that only the permutations (of "parabolic" shapes $\{1, 2, 3, \dots, s\}$) that are "in arithmetic progressions modulo $s$" can exist within the $R_s$ region!

**Can we prove that this holds for all $s$?**

Beside finding how the individual parabolic shapes permute within corresponding regions, we also need to find their exact locations within those regions, to complete the characterization.

**Partition of pixels (entries) into regions $R_s$**

An interesting question that we can ask is, can we color every pixel (entry) $(x,y)$ such that it belongs to exactly one (or two neighbouring) regions $R_s$?

That is, $(x,y)$ should belong to a region if it is a part of a shape that is being permuted in that region, or if it "extends" one of those shapes up to the border of a neighbouring region.

I've decided to color $R_1,R_2,R_3,R_4$ with $\color{purple}{\text{purple}},\color{red}{\text{red}},\color{green}{\text{green}},\color{blue}{\text{blue}}$, respectively. I'll use white to color pixels that "overlap" (could be in either region) or those that "are forming next region".

Prime numbers $p=2,3,5$ seem too small so we can start with $p=7,11,13,17,19,23$.

The first three regions are already visible in these small primes.

Observing the next few primes $p=29,31,37,41$, we see that the fourth region emerges too, but still intersects the third region at some parts.

It is at primes $p=43,47,53$ when the fourth region should be clearly visible for the first time.

The fifth region and beyond will appear at a bit larger primes.

If we want to be able to color larger examples, we need to first characterize the regions (answer my first question) and then we need to be able to additionally determine their exact locations within the corresponding region.

Question. $2.$Can we determine locations for the parabolic shapes for given $R_s$ region?

I've looked at $R_2$ (first nontrivial region), and it is not hard to see where exactly the two corresponding parabolic shapes will appear. This allowed me to come up with the parametrization of the entire pattern (matrix $M_p$) and is presented in the following chapter.

## Pattern parametrization

The central region $R_2$ can be used to generate the entire matrix $M_p$. This is much more efficient than computing it and might shed some light on the pattern.

That is, all regions $R_s$ emerge from the following parametrization.

**Parametrization of $M_p$**

To start, we locate the start (the "head") of the "thin" and the "thick" parabola. The starting $y$ will be given by $y=y_P$ for both, where the starting $x=x_L$ of the leftmost one and the starting $x=x_R$ of the rightmost one are:

$$\begin{align} y_P&=\frac12(p-3)\\ x_L&=\frac14\left(p-(p\bmod{4})_{\in\{-1,1\}}\right)\\ x_R&=p-x_L \end{align}$$

where the "mod" takes values in $\{-1,1\}$ as noted. To generate $M_p$, we start with a matrix of $0$'s and fill in the $1$'s with the following sequences, where the "mod" now takes nonnegative values:

$$\begin{align} \left(x^{(i)}_n,y^{(i)}_n\right)&= \left( \left(\left(x^{(i)}_{n-1}+(2n-1)\right)\bmod{p}\right), y^{(i)}_{n-1}+1 \right), i\in\{1,2\},\\ \left(x^{(i)}_n,y^{(i)}_n\right)&= \left( \left(\left(x^{(i)}_{n-1}+(2n-1)\right)\bmod{p}\right), y^{(i)}_{n-1}-1 \right), i\in\{3,4\},\\ \left(x^{(5)}_n,y^{(5)}_n\right)&= \left( \left(\left(x^{(5)}_{n-1}+2n\right)\bmod{p}\right), y^{(5)}_{n-1}+1 \right),\\ \left(x^{(6)}_n,y^{(6)}_n\right)&= \left( \left(\left(x^{(6)}_{n-1}+2n\right)\bmod{p}\right), y^{(6)}_{n-1}-1 \right),\\ \end{align}$$

where the starting conditions are:

$$\begin{align} \left(x^{(i)}_0,y^{(i)}_0\right)&=\left(x_a,y_P+(i\bmod{2})\right),i\in\{1,2,3,4\},\\ \left(x^{(i)}_0,y^{(i)}_0\right)&=\left(x_b,y_P+(i\bmod{2})\right),i\in\{5,6\},\\ \end{align}$$

where $x_a,x_b\in\{x_L,x_R\}$ are the $x$'s of the "head"'s of "thick","thin" parabolas, respectively.

A sequence terminates after its $y$ coordinate leaves the $[0,p)$ interval.

The only correction that needs to be done is that $M_p(0,0)=M_p(0,p-2)=M_p(0,p-1)=0$ and that $M_p(0,y)=1$ for $y=1,2,\dots,p-3$. The rest of entries $M_p(x^{(i)}_n,y^{(i)}_n)=1$ are correctly generated by sequences $i=1,2,3,4,5,6$ and $n$'s up until the $y$ escapes $[0,p)$.

These sequences represent extensions of the "thick" and "thin" parabolas from $R_2$, that loop around the right and left edges of the image (matrix) up until the top (bottom).

As these sequences intertwine, they will produce all other regions $R_s,s\ne 2$. That is, all regions emerge from these sequences of pixels (entries).

Can we use this to help us predict the characterizations of regions $R_s$?