Gaussian Prime

Author

Eric W. Weisstein
April 21, 2011

This notebook downloaded from http://mathworld.wolfram.com/notebooks/NumberTheory/GaussianPrime.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/GaussianPrime.html.

©2011 Wolfram Research, Inc. except for portions noted otherwise

Code

GaussianPrimeQ[a_Integer]:=PrimeQ[Abs[a]]&&Mod[Abs[a],4]==3
GaussianPrimeQ[b_Complex]:=PrimeQ[Abs[b]]&&Mod[Abs[b],4]==3 /; Re[b]==0
GaussianPrimeQ[z_Complex]:=PrimeQ[Abs[z]^2]

List

Comparing Built-In and User-Defined

p1=Select[Flatten[Table[x+I y,{x,-5,5},{y,-5,5}]],GaussianPrimeQ]

p2=Select[Flatten[Table[x+I y,{x,-5,5},{y,-5,5}]],PrimeQ[#,GaussianIntegers->True]&]

p1==p2

Integer Gaussian Primes

Select[Table[x,{x,-50,50}],PrimeQ[#,GaussianIntegers->True]&]

Radial Plot

V5

<<Utilities`Plot`

Square[i_,j_]:=Polygon[{{i-.5,j-.5},{i-.5,j+.5},{i+.5,j+.5},{i+.5,j-.5}}]

GaussianPrimesPlot[r_]:=Module[{x,y,gp},
gp=Select[Flatten[Table[x+I y,{x,-r,r},{y,-r,r}]],Abs[#]≤r&&PrimeQ[#,GaussianIntegers->True]&];
Show[Graphics[Square[Re[#],Im[#]]&/@gp],AspectRatio->Automatic]
]

GaussianPrimesPlot[r_,opts___]:=Module[{x,y,gp},
PixelPerfect[
Table[If[x^2+y^2<r^2&&PrimeQ[x+I y,GaussianIntegers->True],0,1],{x,-r,r},{y,-r,r}],
opts
]
]

Show[GaussianPrimesPlot[Ceiling[Sqrt[1000]],BlockSize->4]]

Show[GaussianPrimesPlot[50,BlockSize->3]]

V6

SquareBox[i_,j_]:=Polygon[{{i-.5,j-.5},{i-.5,j+.5},{i+.5,j+.5},{i+.5,j-.5}}]

GaussianPrimesPlot[r_]:=Module[{x,y,gp},
gp=Select[Flatten[Table[x+I y,{x,-r,r},{y,-r,r}]],Abs[#]≤r&&PrimeQ[#,GaussianIntegers->True]&];
Show[Graphics[SquareBox[Re[#],Im[#]]&/@gp],AspectRatio->Automatic]
]

GaussianPrimesPlot[r_,opts___]:=Module[{x,y,gp},
ArrayPlot[
Table[If[x^2+y^2<r^2&&PrimeQ[x+I y,GaussianIntegers->True],1,0],{x,-r,r},{y,-r,r}],
opts
]
]

GaussianPrimesPlot[50,PixelConstrained->3,Frame->False]

GaussianPrimesPlot[50,Frame->False]

Counts

Length[gps=With[{r=10^3},Select[Flatten[Table[x+I y,{x,-r,r},{y,-Floor[Sqrt[r^2-x^2]],Floor[Sqrt[r^2-x^2]]}]],PrimeQ[#,GaussianIntegers->True]&]
]]//Timing

And@@(PrimeQ[#,GaussianIntegers->True]&/@gps)

Table[Count[gps,_?(Abs[#]≤10^n&)],{n,0,3}]

Large Gaussian Primes

(((28 (((3233 Primorial(2003)))^9)-6466 Primorial(2003)))^4)+i (((32 (((3233 Primorial(2003)))^8)-1))^4)

Primorial[n_]:=Times@@Prime[Range[PrimePi[n]]]

Based on http://primes.utm.edu/primes/page.php?id=70478

p=(28*(3233*Primorial[2003])^9-6466Primorial[2003])^8 + (32*(3233*Primorial[2003])^8-1)^8 ;

IntegerLength/@Through[{Re,Im,Abs[#]^2&}[p]]

p=(28*(3233*Primorial[2003])^9-6466*Primorial[2003])^4+I*(32*(3233*Primorial[2003])^8-1)^4;

IntegerLength/@Through[{Re,Im,Abs[#]^2&}[p]]

PrimeQ[p,GaussianIntegers->True]//Timing

From http://groups.yahoo.com/group/primeform/message/6620

1372930^65536 +I

-1+(((1+i))^991961)

IntegerLength/@Through[{Re,Im,Abs[#]^2&}[(((1+I))^991961)−1]]

PrimeQ[(((1+I))^991961)−1,GaussianIntegers->True]//Timing

-1+(((1+i))^1203793)

IntegerLength/@Through[{Re,Im,Abs[#]^2&}[(((1+I))^1203793)−1]]

PrimeQ[(((1+I))^1203793)−1,GaussianIntegers->True]//Timing