**Squares and their residues**

This is an exploration of number triangles in the same vein as some other such we have previously described . It resulted in some observations that seemed interesting to us. Some are perhaps trivial but some seem puzzling to us probably on account of our very meager mathematics.

Consider the triangle of squares . The row of is comprised of squares of all integers ; illustrated below is the tip of this triangle.

We then obtain the square residue triangle from it by following operation, . The first 15 rows of this triangle are shown below.

**The rows of **

If we look at each row of , we see a mirror symmetry upon excluding the last term which is always 0. Leaving out the final 0, the first and the last elements of the row are the squares . Thus, the same squares are found at the beginning of each row from to . After that a new square gets added to this run of squares at the beginning and end of the row. The reason for this is rather obvious: All will leave themselves behind as residues of the modulo operation with . will result in a residue in the form of the terminal 0 of that row. Then for will leave residues , i.e., in the reverse order as the starting run. The middle part of each row between these square terms may or may not be square terms but will also symmetrically expand. The pattern of residues is unique for each row of but the basic symmetry of the parabolic ascent and descent is common to all. This is illustrated in Figure 1

*Figure 1. Figure 1 shows 9 different rows of . The first row — divisible by 4; second row — other numbers; third row — primes. The successive values are alternately colored blue and red.*

We observe that for divisible by 4 we get a supersymmetry, wherein each symmetric half of the row is further symmetric (Figure 1, row 1). All other show a pseudo-supersymmetry (Figure 1, rows 2 and 3). All also display a central parabolic region but its particular form varies from number to number.

**The columns of **

Now, if we look at vertically, every column starts with a 0. It eventually terminates in a continuous run of square terms with the value . Thus, the first column terminates in a continuous run of 1s, the second column in a run of 4s, the third in a run of 9s, so on. In a given column, between the starting 0 and the first term we observe several notable patterns:

1) Immediately after the starting 0 there is an ascending sequence of square terms. This becomes apparent from the second column, i.e. onwards, where after 0 we get a 1. For , the sequence is 1, 4 — a new square term 4 is seen. 1,4 then continues as the initial ascending sequence of square terms till . At , we get a new square term 9; thus yielding the ascending sequence of square terms 1, 4, 9, which continues till . At , we get next square term 16, yielding the ascending sequence of square terms 1, 4, 9, 16. Thus, we derived the general formula for the number of terms in this ascending run of square terms as:

; with the sequence of square terms being 1, 4, 9…

Thus, the new square term gets added when , i.e. at 1, 3, 7, 13, 21, 31, 43, 57, 73, 91… (see below for more on this sequence)

2) The next pattern is more complicated. Starting from the largest and last square term of the initial ascending run of square terms of the column (described above), we start seeing a series of descending runs, until we hit a terminal 0, which precedes the concluding continuous sequence of square terms . To understand this let us examine the column of . Below are its first 46 terms:

0, 1, 4, 9, 5, 1, 10, 7, 4, 1, 15, 13, 11, 9, 7, 5, 3, 1, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 49, 49, 49

The first term is the starting 0. Terms 2, 3 and 4 are the 3 ascending square terms 1, 4, 9. Terms 44:46 are the first 3 of the terminal continuous run of square terms . In between are the descending runs that are under consideration. From term 4 which is 9 we descend to 5 and then to 1 (terms 5 and 6 of above sequence); this is a descent by 4. Then we have 10, 7, 4, 1, which is a descent by 3. Then we have 11, 9, 7, 5, 3, 1, which is a descent by 2. Then we have 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, which is a descent by 1. For all columns we have a descent by 1. For higher we see the addition of new runs of descent by 2, 3, 4 ,so on. Thus, for column , we have descents by 4, 3, 2, 1.

3) We notice that in , for a column , these descents by 1, 2, 3… begin with a certain number that keeps increasing. The descents by each number continue till they hit 0 or the positive integer nearest to 0, which can be attained via such a descent. Thus, the descent by 1 sequence will always terminate in a 0. However, as we saw above, for , the descent by 2 starts with 11; so the integer nearest to 0 that the run can reach is 1. Now if we look at the descent by 1 sequence, the first column, , has just 0 before the continuous run of 1s; so we can take the start of the descent by 1 as 0. For the descent by 1 begins with 1; for it begins with 4; for it begins with 7; for it begins with 12. Similarly, we can identify the starting integers with which the descent by 2, 3, 4… begin for successive columns of . This is shown in table 1.

Table 1. The starting integer of each descent run by (horizontal) for the first 12 columns of (vertical) are shown.

Thus, we get sequences of the starting integers of the descent by a given in the successive columns of :

; 0, 1, 4, 7, 12, 17… After the starting 0 here successive terms differ by 3, 3, 5, 5, 7, 7…

; 0, 1, 4, 7, 10, 15… After the starting 0 here successive terms differ by 3, 3, 3, 5, 5, 5,7,7,7…

; 0, 1, 4, 6, 10, 13…

So on, as in Table 1. For the first three of these sequences, i.e. the starting integers of the descent by 1, 2 and 3 in the successive columns of , we were able to derive general formulae for the term of these sequences:

*Figure 2. The number of edges in the graph are shown above it in red . The number of unit square cells in the graph are shown in blue below it.*

Remarkably, for the first of these sequences, , we were able to find a clear geometric interpretation. It corresponds to the number of edges found in the alternating square-rectangle graph, which is formed by extending the previous element by a unit (Figure 2, panel 1). This sequence has been described in OEIS as appearing in several surprising contexts relating to packing of shapes and beyond. However, to our knowledge this is the first time it has been found emerging in the triangle . The second of these sequences corresponding to may also be interpreted as the number of edges in a growing graph of unit squares (Figure 2, panel 2), but describing the growth pattern is less simple than what we see for the case of . One can imagine that these sequences provide analogies for the growth of cell-layers under certain constraints. We are yet to find a clear geometric interpretation for the case of . We have not yet been able to find general formulae for . It is something that mathematicians might be able to find.

4) Then we ask the question as to how many terms the total set of runs of descent in given column of occupy. For , it is obviously 0. For the terms are 1,0; thus, the number of terms is 2. For , the terms are 4, 3, 2, 1, 0; thus the number of terms are 5. For , which we saw above, the total number of terms occupied by the runs of descent is 40. We derived the general formula for the total number of terms in the runs of descent for a column :

This to our knowledge is a novel sequence whose significance in the context of has not been previously described.

5) From the above results it also becomes apparent that the total number of terms in a column of before the terminal continuous run of square terms is given by formula . This sequence 1, 3, 7, 13, 21, 31, 43, 57, 73, 91, 111 … is another famous sequence with a clear geometric significance. It is the number of cycles that exist in a pyramid graph (also known as a wheel graph). It has many other interesting properties (see OEIS), but to our knowledge, this is the first report of its occurrence in the context of .

Thus, is the mother of many interesting sequences that show up in other contexts with various geometric/topological implications.

**The overall structure of **

*Figure 3. In the left panel is plotted using a different color for each value. In the right panel the values of are modulated using to reveal the internal structure more clearly.*

The above-described row-wise and column-wise patterns in combine to give rise to a further intricate structure that becomes apparent if we visualize graphically by plotting each cell of the triangle in a different color (Figure 3). We see a central family of nested conics along the median of the triangle. This is flanked by further such curves along the medians of the two triangles formed by the median of and also their flanks. A mathematician might be able to provide the equations to describe these curves in .

Finally, if we take up to a certain value of , we can ask what are the frequencies of the various integers in it (Figure 4) ?

*Figure 4. The frequencies of the all integers occurring in . The brown line is the best linear fit for the frequency of the successive perfect squares. The unusually low (red) and high (violet) values among the non-squares are marked.*

It is immediately apparent that the perfect squares occur at much higher frequencies than the non-squares. Why this is the case can be generally understood from the above discussion on the rows and columns of , which over-represent perfect squares. The frequencies of successive perfect squares decrease almost linearly (Figure 4, fit line). Among the non-squares, we observe that unusually low and unusually high frequencies are often seen for certain numbers just before or just after the perfect squares (Figure 4). The exact basis of this pattern is in need of an explanation.

**The linearization of **

Another way to examine the structure of is to linearize it. This is done by concatenating successive rows to generate the sequence . The first few terms of are shown below:

0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 4, 4, 1, 0, 1, 4, 3, 4, 1…

We then plot such that the first term is placed at 0 with being y-coordinate and being the x-coordinate (Figure 5).

*Figure 5. A plot of with successive terms alternately colored red and blue. The bounding parabola (green) and the primary parabolic attractors (pink) are plotted over .*

Given that is created by linearizing a triangle it is bounded by a parabola (Figure 5) of the form:

Under this parabola the plot of reveals a complex pattern, which is clearly non-random. There are curves, which might be termed attractors, on which the points tend to occur more frequently than elsewhere:

1) The most obvious attractors are straight lines of the form ; where (Figure 5).

This relates to the preponderance of square terms in (Figure 4).

2) The next most visible attractors are the parabolic arcs that start from the bounding parabola and run towards the x-axis (Figure 5). We term these the primary parabolic attractors. The coordinates of the starting points of parabolic attractor, ( ) are specified by the following algorithm:

Let

The primary parabolic attractors themselves are defined by the equations of the form:

We empirically determined that .

Thus, is a sequence whose first few terms are: 3, 8, 14, 22, 33, 45, 59, 76, 94, 114, 137, 161, 187, 216, 246, 278, 313, 349, 387, 428, 470, 514, 561.

We were unable to derive a general formula for . However, we empirically determined the first few terms of to be: 1, 25, 50, 100, 100, 200, 200, 400, 480, 600, 700, 1000, 1100, 1400, 1550, 2100, 2000, 2700, 2800, 3250, 3250, 4200, 3900.

Perhaps a mathematician could derive the a general formula for sequence and also provide a means of deriving the value of from first principles.

3) Finally, a closer look reveals secondary attractors in the form of fainter parabolic arcs and lines. We have not attempted to derive their equations. A general scheme for identifying them would be of interest.

In conclusion the humble , which can be derived using elementary school mathematics, spawns some interesting patterns and sequences that might uncannily appear in other places.