Is there any code in sage which calculates the ideals in a quadratic field?

143 Views Asked by At

Consider $K=\mathbb{Q}(\sqrt{5})$. I want to find an ideal in the ring of integers
$\mathcal{O}_K$ which is coprime to $5N$ for $N\in \mathbb{N}$ by using sage.

1

There are 1 best solutions below

0
On

You can ask Sage for all ideals with norm less than some bound as follows:

sage: K.<sqrt5> = QuadraticField(5)
sage: K.ideals_of_bdd_norm(10)
{1: [Fractional ideal (1)],
 2: [],
 3: [],
 4: [Fractional ideal (2)],
 5: [Fractional ideal (-sqrt5)],
 6: [],
 7: [],
 8: [],
 9: [Fractional ideal (3)],
 10: []}

this gives a list of ideals of given norm for each norm $N \in \mathbf Z_{\ge 0}$.

We can find primes above specific rational primes also

sage: K.prime_above(5)
Fractional ideal (-sqrt5)
sage: K.prime_factors(37)
[Fractional ideal (37)]
sage: K.prime_factors(59)
[Fractional ideal (7/2*sqrt5 + 3/2), Fractional ideal (7/2*sqrt5 - 3/2)]