First time here? Check out the FAQ!

Ask Your Question
1

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

asked 4 years ago

Moondoggy gravatar image

I am new to sage. This program should give me all prime ideals in OK with K=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
Preview: (hide)

Comments

1 Answer

Sort by » oldest newest most voted
2

answered 4 years ago

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)]
Preview: (hide)
link

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: 4 years ago

Seen: 453 times

Last updated: Jun 08 '20