Finite Sequences from Quadratic Residues (Part III)

A Method for New Finite Sequences

An integer r is called a quadratic residue modulo p if it is congruent to a perfect square modulo p:

x2r (mod p)

with the number of residues for a given prime given by the equation (p − 1)/2 where the one value x2 = 0 is removed before division by 2.

When a number is divided by p there are only p possible remainders including 0. Every integer, positive, negative or zero with its remainder modulo p is, therefore, partitioned into residue classes. Each residue is usually depicted as a number between 0 and m but may also be depicted as (r + m) where m is some multiple of p. However, the congruency, (r + m) ≡ r (mod p), is reduced back to r, a member of the same residue class modulo p.

Quadratic residues may be depicted as in Table I according to increasing r as shown for p = 23 where the first five rs are square numbers in ascending order while the next seven appear to be scattered at random. However, row 2 in Table I can also be depicted, as in row 3, with every r as ordered square numbers where the latter seven x2 now range from 25 to 121 but are congruent to their respective seven latter r values in row 2. Not so random after all.

Table I (Quadratic Residues)
x01234567891011
r0149162133181286
r0149162536496481100121

This page will show an alternative method for generating incremental values of r by adding an 2x + 1 terms to each r in order to to generate the next higher r term. Each 2x + 1 may be derived from an x in row 1 or by initially setting x to zero and incrementing each subsequent 2x + 1 term by 2. The sequence derived from rs is not arithmetic, i.e., having a common difference between terms, since the difference (Δ) between terms increases by two for the next addition. Before depicting this in Table II the following expressions which were defined in Part I shows that the numbers in Table I correspond to either of three types of expressions:

Type I: x2 = r + pq; q=0. Thus x2 = r
Type II: x2 = r + pq; q=1. Thus x2 = r + p
Type III: x2 = r + pq; q>1

where q is the quotient and the values of r, r + p and r + pq in the above three types are perfect squares.

The number of values in each type is found by taking the square roots of p and 2p in the following expressions when p = 23:

Type I = ⌊23⌋ = 4 ⟺ columns 1 to 4
Type II = ⌊2×23⌋ − ⌊23⌋ = 6 − 4 = 2 ⟺ columns 5 to 6
Type III = (p − 1)/2 − (Type I + Type II) = 11 − 6 = 5 ⟺ columns 7 to 11
and where (p − 1)/2 = ⌊(23×22)/4
Column 0 initialized to the value of 0

Sequence of rs with p=23

Tables IIa and IIb show how to increment the x by using the expression 2x + 1 in row 3. We can increment 2x + 1 by initially setting x = 0 and incrementing its value by 2 or by setting the 2x + 1 using the x from the previous column. For example, r = 9 is found by adding the previous r = 4 to the Δ value of 5 in row three and then adding 2 to 5 to get the next Δ addend. Furthermore, as shown above when x = 5 the r value could be depicted as 2 or 25 depending on whether one adds Δ to the last Type I number r = 16 or retains the lower r = 2 as the new starting point, but keeping the Δ values the same. Since having all square rs is not the preferred way to go, the most preferable choice would be to use the lower r and do either of two things: Continue as in Tables IIa and IIb or proceed as in Table IIc.

In Table IIa we can start by adding the first 2x + 1 to 0 and generating all four r of Type I numbers. In the next step since the addition of Δ = 9 to 16 produces a perfect square. So we keep the original value of 2 (in red), producing a Type I and Type II discontinuity, but continue the addition of Δs until the calculation of the last r.

Table IIa (Sequence for p=23)
x0123 456
r0149162 13
Δ13579 1113
Table IIb (Sequence for p=23)
x78910 11
r2641587798
Δ15171921

Although this method places every r of Type III number in ascending order we can, alternatively, set r ≡ 0 (mod 23) equal to −23 (mod 23) and use −23 as the initial r value to which the first Δ = 1 is added followed by further 2x + 1 additions as in Table IIc. A third option is to square each x from start and subtract 23. That would produce Table IIc in one fell swoop:

Table IIc (Sequence for p=23)
x0123 456
r-23-22-19-14-72 13
Δ13579 1113

This then generates a finite sequence without the discontinuity between x = 4 and x = 5 as depicted in Table IIa. Note that all the − r values are congruent to x2 (mod 23).

These new r values I will designate as rn may also be obtained directly from x2 as follows:

rn = x2 − p

Thus we have an alternative way of forming the sequences by generating rn from each x2 and stringing together each value of rn starting with x2 = 0. Moreover, rn produced in this manner is randomly and not sequentially generated.

Sequence of rs with p=1193

The second larger prime used in Part II, 1193, will be used as a second example in Tables IIIa, IIb and IIIc.

Type I = ⌊1193⌋ = 34 ⟺ columns 1 to 34
Type II = ⌊2×1193⌋ − ⌊1193⌋ = 48 − 34 = 14 ⟺ columns 35 to 48
Type III = (p − 1)/2 − (Type I + Type II) = 596 − 48 = 548 ⟺ columns 49 to 596
Column 0 corresponds to the value of 0
Table IIIa (Sequence for p=1193)
x0123 4...3334
r014916...1089 1156
Δ1357...65 6769
Table IIIb (Sequence for p=1193)
x353637...4748
r32103176...10161111
Δ7173...939597
Table IIIc (Sequence for p=1193)
x495051...594595596
r120813071408...351643352832354023
Δ9799...118711891191

As before a discontinuity again occurs this time between x = 34 and x = 35. This discontinuity disappears upon setting r ≡ 0 (mod 1193) to r ≡ −1193 (mod 1193) as the initial r value as was done for p = 23. Note that these sequences do not end at x = 596 but can be continued indefinitely by adding increasing amounts of Δ to r. For instance, adding 1193, the next number in the arithmetic sequence of row three, to r = 354023, affords r = 353216 both of which are congruent to 895 (mod 1193). After x = 596 the r values are in descending order starting with 895 and decreasing to zero.

Again we may use the equation:

rn = x2 − p

to generate all rn values. The advantage of using the latter method is that Δ doesn't have to be explicitly spelled out but may be omitted from the table. However, the best option is to subtract 1193 from each x starting from x = 0. This would start the sequence at −1193 as in p = 23 example.

As an afterword we have been dealing with regular r values and with non regular (r + m) values which I have designated as rn. In the first expression below, the latter rn has been set equal to the right side of the first expression where p(q − 1) is the multiple m required for generating the incremental values of r with again q being the quotient. x2 is then the value shown in the second expression where we add p to rn.

rn = r + p(q − 1)
x2 = rn + p

Go to Part IV, Go back to Part II. Go back to homepage.


Copyright © 2023 by Eddie N Gutierrez. E-Mail: enaguti1949@gmail.com