Ask Your Question
1

How do I write a code which gives me all prime ideals up to a specific norm?

asked 2020-06-07 13:50:15 +0100

Moondoggy gravatar image

I am new to sage. This program should give me all prime ideals in $\mathcal{O}_K$ with $K=\mathbb{Q}(i)$ up to norm $5$. So far I have :

sage: K.<a> = QuadraticField(-1)
for j in range(5):
L= K.ideals_of_bdd_norm(j)
if L.is_prime():
print L
edit retag flag offensive close merge delete

Comments

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-06-08 12:47:12 +0100

tmonteil gravatar image

You just have to do:

sage: K.ideals_of_bdd_norm(5)
{1: [Fractional ideal (1)],
 2: [Fractional ideal (a + 1)],
 3: [],
 4: [Fractional ideal (2)],
 5: [Fractional ideal (2*a + 1), Fractional ideal (-a - 2)]}

What you get is a Python dictionary, whose keys are the norms, and the values are Python lists of the ideals with given norm.

For example:

sage: K.ideals_of_bdd_norm(5)[3]
[]

is an empty list since there is no ideal with norm 3

sage: K.ideals_of_bdd_norm(5)[5]
[Fractional ideal (2*a + 1), Fractional ideal (-a - 2)]

is a list with 2 elements: you can access them as follows:

sage: K.ideals_of_bdd_norm(5)[5][0]
Fractional ideal (2*a + 1)
sage: K.ideals_of_bdd_norm(5)[5][1]
Fractional ideal (-a - 2)

Now, if you want all those ideals without caring about their norm, you can do:

sage: d = K.ideals_of_bdd_norm(5)
sage: [f for i in d for f in d[i]]
[Fractional ideal (1),
 Fractional ideal (a + 1),
 Fractional ideal (2),
 Fractional ideal (2*a + 1),
 Fractional ideal (-a - 2)]

or

sage: flatten(d.values())
[Fractional ideal (1),
 Fractional ideal (a + 1),
 Fractional ideal (2),
 Fractional ideal (2*a + 1),
 Fractional ideal (-a - 2)]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-06-07 13:50:15 +0100

Seen: 428 times

Last updated: Jun 08 '20