ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 24 May 2018 12:02:37 -0500Can we find Gaussian primes $\pi = 1 + 8 \mathbb{Z}[i]$ with $N(\pi) < 10000$?http://ask.sagemath.org/question/42408/can-we-find-gaussian-primes-pi-1-8-mathbbzi-with-npi-10000/It's an exercise in computational number theory. Either by hand or by computer, can we find the Gaussian primes $\pi = 1 + 8 \mathbb{Z}[i]$? To keep the list finite I guess we could have $N(\pi) < 10000$.
For example, is $\mathfrak{p} = (1+8i)$ a prime? Or $\mathfrak{p} = (-7 + 8i)$? I don't even know how to index the primes less than these. The norms are $1^2 + 8^2 = 65 = 5 \times 13$ and $(-7)^2 + 8^2 = 113$, so the first could factor and the second does not.
For $\mathfrak{p} = (a + bi)$ to check it is prime over $\mathbb{Z}[i]$, is it sufficient to check that $N(\mathfrak{p}) = a^2 + b^2$ is a prime over $\mathbb{Z}$?
It would be great to see the code in `Sage` or `Pari/GP` and that would be an acceptable answer.Wed, 23 May 2018 09:20:09 -0500http://ask.sagemath.org/question/42408/can-we-find-gaussian-primes-pi-1-8-mathbbzi-with-npi-10000/Answer by dan_fulea for <p>It's an exercise in computational number theory. Either by hand or by computer, can we find the Gaussian primes $\pi = 1 + 8 \mathbb{Z}[i]$? To keep the list finite I guess we could have $N(\pi) < 10000$.</p>
<p>For example, is $\mathfrak{p} = (1+8i)$ a prime? Or $\mathfrak{p} = (-7 + 8i)$? I don't even know how to index the primes less than these. The norms are $1^2 + 8^2 = 65 = 5 \times 13$ and $(-7)^2 + 8^2 = 113$, so the first could factor and the second does not. </p>
<p>For $\mathfrak{p} = (a + bi)$ to check it is prime over $\mathbb{Z}[i]$, is it sufficient to check that $N(\mathfrak{p}) = a^2 + b^2$ is a prime over $\mathbb{Z}$?</p>
<p>It would be great to see the code in <code>Sage</code> or <code>Pari/GP</code> and that would be an acceptable answer.</p>
http://ask.sagemath.org/question/42408/can-we-find-gaussian-primes-pi-1-8-mathbbzi-with-npi-10000/?answer=42423#post-id-42423Let $a+bi$ be a prime in $\Bbb Z[i]$. We can multiply it with $\pm1$ to have $a\ge 0$. Also, we can pass to the conjugate to have also the case $b\ge 0$. After these norming steps, $0\le a,b$. In case $a < b$, one can multiply with $i$ and renorm. So we are searching for primes of the form $a+ib$ where $0\le b\le a$.
**Warming-up:** It is simple to see if a number in $\Bbb Z[i]$ is prime or not. Dialog with the sage interpreter:
sage: K.<j> = QuadraticField( -1 )
sage: K(2018 + 2019*j).factor()
(-1) * (86*j - 139) * (-6*j - 5) * (-j - 2)
sage: K(2017).factor()
(-9*j - 44) * (9*j - 44)
sage: 2020.next_prime()
2027
sage: K(2027).factor()
2027
sage: K(2027).is_prime()
True
sage: K(1+8*j).factor()
(-3*j - 2) * (-j - 2)
sage: K(1+8*j).is_prime()
False
sage: K(-7+8*j).factor()
(j) * (7*j + 8)
sage: K(-7+8*j).is_prime()
True
To collect now all "normed" primes of the given shape with "real" and "imaginary" part up to a given bound we can try:
K.<j> = QuadraticField( -1 )
BOUND = 40
my_primes = []
for a in xrange( BOUND/8 ):
for b in xrange( 1+8*a+1 ):
p = 1 + 8*a + b*j
if p.is_prime():
my_primes.append(p)
for p in my_primes:
print p
Above, there is a "decent bound", so i can print here the results:
j + 1
4*j + 9
2*j + 17
8*j + 17
10*j + 17
12*j + 17
4*j + 25
6*j + 25
12*j + 25
14*j + 25
16*j + 25
22*j + 25
24*j + 25
2*j + 33
8*j + 33
20*j + 33
28*j + 33
32*j + 33
Thu, 24 May 2018 12:02:37 -0500http://ask.sagemath.org/question/42408/can-we-find-gaussian-primes-pi-1-8-mathbbzi-with-npi-10000/?answer=42423#post-id-42423