Jens Hemelaer
by Jens Hemelaer
3 min read

Take a natural number \(n \geq 2\). Then we can create an interesting pattern as follows: we draw a dot with coordinates \((b,c)\) if the polynomial \(x^2+bx+c\) is reducible modulo \(n\). In other words, we draw a dot on \((b,c)\) if we can find natural numbers \(x_1\) and \(x_2\) such that \(b-x_1-x_2\) and \(c-x_1 x_2\) are both divisible by \(n\). This pattern repeats itself vertically and horizontally.

This is the result for \(n=5\):

reducibles-5-25

And for \(n=7\) we get:

reducibles-7-25

In both cases, the pattern is repeated 25 times, and Python automatically draws each block in a different color (for the code, scroll down to the end of the post).

Here are the patterns for all numbers \(n\) starting at \(n=2\) and ending with \(n=199\) (with one “block” per pattern). It seems that the prime numbers have the most chaotic patterns…

Pattern for n=2
$$n=2$$
Pattern for n=3
$$n=3$$
Pattern for n=4
$$n=4$$
Pattern for n=5
$$n=5$$
Pattern for n=6
$$n=6$$
Pattern for n=7
$$n=7$$
Pattern for n=8
$$n=8$$
Pattern for n=9
$$n=9$$
Pattern for n=10
$$n=10$$
Pattern for n=11
$$n=11$$
Pattern for n=12
$$n=12$$
Pattern for n=13
$$n=13$$
Pattern for n=14
$$n=14$$
Pattern for n=15
$$n=15$$
Pattern for n=16
$$n=16$$
Pattern for n=17
$$n=17$$
Pattern for n=18
$$n=18$$
Pattern for n=19
$$n=19$$
Pattern for n=20
$$n=20$$
Pattern for n=21
$$n=21$$
Pattern for n=22
$$n=22$$
Pattern for n=23
$$n=23$$
Pattern for n=24
$$n=24$$
Pattern for n=25
$$n=25$$
Pattern for n=26
$$n=26$$
Pattern for n=27
$$n=27$$
Pattern for n=28
$$n=28$$
Pattern for n=29
$$n=29$$
Pattern for n=30
$$n=30$$
Pattern for n=31
$$n=31$$
Pattern for n=32
$$n=32$$
Pattern for n=33
$$n=33$$
Pattern for n=34
$$n=34$$
Pattern for n=35
$$n=35$$
Pattern for n=36
$$n=36$$
Pattern for n=37
$$n=37$$
Pattern for n=38
$$n=38$$
Pattern for n=39
$$n=39$$
Pattern for n=40
$$n=40$$
Pattern for n=41
$$n=41$$
Pattern for n=42
$$n=42$$
Pattern for n=43
$$n=43$$
Pattern for n=44
$$n=44$$
Pattern for n=45
$$n=45$$
Pattern for n=46
$$n=46$$
Pattern for n=47
$$n=47$$
Pattern for n=48
$$n=48$$
Pattern for n=49
$$n=49$$
Pattern for n=50
$$n=50$$
Pattern for n=51
$$n=51$$
Pattern for n=52
$$n=52$$
Pattern for n=53
$$n=53$$
Pattern for n=54
$$n=54$$
Pattern for n=55
$$n=55$$
Pattern for n=56
$$n=56$$
Pattern for n=57
$$n=57$$
Pattern for n=58
$$n=58$$
Pattern for n=59
$$n=59$$
Pattern for n=60
$$n=60$$
Pattern for n=61
$$n=61$$
Pattern for n=62
$$n=62$$
Pattern for n=63
$$n=63$$
Pattern for n=64
$$n=64$$
Pattern for n=65
$$n=65$$
Pattern for n=66
$$n=66$$
Pattern for n=67
$$n=67$$
Pattern for n=68
$$n=68$$
Pattern for n=69
$$n=69$$
Pattern for n=70
$$n=70$$
Pattern for n=71
$$n=71$$
Pattern for n=72
$$n=72$$
Pattern for n=73
$$n=73$$
Pattern for n=74
$$n=74$$
Pattern for n=75
$$n=75$$
Pattern for n=76
$$n=76$$
Pattern for n=77
$$n=77$$
Pattern for n=78
$$n=78$$
Pattern for n=79
$$n=79$$
Pattern for n=80
$$n=80$$
Pattern for n=81
$$n=81$$
Pattern for n=82
$$n=82$$
Pattern for n=83
$$n=83$$
Pattern for n=84
$$n=84$$
Pattern for n=85
$$n=85$$
Pattern for n=86
$$n=86$$
Pattern for n=87
$$n=87$$
Pattern for n=88
$$n=88$$
Pattern for n=89
$$n=89$$
Pattern for n=90
$$n=90$$
Pattern for n=91
$$n=91$$
Pattern for n=92
$$n=92$$
Pattern for n=93
$$n=93$$
Pattern for n=94
$$n=94$$
Pattern for n=95
$$n=95$$
Pattern for n=96
$$n=96$$
Pattern for n=97
$$n=97$$
Pattern for n=98
$$n=98$$
Pattern for n=99
$$n=99$$
Pattern for n=100
$$n=100$$
Pattern for n=101
$$n=101$$
Pattern for n=102
$$n=102$$
Pattern for n=103
$$n=103$$
Pattern for n=104
$$n=104$$
Pattern for n=105
$$n=105$$
Pattern for n=106
$$n=106$$
Pattern for n=107
$$n=107$$
Pattern for n=108
$$n=108$$
Pattern for n=109
$$n=109$$
Pattern for n=110
$$n=110$$
Pattern for n=111
$$n=111$$
Pattern for n=112
$$n=112$$
Pattern for n=113
$$n=113$$
Pattern for n=114
$$n=114$$
Pattern for n=115
$$n=115$$
Pattern for n=116
$$n=116$$
Pattern for n=117
$$n=117$$
Pattern for n=118
$$n=118$$
Pattern for n=119
$$n=119$$
Pattern for n=120
$$n=120$$
Pattern for n=121
$$n=121$$
Pattern for n=122
$$n=122$$
Pattern for n=123
$$n=123$$
Pattern for n=124
$$n=124$$
Pattern for n=125
$$n=125$$
Pattern for n=126
$$n=126$$
Pattern for n=127
$$n=127$$
Pattern for n=128
$$n=128$$
Pattern for n=129
$$n=129$$
Pattern for n=130
$$n=130$$
Pattern for n=131
$$n=131$$
Pattern for n=132
$$n=132$$
Pattern for n=133
$$n=133$$
Pattern for n=134
$$n=134$$
Pattern for n=135
$$n=135$$
Pattern for n=136
$$n=136$$
Pattern for n=137
$$n=137$$
Pattern for n=138
$$n=138$$
Pattern for n=139
$$n=139$$
Pattern for n=140
$$n=140$$
Pattern for n=141
$$n=141$$
Pattern for n=142
$$n=142$$
Pattern for n=143
$$n=143$$
Pattern for n=144
$$n=144$$
Pattern for n=145
$$n=145$$
Pattern for n=146
$$n=146$$
Pattern for n=147
$$n=147$$
Pattern for n=148
$$n=148$$
Pattern for n=149
$$n=149$$
Pattern for n=150
$$n=150$$
Pattern for n=151
$$n=151$$
Pattern for n=152
$$n=152$$
Pattern for n=153
$$n=153$$
Pattern for n=154
$$n=154$$
Pattern for n=155
$$n=155$$
Pattern for n=156
$$n=156$$
Pattern for n=157
$$n=157$$
Pattern for n=158
$$n=158$$
Pattern for n=159
$$n=159$$
Pattern for n=160
$$n=160$$
Pattern for n=161
$$n=161$$
Pattern for n=162
$$n=162$$
Pattern for n=163
$$n=163$$
Pattern for n=164
$$n=164$$
Pattern for n=165
$$n=165$$
Pattern for n=166
$$n=166$$
Pattern for n=167
$$n=167$$
Pattern for n=168
$$n=168$$
Pattern for n=169
$$n=169$$
Pattern for n=170
$$n=170$$
Pattern for n=171
$$n=171$$
Pattern for n=172
$$n=172$$
Pattern for n=173
$$n=173$$
Pattern for n=174
$$n=174$$
Pattern for n=175
$$n=175$$
Pattern for n=176
$$n=176$$
Pattern for n=177
$$n=177$$
Pattern for n=178
$$n=178$$
Pattern for n=179
$$n=179$$
Pattern for n=180
$$n=180$$
Pattern for n=181
$$n=181$$
Pattern for n=182
$$n=182$$
Pattern for n=183
$$n=183$$
Pattern for n=184
$$n=184$$
Pattern for n=185
$$n=185$$
Pattern for n=186
$$n=186$$
Pattern for n=187
$$n=187$$
Pattern for n=188
$$n=188$$
Pattern for n=189
$$n=189$$
Pattern for n=190
$$n=190$$
Pattern for n=191
$$n=191$$
Pattern for n=192
$$n=192$$
Pattern for n=193
$$n=193$$
Pattern for n=194
$$n=194$$
Pattern for n=195
$$n=195$$
Pattern for n=196
$$n=196$$
Pattern for n=197
$$n=197$$
Pattern for n=198
$$n=198$$
Pattern for n=199
$$n=199$$

And here is the Python code. I run this inside a Jupyter notebook.

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from itertools import product

for n in range(2,200):
    N1=1   # number of times the pattern is repeated horizontally
    N2=1   # number of times the pattern is repeated vertically
    numberofdots = N1*N2*(n*n + n)/2       # estimate (!) of number of dots
    d = 1.1
    s0 = 10000.0/pow(numberofdots,d)       # area of each dot should decrease for larger number of dots
    l = list(range(n))                     # list of numbers modulo p

    b_list = [x_1+x_2  for x_1,x_2 in product(l,l)]        # b-coefficients of reducible polynomials
    c_list = [x_1*x_2  for x_1,x_2 in product(l,l)]        # c-coefficients of reducible polynomials

    # convert to numpy arrays
    b = np.asarray(b_list)
    c = np.asarray(c_list)

    # plot layout
    axes = plt.gca()
    axes.set_aspect('equal','box')
    axes.set_xlim([0,N1*n])
    axes.set_ylim([0,N2*n])
    plt.xticks([0,n])
    plt.yticks([0,n])

    # scatter plotting all dots, each with the correct size
    for i in range(N1+1):
        for j in range(N2+1):
            plt.scatter(n*i + b % n, n*j + c % n, s=s0)
            
    plt.show()

To estimate the number of dots in each “block” of the pattern, I use the formula \((n^2+n)/2\). This is the exact number of dots if \(n\) is a prime number, but an overestimate otherwise. As a result, the patterns for prime numbers are more “dense”.

The number of dots per block for the first few patterns are 3,6,8,15,18 and 28 (you can count them in the images above). So we search for “3,6,8,15,18,28” in The On-Line Encyclopedia of Integer Sequences (OEIS). The sequence that we need is Sequence A261928. We could use this to “repair” the estimate in the code, but I don’t think that would make the pictures more interesting.