Class groups¶
This module allows to work with ideal classes and compute the class numbers of quadratic integer rings.
To compute operations with ideal classes within the same quadratic ring,
all ideal classes must be created as IdealClass
objects. To do so:
Create the quadratic integer ring \(\mathcal{O}_{\mathbb{Q}[\sqrt{d}]}\) with the function
QuadraticIntegerRing
.>>> O = QuadraticIntegerRing(-5)Create the representative ideal of the ideal class.
>>> generator1 = O(3) >>> generator2 = O("1 + sqrt(-5)") >>> I = Ideal(generator1, generator2)Create the ideal class object with the ideal as argument and use the available operators and methods.
>>> a = IdealClass(I) >>> a.order 2
To compute the class group of a quadratic integer ring (i.e. the class number
and the generators of the class group), simply instance the class
ClassGroup
and access its attributes class_number
and
generators
.
Note that this module, class_group
, 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 * >>> O = QuadraticIntegerRing(-5) >>> a = IdealClass( Ideal(O(2), O("1 + sqrt(-5)")) )Import only the package, and use the package’s identifier to access the classes and functions:
>>> import qipy >>> O = qipy.QuadraticIntegerRing(-5) >>> I = qipy.Ideal(O(2), O("1 + sqrt(-5)")) >>> a = qipy.IdealClass(I)
-
class
IdealClass
(ideal, name=None)¶ Represent an ideal class of a quadratic integer ring.
>>> Zi = QuadraticIntegerRing(-1) >>> I = Ideal(Zi(3)) >>> a = IdealClass(I) >>> a [<3>] >>> a == a * a True >>> O = QuadraticIntegerRing(-5) >>> J = Ideal(O(2), O("1 + sqrt(-5)")) >>> b = IdealClass(J) >>> b [<1 + sqrt(5)*I,2*sqrt(5)*I>] >>> b ** 2 [<-2,2*sqrt(5)*I>]
This class supports the operators
*
and**
with their natural meaning.Parameters: - ideal – a representative of the ideal class
- name – an optional name for the representative.
-
O
¶ the quadratic integer ring related to the ideal class.
-
representative
¶ a representative of the ideal class.
-
inverse
()¶ Return the inverse of the ideal class.
>>> Zi = QuadraticIntegerRing(-1) >>> a = IdealClass(Ideal(Zi(3))) >>> a [<3>] >>> a.inverse() [<1>] >>> O = QuadraticIntegerRing(-5) >>> b = IdealClass(Ideal(O(2), O("1 + sqrt(-5)"))) >>> b [<1 + sqrt(5)*I,2*sqrt(5)*I>] >>> b.inverse() [<1 + sqrt(5)*I,2*sqrt(5)*I>]
-
is_trivial
()¶ Test whether the ideal class is the trivial class.
>>> Zi = QuadraticIntegerRing(-1) >>> a = IdealClass(Ideal(Zi(3))) >>> a [<3>] >>> a.is_trivial() True >>> O = QuadraticIntegerRing(-5) >>> b = IdealClass(Ideal(O(2), O("1 + sqrt(-5)"))) >>> b [<1 + sqrt(5)*I,2*sqrt(5)*I>] >>> b.is_trivial() False
-
order
¶ The order of the ideal class, that is, the smallest positive intenger such that
self ** order
is the trivial class.>>> Zi = QuadraticIntegerRing(-1) >>> a = IdealClass(Ideal(Zi(3))) >>> a [<3>] >>> a.order 1 >>> O = QuadraticIntegerRing(-5) >>> b = IdealClass(Ideal(O(2), O("1 + sqrt(-5)"))) >>> b [<1 + sqrt(5)*I,2*sqrt(5)*I>] >>> b.order 2
-
classmethod
trivial_class
(d)¶ Return the trivial class (with the unit ideal as representative) of the quadratic integer ring defined by \(d\).
>>> IdealClass.trivial_class(-1) [<1>]
Returns: the trivial ideal class. Return type: IdealClass
-
class
ClassGroup
(d, verbose=False)¶ Represent the class group of a quadratic integer ring.
>>> G = ClassGroup(-1) >>> G.class_number 1 >>> G.generators [[<1>]] >>> H = ClassGroup(-14, verbose=True) List of generators (including dependent): [[p2], [p3]] Testing whether [p3] is dependent: [p3] is independent Testing whether [p2] is dependent: Dependency relation found: [<1>] == [p2] * [p3]^2 [p2] removed from the list of generators Class number: 4 Generators: [[p3]]
The non-trivial generators are represented as
[pX]
wherepX
is a prime ideal that divides \(\langle X \rangle\) (the ideal generated by \(X\)).Warning
In the of the object, the generators and the class number are computed. Therefore, the creation of the object may take some time.
Parameters: - d – a non-square free integer that defines the quadratic integer ring.
- verbose – if
True
, information about the computation process of the class group is printed.
-
O
¶ the quadratic integer ring related to the ideal class.
-
generators
¶ a list of ideal classes that span the class group.
-
class_number
¶ the order of the class group.