Why does the code not work?

74 Views Asked by At

I want to write a program which gives me all prime ideals in the ring of integers $\mathcal{O}_K $, $K= \mathbb{Q}(\sqrt{-5})$ . They should have the property to be principal. My problem is that the condition if(J.gens()[0]-1 in L): does not really work. By this I want that the generator of the principal ideal minus $1$ is contained in the ideal L.

   sage: K.<a> = QuadraticField(-5)
             cl = K.class_group()
              g = cl.gens()[0]
               L=K.fractional_ideal(-a-1)
    sage: for norm, ideals in K.ideals_of_bdd_norm(10).items():
             for J in ideals:
                 if (J.is_prime()):
                   if  (cl(J)==g^4):
                     if(J.gens()[0]-1 in L):
                         print norm,J
1

There are 1 best solutions below

0
On BEST ANSWER

I answered this on Ask SageMath:

What you are looking for is J.gens_reduced() instead of J.gens().

See the documentation of gens_reduced:

Express this ideal in terms of at most two generators, and one if possible.

By contrast, gens() are just the generators which were given when the ideal was constructed (in this case, by Sage).