{'fraction_non_alphanumeric': 0.05050087782711969, 'fraction_numerical': 0.015800888154497574, 'mean_word_length': 3.6986899563318776, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Graphical patterns in quadratic residues

Plots of quadratic residues display some features that are analyzed mathematically.


Introduction
The quadratic residue (QR) of an integer x modulo m is the remainder a of the division of x 2 by m. It is expressed by the congruence, where the residue class a can be represented by an integer from 0 to m− 1. Figure 1 shows a typical plot of QRs where a rather chaotic distribution can be appreciated. As x and m − x have the same QR, then only those QRs corresponding to 0 ≤ x < m/2 are represented. It is not surprising that QRs modulo a big integer of unknown factorization are used in cryptography and random sequence generators [1]. Nevertheless, they always show a remarkable presence of points that seem to draw multiple "acute parabolas" that spread along the graphic. A closer look confirms that the acute parabolas have a quite regular distribution, for values of x near simple fractions of the modulus in a quantity related to the denominator of the fraction, so that a lower number of best defined acute parabolas correspond to a simpler fraction . Not only QRs, but also n-power residues spread as integer points of sets of n-degree polynomials for x values near a fraction of the modulus as it is stated in [2]. In that paper, it was shown that some of those "acute parabolas" can be used to obtain low quadratic residues used in the factorization of large integers. In fact, those parabolas correspond to the Montgomery polynomials of the MPQS (Multipolynomial Quadratic Sieve) [4,5] and HMPQS (Hypercube Multipolynomial Quadratic Sieve) [3] factorization algorithms.
A detailed treatment of the presence and regular disposition of the "acute parabolas" is done in Section 2. Nevertheless, such features can be explained in a rather informal way with a fairly straightforward reasoning. Let be an integer x and a modulus m and consider the difference between the square of x and its nearby integers, i.e. ∆ = (x + i) 2 − x 2 = 2ix + i 2 , when x is the closest integer to a fraction a/b of the modulus. We consider small i values and neglect the term i 2 . A second approximation is done replacing x by (a/b)m, so ∆ ≈ (2ia/b)m. If b is odd, the residue of the fraction (2ia/b)m modulo m is another fraction (a ′ /b)m with a ′ ≡ 2ia (mod b) because 2ia = a ′ + kb for some integer k. When b is even, we can note that ∆ ≈ (ia/b ′ )m with b ′ = b/2 and its residue modulo m is the fraction (a ′ /b ′ )m with a ′ ≡ ia (mod b ′ ). Therefore, the QRs for values near x are spaced approximately by multiples of m/b ′ . The term i 2 , which is not considered in this approximation, accounts for building the parabolas at regular intervals.
Functions involving QRs have been used to generate computer graphics. The function f (x, y) = x 2 + y 2 (mod m) shows concentric circles with centres at coordinates that are made up of simple fractions of the modulus. They are actually, truncated paraboloids present in this bi-dimensional case (see fig. 2). Another type of patterns can be observed sometimes in QRs plots besides the "acute parabolas". For some moduli, it may happen that the outlines of broader diffused "ghost parabolas" materialize, as can be observed in fig. 1 and fig. 3. These kind of patterns are analyzed in Section 3. To conclude, we can state that the graphical patterns of QRs mod m plots depend only on the residues of m modulo the lower positive integers.
2 The geometry of the "acute parabolas" The congruence relation is a relation of equivalence between integers. Nevertheless, a similar relation between rationals can be established: Definition 1 Two rationals, s and t, are Q-congruent modulo an integer m when (s − t)/m is an integer and then we can write s ≡ Q t (mod m) and s = t + km, for some integer k.
Q-congruence relation is reflexive, symmetric and transitive as well as the congruence relation between integers. Moreover, two congruent integers are also Qcongruent. Therefore, the notation "≡" between rationals must be read as "≡ Q " and when the relation is between integers, it can be read in both ways. Let m be a modulus and a/b an irreducible fraction. We define the integer x 0 and its quadratic residue r 0 as where ⌊x⌉ = ⌊x + 1/2⌋, that is, the nearest integer to x.
Proof. We note that x 0 = (am − α)/b from the definition of the integer α and then, With the definition of β, the term (a 2 m − 2aα − β)/b 2 becomes an integer. Taking into account that |α| ≤ b/2, we can then write We now calculate the QRs of integers near x 0 . From the considerations explained in the introduction, it becomes natural to consider lattice points defined by Expanding the square of the trinomial, we have Taking into account that x 0 = (am − α)/b and with r and r i as the quadratic residues of x and x 0 + i respectively, we can write Proof. It is clear that (4) is a parabola under variable j for each one of the b ′ values of i in (3). Those parabolas will be named as P i (j). The coordinates at the vertex are given when the derivative of (4) with respect to j becomes null. Since r i is fixed for each i value they are given by Substituting the value of j v in (3), and taking into account that x 0 = (am − α)/b, the coordinate at the vertex is x v = (a/b)m which is independent from i value. Then, all parabolas related to the fraction a/b have vertices at the same x value. Since Replacing r i and simplifying we obtain, . Taking the value of r 0 from (2), we obtain, Let be with c as defined in (4). Then As much as i runs over Z b ′ and gcd(a, b ′ ) = 1, a ′ takes all values in Z b ′ . From the above equation, it follows that vertices of P i (j) lie exactly at multiples of m/b 2 and are separated by exact gaps of m/b ′ . This concludes the proof.  Figure 2 shows a representation in gray levels of the function f (x, y) = (x 2 + y 2 ) (mod m). It is remarkable the symmetry of the graphic because it displays all the range of variables in Z m . There is only one paraboloid at each node related to fractions 0/1, 1/2 and 1/1. That corresponds to centre, corner and the midpoint of the sides of fig. 2. Such paraboloids have a sharp profile form and they are surrounded by rings due to truncations. Two paraboloids are present at each node related to 1/4 and 3/4 producing more fuzzy patterns. Other patterns alike can be observed for more complex fractions.
At first glance, when plots like fig. 1 are observed, the presence of "acute parabolas" and their positions can be recognized. Since b = b ′ c, equation (5) can be rewritten as , for some integer s.
Taking k = s + a ′ , we have If the set of parabolas P i corresponding to the fraction a/b is considered as a whole, without paying attention to the position of any single parabola in the set, the above equation shows that their position is defined only by the value of β ′ . Proposition 1 shows that β (and also β ′ ) depends only on m for each fraction a/b. Since the sets of parabolas corresponding to the simplest fractions are those that are relevant to the eye, it follows that the general appearance of a plot only depends on the values of m mod cb for the lowest values of b, that is for cb = 4, 3, 8, 5, 12, · · · .
For example, let Λ = Λ(9) = 2 4 · 3 2 · 5 · 7 = 5040. Plots of QRs modulo integers that are congruent modulo Λ will have the parabolas corresponding to fractions with denominator equal or less than 9 in the same position. Moreover, since cb divides Λ for b = 10, 12, 14, 15, 16, 18 · · ·, the parabolas related to fractions with these denominators will also have the same position. As an example, Figures 3(a) and 3(b) have the same appearance, but for their density, because the modules are 4Λ + 19 and 5Λ + 19 respectively and then β mod cb do not change when b ≤ 9 or b = 10, 12, 14, 15, 16, 18 · · ·. Furthermore, we can prove that the vertices are rational points of a bundle of lines.
Proposition 3 Let the integers Λ, m and s be such that s ≡ m (mod Λ) and let B be the set of positive integers b such that b|Λ if b is odd or 2b|Λ if b is even. The vertices of the parabolas defined in Proposition 2 associated to fractions a/b with b ∈ B are rational points of the bundle of lines of the form Proof. The relative position of the vertices depends on the value of β mod cb as it was justified above. When b is odd, c = 1 and the expression of β in Proposition 1 can reduce to β ≡ −a 2 m (mod b). If b is even, c = 2. We put α = am − kb, for an integer k such as |α| ≤ b/2. Then, β ≡ a 2 m − 2a(am − kb) (mod b 2 ), that reduced to mod 2b is also β ≡ −a 2 m (mod 2b). We conclude that β ≡ −a 2 m (mod cb) for any parity of b. Note that, from the definition of Λ and s, we have that when b ∈ B, s ≡ m (mod cb) and then β ≡ −sa 2 (mod cb). From Proposition 2 and equation (6), it follows that the vertices of the parabolas are at Note that ck ≡ 2na (mod b) can always be solvable in n for any value of k ∈ Z b ′ and for any parity of b. Note also that n can take any value with the appropriate value of k ∈ Z b ′ . Then, we have that Y v = −s a 2 b 2 + 2n a b = −sX 2 v + 2nX v for some n.
When s = 0 the bundle of quadratics degenerates in straight lines( fig. 3(c)) that are outlined due to the accumulation of points near the vertices. As s has a higher absolute value, the straight lines bend into parabolas as can be seen in fig. 3 (d) and 3(e). When s has absolute value as high as in fig 3(f), the lines of the bundle have such a high slope that they do not allow to notice the "ghost parabolas".
To conclude, we have shown that Proposition 1, 2 and 3 explain the main visual features of QR plots and that those features are related solely with the residues of m modulo the lower positive integers.