# Pattern “inside” prime numbers

Update $$(2020)(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.

• 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 $$nn$$ is encoded into it in the form of a fractal-like pattern.

$$22$$-digit palindromes represent factorizations

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

The $$22$$-digit palindrome is an integer $$n=(a,a)b=ab1+ab0=a(b+1),a, where in the $$(n1,n2,…)b(n_1,n_2,\dots)_b$$ notation, $$n1,n2,…n_1,n_2,\dots$$ stand for digits of $$nn$$ in the integer base $$b≥2b\ge 2$$.

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

$$n=pq=p(q−1)+p=(p,p)q−1,p

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

Representing $$n∈Nn\in\mathbb N$$ as a sum of $$n×nn\times n$$ images (matrices)

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

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

$$Pn(x0,y0)(x,y)={1,if x+nx0 is a two digit palindrome in base y+ny00,else 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, "$$P100(x0,y0)P_{100}(x_0,y_0)$$"'s for $$(x0,x0)=(0,0),(1,0),(2,0),(3,0)(x_0,x_0)=(0,0),(1,0),(2,0),(3,0)$$ are:

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

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

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

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

Visualization of the "image of $$nn$$" matrix

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

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

This motivates us to write $$Nn=f(Nn(1))N_n=f(N_n(1))$$ and call $$NnN_n$$ the "image of $$nn$$", where $$ff$$ 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 $$NnN_n$$'s for $$n=7,…,31n=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 $$NnN_n$$ based on factorizations of $$nn$$

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

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

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

One might ask if we can for $$nn$$ in general compute the matrix $$NnN_n$$ more efficiently than calculating and summing up all those $$PnP_n$$'s. That is, is there an efficient test to get a $$Nn(x,y)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 $$NpN_p$$ where $$pp$$ is a prime number resembles a solid blue square and looks boring. But, we can "look inside" this solid blue square by replacing our $$ff$$ function.

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

"Heat-image" matrix of prime number $$pp$$

We will write $$¯Np=h(Np(1))\overline{N}_p=h(N_p(1))$$ and call $$¯Np\overline{N}_p$$ the "heat-image of prime $$pp$$", where $$hh$$ assigns distinct colors to distinct values of entries of $$Np(1)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 $$¯Np\overline{N}_p$$'s of primes $$p=101,103,109p=101,103,109$$:

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

Within different $$MpM_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 $$¯Np\overline{N}_p$$'s appear to be symmetric along the central horizontal line. In other words, if an entry $$(x,y)(x,y)$$ is red then the mirrored entry $$(x,|p−y−2|)(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 $$00$$.

The pattern inside prime number $$pp$$

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

$$Mp(x,y)={1,if Np(1)(x,y)=Np(1)(x,|p−y−2|)0,else 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 $$11$$'s and $$00$$'s with white and black, respectively.

For example, here are $$MpM_p$$'s of primes $$p=101,103,109p=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 $$109109$$ 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 $$101101$$, but not for the prime $$103103$$ which has it the other way around.

It turns out that primes of the form $$p=4k+1p=4k+1$$ are "left-handed" (have the "thick" parabola on the left side) and that the primes of the form $$p=4k−1p=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=101p=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 $$I2I_{2}$$ - "I shape of height of 2 pixels"
• The second ("blue parabola") has $$J2,1J_{2,1}$$ - "J shape of height of $$2+12+1$$ pixels"
• The third ("red parabola") has $$I3I_{3}$$ - "I shape of height of $$33$$ pixels"

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

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

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

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

For example, in primes as large as $$p=997p=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 $$RR$$, we can observe a set of "parabolic" shapes. Different permutations of those shapes will appear in different primes $$pp$$ (in different $$MpM_p$$'s), depending on the remainder $$mm$$ from division of $$pp$$ by some constant $$cRc_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 $$MpM_p$$ contains "regions $$RsR_s$$" and within those regions we can find one of the possible permutations $$P=(p(s)1,p(s)2,…,p(s)s)P=(p^{(s)}_1,p^{(s)}_2,\dots,p^{(s)}_s)$$ of $$ss$$ "parabolic shapes".

It seems that region $$RsR_s$$ contains some permutation $$PmP_m$$ if and only if $$p\equiv m\pmod{c_s}p\equiv m\pmod{c_s}$$ where $$c_sc_s$$ is some constant related to the $$ss$$th region.

Question. $$1.1.$$ Can we characterize all regions $$R_sR_s$$ and their $$P_mP_m$$'s and $$c_sc_s$$ ?

The "pattern inside a prime $$pp$$" would be the collection of all regions $$R_sR_s$$ of the matrix $$M_pM_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_sR_s$$ for small $$ss$$

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

$$(s=1) (s=1)$$

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

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

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

$$(s=2) (s=2)$$

Given a $$M_pM_p$$ and looking around the central horizontal line we can find $$22$$ distinct parabolic shapes. These are the "thick parabola" $$p^{(2)}_1p^{(2)}_1$$ and the "thin parabola" $$p^{(2)}_2p^{(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}\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) (s=3)$$

In the previous chapter we've observed $$R_3R_3$$ to contain parabolic shapes characterized by a "short I shape" = $$p^{(3)}_1p^{(3)}_1$$, a "long I shape" = $$p^{(3)}_2p^{(3)}_2$$ and a "J shape" = $$p^{(3)}_3p^{(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}\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_2R_2$$ that appears only once, this $$R_3R_3$$ region appears twice in the image: above and (mirrored) below the central horizontal line.

$$(s=4) (s=4)$$

The region $$R_4R_4$$ is similar to $$R_3R_3$$ but of course has more permutations. This region contains parabolic shapes characterized by following shapes (groups of pixels): "3 long pixels" = $$p^{(4)}_1p^{(4)}_1$$, "2 short pixels" = $$p^{(4)}_2p^{(4)}_2$$, "2 long pixels" = $$p^{(4)}_3p^{(4)}_3$$ and "3 short pixels" = $$p^{(4)}_4p^{(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}\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 $$88$$ out of theoretical $$24=4!24=4!$$ appear. Also notice that we alternate even and odd numbers ("short" and "long" shapes) in all of these permutations.

$$(s\ge 5) (s\ge 5)$$

Unexpectedly, unlike $$R_3R_3$$ and $$R_4R_4$$ that appear only once (on each mirrored side), we can say that the $$R_5R_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_5R_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_5R_5$$ region(s) and found that $$c_5=50c_5=50$$, which gives $$2020$$ possible permutations. I've also examined $$R_6R_6$$ and found $$c_6=36c_6=36$$, which gives $$1212$$ possible permutations.

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

$$c_s=2, 4, 18, 16, 50, 36,\dots 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)c_s = \DeclareMathOperator{\lcm}{lcm}\lcm(s^2,2)$$. If this is true, then the number of possible permutations is $$s\phi(s)s\phi(s)$$, which is A002618.

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

Can we prove that this holds for all $$ss$$?

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

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

That is, $$(x,y)(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_4R_1,R_2,R_3,R_4$$ with $$\color{purple}{\text{purple}},\color{red}{\text{red}},\color{green}{\text{green}},\color{blue}{\text{blue}}\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,5p=2,3,5$$ seem too small so we can start with $$p=7,11,13,17,19,23p=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,41p=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,53p=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.2.$$ Can we determine locations for the parabolic shapes for given $$R_sR_s$$ region?

I've looked at $$R_2R_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_pM_p$$) and is presented in the following chapter.

## Pattern parametrization

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

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

Parametrization of $$M_pM_p$$

To start, we locate the start (the "head") of the "thin" and the "thick" parabola. The starting $$yy$$ will be given by $$y=y_Py=y_P$$ for both, where the starting $$x=x_Lx=x_L$$ of the leftmost one and the starting $$x=x_Rx=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}\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\}\{-1,1\}$$ as noted. To generate $$M_pM_p$$, we start with a matrix of $$00$$'s and fill in the $$11$$'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}\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}\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\}x_a,x_b\in\{x_L,x_R\}$$ are the $$xx$$'s of the "head"'s of "thick","thin" parabolas, respectively.

A sequence terminates after its $$yy$$ coordinate leaves the $$[0,p)[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)=0M_p(0,0)=M_p(0,p-2)=M_p(0,p-1)=0$$ and that $$M_p(0,y)=1M_p(0,y)=1$$ for $$y=1,2,\dots,p-3y=1,2,\dots,p-3$$. The rest of entries $$M_p(x^{(i)}_n,y^{(i)}_n)=1M_p(x^{(i)}_n,y^{(i)}_n)=1$$ are correctly generated by sequences $$i=1,2,3,4,5,6i=1,2,3,4,5,6$$ and $$nn$$'s up until the $$yy$$ escapes $$[0,p)[0,p)$$.

These sequences represent extensions of the "thick" and "thin" parabolas from $$R_2R_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 2R_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_sR_s$$?

I would put this in the comments, but I don't have enough points.

The patterns you are seeing are Moiré patterns. From wikipedia:

In mathematics, physics, and art, a moiré pattern (/mwɑːrˈeɪ/; French: [mwaʁe]) or moiré fringes are large scale interference patterns that can be produced when an opaque ruled pattern with transparent gaps is overlaid on another similar pattern. For the moiré interference pattern to appear, the two patterns must not be completely identical in that they must be displaced, rotated, etc., or have different but similar pitch.

This is a broad topic with lots of different approaches and applications, so I encourage you to research it.

In terms of finding equations to the patterns you are seeing, Mathematica is great for this. If you don't have Mathematica, you can use Wolfram Alpha. Here is an example with a list of numbers using findsequencefunction. You can also provide a list of points (generally, wolfram alpha needs five or more points to find a sequence):

findsequencefunction[{{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}}, n]


Hope this helps!