Skip to content

QuadraticIntegers ​

The ring of integers of Q(d)\mathbb{Q}(\sqrt d): Z[ω]\mathbb{Z}[\omega] with ω=(−1+d)/2\omega = (-1 + \sqrt d)/2 when d≡1(mod4)d \equiv 1 \pmod 4, else d\sqrt d.

QuadraticIntegers(d)the ring of integers of Q(d)\mathbb{Q}(\sqrt d), for a non-square integer dd; a square factor of dd names the same field
SageMathQuadraticField(d).ring_of_integers()
Typed signatures
TypePackageApplies
(integer) -> set<quadratic_integer>number-theoryalways

Domain: Number theory

Details
  • A value for the Over option: IsPrime(x, Over -> QuadraticIntegers(-5)) asks whether xx is prime in Z[−5]\mathbb{Z}[\sqrt{-5}]. IsPrime, IsComposite, FactorInteger, Divisors, PrimeNu, PrimeOmega, MoebiusMu and IsSquareFree read it
  • QuadraticIntegers(-1) is GaussianIntegers, answered with the Gaussian conventions
  • Primality holds in every ring: xx is prime when the ideal (x)(x) is prime. Most of these rings do not factor uniquely (6=2⋅3=(1+−5)(1−−5)6 = 2 \cdot 3 = (1 + \sqrt{-5})(1 - \sqrt{-5}) in Z[−5]\mathbb{Z}[\sqrt{-5}]), so FactorInteger, Divisors and the counting heads answer only where the class number is 1, and stay unevaluated elsewhere
  • An irreducible that is not prime is not composite either: IsComposite(2, Over -> QuadraticIntegers(-5)) is False, and so is IsPrime
  • The guide Quadratic integers draws these rings as lattices

Examples

Basic #

2 is irreducible in ℤ[√−5] but not prime: it divides (1 + √−5)(1 − √−5) without dividing either

live ↗
InIsPrime(2,KeyValuePair⁡(Over,QuadraticIntegers(−5)))\mathrm{IsPrime}(2, \operatorname{KeyValuePair}(\mathrm{Over}, \mathrm{QuadraticIntegers}(-5)))OutFalse\mathrm{False}

nor composite: it has no proper factorization

live ↗
InIsComposite(2,KeyValuePair⁡(Over,QuadraticIntegers(−5)))\mathrm{IsComposite}(2, \operatorname{KeyValuePair}(\mathrm{Over}, \mathrm{QuadraticIntegers}(-5)))OutFalse\mathrm{False}
live ↗
InIsPrime(1+−5,KeyValuePair⁡(Over,QuadraticIntegers(−5)))\mathrm{IsPrime}(1+\sqrt{-5}, \operatorname{KeyValuePair}(\mathrm{Over}, \mathrm{QuadraticIntegers}(-5)))OutFalse\mathrm{False}

6 = 2 · 3 = (1 + √−5)(1 − √−5): no prime factorization to give

live ↗
InFactorInteger(6,KeyValuePair⁡(Over,QuadraticIntegers(−5)))\mathrm{FactorInteger}(6, \operatorname{KeyValuePair}(\mathrm{Over}, \mathrm{QuadraticIntegers}(-5)))OutFactorInteger(6,(Over,QuadraticIntegers(−5)))\mathrm{FactorInteger}(6, (\mathrm{Over},\mathrm{QuadraticIntegers}(-5)))

7 = (1 + 2√2)(−1 + 2√2) in ℤ[√2]

live ↗
InFactorInteger(7,KeyValuePair⁡(Over,QuadraticIntegers(2)))\mathrm{FactorInteger}(7, \operatorname{KeyValuePair}(\mathrm{Over}, \mathrm{QuadraticIntegers}(2)))Out[(1+22,1),(22−1,1)]\bigl\lbrack(1+2\sqrt{2},1), (2\sqrt{2}-1,1)\bigr\rbrack
Scope #

7 splits in the Eisenstein integers; the unit comes first

live ↗
InFactorInteger(7,KeyValuePair⁡(Over,QuadraticIntegers(−3)))\mathrm{FactorInteger}(7, \operatorname{KeyValuePair}(\mathrm{Over}, \mathrm{QuadraticIntegers}(-3)))Out[(12−−32,1),(2+−3,1),(52+−32,1)]\bigl\lbrack(\frac{1}{2}-\frac{\sqrt{-3}}{2},1), (2+\sqrt{-3},1), (\frac{5}{2}+\frac{\sqrt{-3}}{2},1)\bigr\rbrack

QuadraticIntegers(-1) is GaussianIntegers

live ↗
InFactorInteger(5,KeyValuePair⁡(Over,QuadraticIntegers(−1)))\mathrm{FactorInteger}(5, \operatorname{KeyValuePair}(\mathrm{Over}, \mathrm{QuadraticIntegers}(-1)))Out[(−i,1),(1+2i,1),(2+i,1)]\bigl\lbrack(-i,1), (1+2i,1), (2+i,1)\bigr\rbrack
About
Examples7
CrosswalkSageMath ×2mathlib4

Implementation

mappedwolframpackages/oracle/src/mappings.ts

Wolfram has no ring-of-integers value to pass as a domain: its number-theory heads take GaussianIntegers -> True for Z[i] only, and NumberFieldClassNumber and friends take an algebraic number, not a ring.

mappedsagepackages/oracle/src/mappings.ts

See also: QuadraticInteger, GaussianIntegers, IsPrime, FactorInteger