# QiPy documentation¶

QiPy is a Python library to work with quadratic integers. Well-known examples are Gaussian integers and Eisenstein integers. Besides, QiPy implements ideals, ideal classes and class groups of quadratic integer rings.

This library has been exhaustively tested with unit tests and property testing.

## Installation¶

QiPy is written in Python 3 and uses the Python library SymPy. Therefore, Python 3 and SymPy must be installed in your computer.

The easiest way to install QiPy is with pip :

pip3 install qipy


## Examples of usage¶

Computing $$\frac{1 + i}{1 - i}$$ in $$\mathbb{Z}[i]$$:

>>> Zi = QuadraticIntegerRing(-1)
>>> Zi("1 + I") / Zi("1 - I")
I


Factoring $$2$$ in $$\mathbb{Z}[i]$$:

>>> Zi = QuadraticIntegerRing(-1)
>>> Zi(2).factor()
[1 + I, 1 - I]


Testing whether the ideal $$\langle 3, 1 + \sqrt{-5} \rangle$$ in $$\mathcal{O}_{\mathbb{Q}[\sqrt{-5}]}$$ is principal:

>>> O = QuadraticIntegerRing(-5)
>>> Ideal(O(3), O("1 + sqrt(-5)")).is_principal()
False


Factoring the ideal $$\langle 2 \rangle$$ in $$\mathbb{Z}[i]$$:

>>> Zi = QuadraticIntegerRing(-1)
>>> Ideal(Zi(2)).factor()
[<1 + I,2*I>, <1 + I,2*I>]


Computing the order of the ideal class with representative $$\langle 3, 1 + \sqrt{-5} \rangle$$ in $$\mathcal{O}_{\mathbb{Q}[\sqrt{-5}]}$$:

>>> O = QuadraticIntegerRing(-5)
>>> a = IdealClass(Ideal(O(3), O("1 + sqrt(-5)")))
>>> a.order
2


Computing the class number of $$\mathcal{O}_{\mathbb{Q}[\sqrt{-5}]}$$:

>>> G = ClassGroup(-5)
>>> G.class_number
2


## Contents¶

QiPy has been implemented in three main modules. See the documentation of each module for descriptions and examples of their funcionalities.