Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Support arithmetic operations for pairs of Eisenstein integers
| ResourceFunction["EisensteinIntegers"][n,"operator"] returns the result of applying unary operation "operator" to the Eisenstein integer n. | |
| ResourceFunction["EisensteinIntegers"][n1,n2,"operator"] returns the result of applying binary operation "operator" to n1 and n2. | |
| ResourceFunction["EisensteinIntegers"][n1,…,ω,"operator"] uses ω to represent the Eisenstein ring extension element  | 
 is a primitive third root of unity.
 is a primitive third root of unity. , or as
, or as  . In the latter case, the symbol used to denote the extension element, ω, must be given explicitly in all operations.
. In the latter case, the symbol used to denote the extension element, ω, must be given explicitly in all operations. .
.Find the norm of an Eisenstein integer:
| In[1]:= | ![e = 3 + 7 w;
ResourceFunction["EisensteinIntegers"][e, w, "Norm"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/6ab80f49aa620bc7.png)  | 
| Out[1]= |   | 
Find its conjugate:
| In[2]:= | ![ce = ResourceFunction["EisensteinIntegers"][e, w, "Conjugate"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/7d8865673a277b12.png)  | 
| Out[2]= |   | 
Verify that the norm is the product of the number and its conjugate:
| In[3]:= | ![ResourceFunction["EisensteinIntegers"][e, ce, w, "Times"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/7aa052562a41fcd1.png)  | 
| Out[3]= |   | 
The absolute value of an Eisenstein number is the same as that of the complex number equivalent:
| In[4]:= | ![{ResourceFunction["EisensteinIntegers"][{3, 7}, "Abs"], Abs[3 + 7 Exp[2*I*Pi/3]]}](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/27c6f3771b7fd9fc.png)  | 
| Out[4]= |   | 
Find the reciprocal of an Eisenstein integer:
| In[5]:= | ![r = ResourceFunction["EisensteinIntegers"][9 - 11 w, w, "Reciprocal"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/0109a261a9abbd1b.png)  | 
| Out[5]= |   | 
Verify that it is the reciprocal:
| In[6]:= | ![ResourceFunction["EisensteinIntegers"][9 - 11 w, r, w, "Times"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/2ada3cdb05bd2493.png)  | 
| Out[6]= |   | 
Multiply a pair of Eisenstein integers:
| In[7]:= | ![e0 = 3 + 7 w;
e1 = 2 - 7 w;
eprod = ResourceFunction["EisensteinIntegers"][e0, e1, w, "Times"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/6fcfc08d5e2ede89.png)  | 
| Out[7]= |   | 
The product cannot be a prime:
| In[8]:= | ![ResourceFunction["EisensteinIntegers"][eprod, w, "PrimeQ"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/746393fc3d7fba31.png)  | 
| Out[8]= |   | 
Show that both factors are prime:
| In[9]:= | ![Map[ResourceFunction["EisensteinIntegers"][#, w, "PrimeQ"] &, {e0, e1}]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/7ac0b844db0c7f11.png)  | 
| Out[9]= |   | 
Divide a pair of Eisenstein integers:
| In[10]:= | ![ResourceFunction["EisensteinIntegers"][9 - 11 w, 3 + 7 w, w, "Quotient"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/090b8ebca348d3a9.png)  | 
| Out[10]= |   | 
Find the quotient and remainder of a pair of Eisenstein integers:
| In[11]:= | ![{quo, rem} = ResourceFunction["EisensteinIntegers"][9 - 11 w, 3 + 7 w, w, "QuotientRemainder"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/39f481834de55cb1.png)  | 
| Out[11]= |   | 
Recover the dividend from divisor, quotient and remainder:
| In[12]:= | ![ResourceFunction["EisensteinIntegers"][
 ResourceFunction["EisensteinIntegers"][3 + 7 w, quo, w, "Times"], rem, w, "Plus"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/3a2e0d03380b2464.png)  | 
| Out[12]= |   | 
Use the ordered pair representation:
| In[13]:= | ![ResourceFunction[
 "EisensteinIntegers"][{9, -11}, {3, 7}, "QuotientRemainder"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/3bb6439a8d6de680.png)  | 
| Out[13]= |   | 
Multiply a pair of Eisenstein numbers with symbolic values for real and imaginary parts:
| In[14]:= | ![ResourceFunction[
 "EisensteinIntegers"][(a + w b), (c + w d), w, "Times"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/052dd0b1e0055acf.png)  | 
| Out[14]= |   | 
Form the dot product of two vectors of Eisenstein integers:
| In[15]:= | ![ResourceFunction[
 "EisensteinIntegers"][{3 + w, 2 + 3 w, 4 + 7 w}, {-2 - w, w, 3 + 5 w}, w, "Dot"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/4dc8d6db10ce2bfd.png)  | 
| Out[15]= |   | 
Repeat, using the list representation for the Eisenstein integers:
| In[16]:= | ![ResourceFunction[
 "EisensteinIntegers"][{{3, 1}, {2, 3}, {4, 7}}, {{-2, -1}, {0, 1}, {3, 5}}, "Dot"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/3ee00f71f13a3a35.png)  | 
| Out[16]= |   | 
Compute the GCD of a pair of Eisenstein integers:
| In[17]:= | ![e0 = 3 + 7 w;
e1 = ResourceFunction["EisensteinIntegers"][e0, 4 + 5 w, w, "Times"];
e2 = ResourceFunction["EisensteinIntegers"][e0, 6 - 7 w, w, "Times"];
g = ResourceFunction["EisensteinIntegers"][e1, e2, w, "GCD"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/1a1f4fe220680744.png)  | 
| Out[17]= |   | 
Check that it divides both inputs:
| In[18]:= | ![Map[ResourceFunction["EisensteinIntegers"][g, #, w, "DividesQ"] &, {e1, e2}]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/0c687a5c44aba6ed.png)  | 
| Out[18]= |   | 
Compute the extended GCD of this pair:
| In[19]:= | ![eg = ResourceFunction["EisensteinIntegers"][e1, e2, w, "ExtendedGCD"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/5158d4b5db4689dd.png)  | 
| Out[19]= |   | 
Show that we recover the GCD from the Bezout relation:
| In[20]:= | ![ResourceFunction["EisensteinIntegers"][{e1, e2}, eg[[2]], w, "Dot"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/17372627826779ab.png)  | 
| Out[20]= |   | 
Check that the GCD is an associate of the common factor used to form the inputs:
| In[21]:= | ![ResourceFunction["EisensteinIntegers"][g, e0, w, "AssociatesQ"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/0c94531b79738b32.png)  | 
| Out[21]= |   | 
Raise 11-7w to power 20 modulo 14+9w:
| In[22]:= | ![ResourceFunction["EisensteinIntegers"][11 - 7*w, 20, 14 + 9 w, w, "PowerMod"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/26de33e87788f602.png)  | 
| Out[22]= |   | 
Create some Eisenstein primes:
| In[23]:= | ![SeedRandom[1234];
enums = RandomInteger[{-5, 5}, {16, 2}];
eprims = Select[enums, ResourceFunction["EisensteinIntegers"][#, "PrimeQ"] &]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/1b505b873e72e74e.png)  | 
| Out[23]= |   | 
No pair are associates:
| In[24]:= | ![Table[ResourceFunction["EisensteinIntegers"][eprims[[i]], eprims[[j]],
    "AssociatesQ"], {i, Length[eprims] - 1}, {j, i + 1, Length[eprims]}] // Flatten](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/1d8ca113857818ee.png)  | 
| Out[24]= |   | 
Raise these primes to successive powers:
| In[25]:= | ![primepowers = MapIndexed[
  ResourceFunction["EisensteinIntegers"][#1, #2[[1]], "Power"] &, eprims]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/22247a3203641f56.png)  | 
| Out[25]= |   | 
Take the product of these powers:
| In[26]:= | ![powerprod = ResourceFunction["EisensteinIntegers"][primepowers, "ListTimes"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/31806a1aec5e65f5.png)  | 
| Out[26]= |   | 
Now factor it:
| In[27]:= | ![pfacs = ResourceFunction["EisensteinIntegers"][powerprod, "FactorInteger"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/76d70dd9842af60c.png)  | 
| Out[27]= |   | 
Check that each factor after the initial unit is an Eisenstein prime:
| In[28]:= | ![Map[ResourceFunction["EisensteinIntegers"][#, "PrimeQ"] &, pfacs[[2 ;;, 1]]]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/23d36bf7766924fb.png)  | 
| Out[28]= |   | 
Expand the factors to their specified powers:
| In[29]:= | ![pows = Map[
  ResourceFunction["EisensteinIntegers"][#[[1]], #[[2]], "Power"] &, pfacs]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/13f0486e11ef0610.png)  | 
| Out[29]= |   | 
Check that expanding the factorization recovers the product:
| In[30]:= | ![ResourceFunction["EisensteinIntegers"][pows, "ListTimes"] == powerprod](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/137d979eb8ec2604.png)  | 
| Out[30]= |   | 
The GCD implementation for EisensteinIntegers uses an asymptotically fast method that performs better than the standard Euclidean sequence method:
| In[31]:= | ![(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/9cdc71b5-7ff3-427e-bcab-ffb73207ea80"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/0be40adfe92b770d.png)  | 
| Out[31]= |   | 
Here is a version of the Euclidean sequence method:
| In[32]:= | ![(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/e2593eb2-8fa1-4441-90d8-dad97f8e723a"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/722c443ae39c0d19.png)  | 
Time it on the same example:
| In[33]:= | ![Timing[gcd2 = EisensteinEuclideanGCD[e1, e2];]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/2dbfbf1fca6f4644.png)  | 
| Out[33]= |   | 
Check that the results are equivalent:
| In[34]:= | ![ResourceFunction["EisensteinIntegers"][gcd, gcd2, "AssociatesQ"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/15e258136255d2bc.png)  | 
| Out[34]= |   | 
Double the size and repeat the timing:
| In[35]:= | ![(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/284cccfd-853a-411b-83f1-c7f538dfc27c"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/15b00cb1d429a6d5.png)  | 
| Out[35]= |   | 
Now repeat the Euclidean sequence computation:
| In[36]:= | ![Timing[gcd2 = EisensteinEuclideanGCD[e1, e2];]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/57b71468400e8068.png)  | 
| Out[36]= |   | 
Do this again:
| In[37]:= | ![(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/bea72e8a-276f-44cb-9277-aecc98f4175f"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/625c01963efeb97a.png)  | 
| Out[37]= |   | 
Again repeat the Euclidean sequence computation:
| In[38]:= | ![Timing[gcd2 = EisensteinEuclideanGCD[e1, e2];]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/030ab59eae80e5ee.png)  | 
| Out[38]= |   | 
Check that the known factor e0 is a divisor of the GCD:
| In[39]:= | ![ResourceFunction["EisensteinIntegers"][e0, gcd, "DividesQ"]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/4db1d0d2b7ff0df9.png)  | 
| Out[39]= |   | 
Show the first 18 powers of 7/6+ω:
| In[40]:= | ![Graphics[RegularPolygon[ReIm[#], {1/2, \[Pi]/2}, 6] & /@ Table[ResourceFunction["EisensteinIntegers"][7/6 + \[Omega], n, \[Omega], "Power"], {n, 18}] /. \[Omega] -> Exp[2 Pi I/3]]](https://www.wolframcloud.com/obj/resourcesystem/images/9e4/9e44399a-4f41-4fc9-a331-18f9f46c9889/0c844e79e53a4ee3.png)  | 
| Out[40]= |   | 
This work is licensed under a Creative Commons Attribution 4.0 International License