Ideals¶
This module allows to work with ideals of quadratic integer rings.
To compute operations with ideal within the same quadratic ring,
all ideals must be created as Ideal
objects. To do so:
Create the quadratic integer ring \(\mathcal{O}_{\mathbb{Q}[\sqrt{d}]}\) with the function
QuadraticIntegerRing
.>>> O = QuadraticIntegerRing(-5)Use the returned factory to create the generators of the ideal.
>>> generator1 = O(3) >>> generator2 = O("1 + sqrt(-5)")Create the ideal object with the generators as arguments and use the available operators and methods.
>>> I = Ideal(generator1, generator2) >>> I.factor() [<1 + sqrt(5)*I,3*sqrt(5)*I>]
Note that this module, ideal
, need to be imported to use
its classes and functions. There are several ways to import it:
Import all functions and classes of QiPy:
>>> from qipy import * >>> Zi = QuadraticIntegerRing(-1) >>> I = Ideal(Zi(3))Import only the package, and use the package’s identifier to access the classes and functions:
>>> import qipy >>> Zi = qipy.QuadraticIntegerRing(-1) >>> I = qipy.Ideal(Zi(3))
-
class
Ideal
(*generators)¶ Represent an ideal of a quadratic integer ring.
>>> Zi = QuadraticIntegerRing(-1) >>> I = Ideal(Zi(3)) >>> I <3> >>> J = Ideal(Zi("1 + I")) >>> J <1 + I> >>> I * J <3 + 3*I,6*I>
This class supports the operators
*
and/
(division only by prime ideals) with their natural meaning.Note
An ideal is represented by a reduced basis of two elements (as abelian group, not as ideal).
However, if at some moment it is known that the ideal is principal, its representation is changed with a generator (as ideal).
>>> Zi = QuadraticIntegerRing(-1) >>> I = Ideal(Zi("1 + I"), Zi("2*I")) >>> I <1 + I,2*I> >>> I.is_principal() True >>> I <1 + I>
Parameters: generators – a sequence of quadratic integers (of the same quadratic ring) that span the ideal. -
O
¶ the quadratic integer ring related to the ideal.
-
norm
¶ the norm of the ideal.
-
basis
¶ a list of two quadratic integers that span the ideal.
-
contain
(element)¶ Test whether the ideal contains an element.
>>> Zi = QuadraticIntegerRing(-1) >>> I = Ideal(Zi(3)) >>> I.contain(Zi(3)) True >>> I.contain(Zi(1)) False
Note that the element must be a quadratic integer of the same ring as the ideal.
-
divide
(other)¶ Test whether the ideal divides other ideal.
>>> Zi = QuadraticIntegerRing(-1) >>> I = Ideal(Zi("1 + I")) >>> I.divide(Ideal(Zi(2))) True
-
factor
()¶ Factor the ideal as a product of prime ideals.
>>> Zi = QuadraticIntegerRing(-1) >>> I = Ideal(Zi(2)) >>> I <2> >>> factors = I.factor() >>> factors [<1 + I,2*I>, <1 + I,2*I>] >>> factors[0] * factors[1] <-2,2*I>
Returns: the prime factors. Return type: List[Ideal]
-
generator
¶ A quadratic integer that spans the ideal if it is principal. If it isn’t, it returns
None
.>>> Zi = QuadraticIntegerRing(-1) >>> Ideal(Zi("1 + I"), Zi("2*I")).generator 1 + I >>> O = QuadraticIntegerRing(-5) >>> Ideal(O(3), O("1 + sqrt(-5)")).generator is None True
-
is_prime
()¶ Test whether the ideal is prime.
>>> Zi = QuadraticIntegerRing(-1) >>> Ideal(Zi(2)).is_prime() False >>> Ideal(Zi(3)).is_prime() True
-
is_principal
()¶ Test whether the ideal is principal.
>>> Zi = QuadraticIntegerRing(-1) >>> Ideal(Zi("1 + I"), Zi("2*I")).is_principal() True >>> O = QuadraticIntegerRing(-5) >>> Ideal(O(3), O("1 + sqrt(-5)")).is_principal() False
-
is_proper
()¶ Test whether the ideal is not the total.
>>> Zi = QuadraticIntegerRing(-1) >>> Ideal(Zi(1)).is_proper() False >>> Ideal(Zi(3)).is_proper() True
-
classmethod
prime_divisors
(p, d)¶ Return the prime ideal(s) that divides \(\langle p \rangle\) (the ideal generated by \(p\)) in the quadratic integer ring defined by \(d\).
>>> divisors = Ideal.prime_divisors(3, -1) >>> divisors [<3>] >>> divisors = Ideal.prime_divisors(5, -1) >>> divisors [<-1 + 2*I,5*I>, <-1 + 3*I,5*I>]
Returns: the prime divisors. Return type: List[Ideal]
-