The is_principal() method for fractional ideals

6 views
Skip to first unread message

Kevin McGown

unread,
Aug 23, 2007, 10:40:34 PM8/23/07
to sage-forum
William,

In SAGE 2.8 it seems there is a problem with the is_principal method
for fractional ideals in a number field. In the code below I create
the same ideal in two different ways and obtain two different answers
from is_principal (True and False).

K = QuadraticField(-119,'a')
P2 = K.ideal([2]).factor()[0][0]
I = P2^5
a = K.0
J = K.ideal([1/2*a+3/2])
I==J
I.is_principal()
J.is_principal()

I believe the problem is with the following line in the is_principal()
method:

if len (self.gens()) <= 1:

Instead it should read:

if len (self.gens_reduced()) <= 1:

Not 100% sure, but I thought I would bring it to your attention.

- Kevin

mabshoff

unread,
Aug 24, 2007, 1:19:01 AM8/24/07
to sage-forum

On Aug 24, 4:40 am, Kevin McGown <kmcg...@math.ucsd.edu> wrote:
> William,
>
> In SAGE 2.8 it seems there is a problem with the is_principal method
> for fractional ideals in a number field. In the code below I create
> the same ideal in two different ways and obtain two different answers
> from is_principal (True and False).
>
> K = QuadraticField(-119,'a')
> P2 = K.ideal([2]).factor()[0][0]
> I = P2^5
> a = K.0
> J = K.ideal([1/2*a+3/2])
> I==J
> I.is_principal()
> J.is_principal()
>

Hello Kevin,

with Sage 2.8.2 I get:

sage: K = QuadraticField(-119,'a')
sage: P2 = K.ideal([2]).factor()[0][0]
sage: I = P2^5
sage: a = K.0
sage: J = K.ideal([1/2*a+3/2])
sage: I==J
True

So, could you please test after you upgrade Sage if the problem is
gone there, too?

> I believe the problem is with the following line in the is_principal()
> method:
>
> if len (self.gens()) <= 1:
>
> Instead it should read:
>
> if len (self.gens_reduced()) <= 1:
>
> Not 100% sure, but I thought I would bring it to your attention.
>
> - Kevin

Cheers,

Michael

mabshoff

unread,
Aug 24, 2007, 1:27:43 AM8/24/07
to sage-forum

On Aug 24, 7:19 am, mabshoff <Michael.Absh...@fsmath.mathematik.uni-

Sorry Kevin,

I am an idiot and in need of sleep. You are right:

sage: I.is_principal()
False
sage: J.is_principal()
True

I files this as ticket #487 and attached your suggested fix.

Cheers,

Michael

Kevin McGown

unread,
Aug 24, 2007, 2:50:29 AM8/24/07
to sage-forum
Michael,

Thanks for adding the ticket. I guess I should have upgraded first
before posting the bug. Good to know I'm not crazy though.

Regards,
Kevin

Kevin McGown

unread,
Aug 26, 2007, 5:26:58 PM8/26/07
to sage-forum
Hello everyone,

I think my fix above was incorrect. The relevant file is:
/sage-2.8.2-i386-Darwin/local/lib/python2.5/site-packages/sage/rings/
number_field/number_field_ideal.py

I think the problem is with the following line:
self.__is_principal = (len(v[0]) == 0) ## i.e., v[0] is the zero
vector

This above code gets 1 for the length of the zero vector. I replaced
it with this line:
self.__is_principal = (v[0] == "[0]~")

I don't know if this is the best way to do it, but it seemed to fix
the problem for me.

- Kevin

mabshoff

unread,
Aug 27, 2007, 3:12:14 AM8/27/07
to sage-forum

Hello Kevin,

I have updated the trac ticket with your suggestions, see
http://sagetrac.org/sage_trac/ticket/487#comment:1

Cheers,

Michael

Reply all
Reply to author
Forward
0 new messages