I need to adapt the Sieve of Eratosthenes for the usual integers to find all Gaussian primes with norm less than a specific limit. How to apply it to finding all Gaussian primes with norm less than 100? Thank you very much!
3 Answers
In the Sieve of Eratosthenes for rational integers, you select the positive ones and list those in increasing size. You do the same for the Gaussian integers: list them by increasing norm. But you need to select only one representative from each associate class, that is, modulo multiplication by units. In the rational integers, the units are $\pm 1$. In the Gaussian integers they are $\pm 1$ and $\pm i$. So to normalize the Gaussian integers, you may assume that $|a| \le |b|$ in $a+bi$ because you can always multiply by $i$ to make it so, and you may also assume that $a \ge 0$ because you can always multiply by $-1$ to make it so.

- 216,483
-
2that doesn't quite mimic the sieve of Eratosthenes, does it? In the integers, every third one is divisible by 3, every 5th one by 5, etc. If you list the Gaussians as you describe, will the multiples of, say, $2+i$ form such a simple pattern? – Gerry Myerson Apr 16 '11 at 00:10
-
@Gerry, you're right, it's not quite clear how to proceed. Here's one possibility: http://www.jimloy.com/algebra/gprimes.htm – lhf Apr 16 '11 at 02:14
-
yes, that page goes systematically through the Gaussians and picks out the primes. I don't see it as Eratosthenian, if you'll allow that as a word. For one thing, you have to know which ordinary integers are prime, else what do you do when you get to, say, $100+i$, with norm 10,001? You can't say, unless you know whether 10,001 is a prime. – Gerry Myerson Apr 16 '11 at 06:26
-
@Gerry, yes, I think that the lattice approach you describe is the closest in spirit to Eratosthenes. – lhf Apr 16 '11 at 09:30
-
Thank you all for interesting thoughts! – user9636 Apr 21 '11 at 20:04
EDIT1: what's below is quite wrong, or, to be more positive about it, woefully incomplete. Please see EDIT2.
Represent the Gaussians with norm less than 100 as the lattice points on or in the circle of radius 10 centered at the origin (I take it the norm of $a+bi$ is $a^2+b^2$). Concentrate on the 45 degree sector between the real axis and the line $x=y$. Ignore the points $(0,0)$ and $(1,0)$. Take the closest point to the origin (which is $(1,1)$, corresponding to the number $1+i$), circle it (that's your first prime), and cross out everything else on the line connecting it to the origin. Among the points remaining, take the one closest to the origin, and iterate the procedure until termination.
EDIT2: Crossing out everything on the line through $(0,0)$ and $(a,b)$ will only cross out the multiples of $a+bi$ by ordinary integers, and that's not good enough - one must also cross out the multiples by other Gaussian integers. These form a $\it lattice$ generated by $a+bi$ and $b-ai$. Anyone unfamiliar with this concept is encouraged to plot (for example) the points ${\bf u}=(2,1)$ and ${\bf v}=(1,-2)$, think of them as vectors, then start plotting linear combinations of the two vectors with integer coefficients, $c{\bf u}+d{\bf v}$ with $c$ and $d$ integers. You'll see a simple pattern - that's a lattice, and you have to cross out all the points in it when you circle $(2,1)$.

- 179,216
We can adopt the siev-ing method to identify prime sums of two squares as the sums of the individual squares, from which the appropriate Gaussian primes follow. For instance, if we identify a prime number $4^2+1^2$ as such (rather than identifying it as just the number $17$) , then we have the Gaussuan primes $4\pm $i$.
Let us set up an array of $a^2+b^2$ numbers such that $a\ge b\ge 1$. We order them into rows having a constant sum, and order each row by increasing difference. Here I will use six rows:
$1^2+1^2$
$1^2+2^2$
$2^2+2^2...3^2+1^2$
$3^2+2^2...4^2+1^2$
$3^2+3^2...4^2+2^2...5^2+1^2$
$4^2+3^2...5^2+2^2...6^2+1^2$
Which of these are prime?
Begin by identifying the first entry, $1^2+1^2$, as a prime. We evaluate it as $2$ and then note that tge roots have residue $1,1\bmod 2$. We now generate all the distince multiples of this pair of residues by multiplying each root by a common factor. In $\bmod 2$ that factor can only be $0$ or $1$, so we check larger entries for one of the residue pairs
$0,0$
$1,1$
We intend to cross out any sums other than $1^2+1^2=2$ itself we find with either pair in either order, these corresponding to multiples of $2$. Where blue us a prime and red is rejected, this gives:
$\color{blue}{1^2+1^2}$
$1^2+2^2$
$\color{red}{2^2+2^2}...\color{red}{3^2+1^2}$
$3^2+2^2...4^2+1^2$
$\color{red}{3^2+3^2}...\color{red}{4^2+2^2}...\color{red}{5^2+1^2}$
$4^2+3^2...5^2+2^2...6^2+1^2$
That sieves out our first prime factor. We therefore move on to the next available entry, $2^2+1^2=5$, which is prime. This gives the residue pair $2,1\bmod 5$, whose multiples are as follows:
$0,0$
$2,1$
$4,2$
$1,3$
$3,4$
Note that these pairs must be detected in either order. So $4^2+3^2$ with residues $4,3$ is matched with $3,4$ above:
$\color{blue}{1^2+1^2}$
$\color{blue}{1^2+2^2}$
$\color{red}{2^2+2^2}...\color{red}{3^2+1^2}$
$3^2+2^2...4^2+1^2$
$\color{red}{3^2+3^2}...\color{red}{4^2+2^2}...\color{red}{5^2+1^2}$
$\color{red}{4^2+3^2}...5^2+2^2...6^2+1^2$
Listing multiples in this way will become unwieldy for larger sums, so I present an alternative. With $2^2+1^2=5$ being our test factor, compute $2(1^{-1})\equiv2$ and $(2^{-1})1\equiv3\bmod 5$. Then $a^2+b^2$ will be a multiple of $2^2+1^2$ whenever residue $a$ multiplied by $2$ or $3$ gives residue $\pm b\bmod 5$. For instance, $3×2\equiv1$ and $3×3\equiv4$, so $3^2+2^2$ is not a multiple of $2^2+1^2$. This approach again rejects $4^2+3^2$ because $4×2\equiv3$.
Our next prime is $3^2+2^2=13$, which generates no more cross-outs in my limited list. We do have $2(3^{-1})\equiv5$ and $5×5\equiv-1\bmod13$, but $5^2+1^2$ is already rejected as a multiple of $1^2+1^2$. Neither do any other remaining entries in my list, and I identify all the prime sums of squares with the roots adding up to less than or equal to $7$:
$1^2+1^2$
$2^2+1^2$
$3^2+2^2$
$4^2+1^2$
$5^2+2^2$
$6^2+1^2$
The corresponding Gaussian primes are then $1\pm i, 2\pm i,1\pm 2i$, etc.
To generate complex Gaussian primes up to absolute value $100$, you need sums of roots up to $100\sqrt2\approx 141$.

- 39,403