[sage-support] Two possible bugs in number fields
Dear all, 1. In number fields, some elements are considered as prime, which is not mathematically correct: | sage:S.x=NumberField(x^2+5) sage:S(11).is_prime() True | | In the field of rational number, the answer is correct: | sage:QQ(11).is_prime() False | Is that a bug? | 2. When one defines a number field as above, one cannot define a new number field anymore: | sage:S.x=NumberField(x^2+5) sage:R.y=NumberField(x^2+7) Traceback(most recent call last): ... ValueError:variable names must be alphanumeric,but one is'Rational Field'which isnot. sage:NumberField(x^2+7,'x') |Traceback(most recent call last): ... ValueError:variable names must be alphanumeric,but one is'Rational Field'which isnot. | | Note that this does not happen if the first number field S has be defined as follows: | sage: S = NumberField(x^2+5, 'x') sage: NumberField(x^2+7,'x') Number Field in x with defining polynomial x^2 + 7 sage: R.t = NumberField(x^2+7) sage: R Number Field in t with defining polynomial x^2 + 7 | How may this be corrected? Thanks in advance! Bruno P.S.: I encounter these bugs while reading this question http://ask.sagemath.org/question/26695/check-if-element-is-irreducible-in-algebraic-number-field/ on ask.sagemath.org which asks for an is_irreducible() method in number field (or maybe in their rings of integers). -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] Two possible bugs in number fields
On 2015-05-04 14:39, Bruno Grenet wrote: Dear all, 1. In number fields, some elements are considered as prime, which is not mathematically correct: | sage:S.x=NumberField(x^2+5) sage:S(11).is_prime() True This is really due to S.ideal(11) returning a *fractional* ideal. I think it's difficult to change that now. 2. When one defines a number field as above, one cannot define a new number field anymore: | sage:S.x=NumberField(x^2+5) sage:R.y=NumberField(x^2+7) Traceback(most recent call last): ... ValueError:variable names must be alphanumeric,but one is'Rational Field'which isnot. When defining R, x is not a polynomial variable, but an element of S. The line R.y = NumberField(x^2+7) really is R.y = NumberField(S(2)) The only bug here might be that the error message is very confusing. It comes from sage: S(2).polynomial(QQ) ValueError: variable names must be alphanumeric, but one is 'Rational Field' which is not. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] Two possible bugs in number fields
On 4 May 2015 at 13:48, Jeroen Demeyer jdeme...@cage.ugent.be wrote: On 2015-05-04 14:39, Bruno Grenet wrote: Dear all, 1. In number fields, some elements are considered as prime, which is not mathematically correct: | sage:S.x=NumberField(x^2+5) sage:S(11).is_prime() True This is really due to S.ideal(11) returning a *fractional* ideal. I think it's difficult to change that now. 2. When one defines a number field as above, one cannot define a new number field anymore: | sage:S.x=NumberField(x^2+5) sage:R.y=NumberField(x^2+7) Traceback(most recent call last): ... ValueError:variable names must be alphanumeric,but one is'Rational Field'which isnot. Another comment: in your first number field definition you are tacitly using the fact that on startup, Sage assigns to the python identifier 'x' the value of the symbolic variable x. That is why you can say (immediately after startup): K = NumberField(x^2+5) but if you were to try K = NumberField(y^2+5) it would raise an error since y is not defined. Then, you are reusing that identifier 'x' to be the generator of your first field, since the line S.x=NumberField(x^2+5) is expanded by the preprocessor: sage: preparse('S.x=NumberField(x^2+5)') S = NumberField(x**Integer(2)+Integer(5), names=('x',)); (x,) = S._first_ngens(1) I recommend two things: (1) that you do not use names for the generators of your number fields that look like indeterminates (x, y); (2) that you do not reply on the pre-definition of 'x', but define it yourself to be a generator of the polynomial ring over QQ which is where the polynomials x^2+5 and x^2+7 really belong: sage: x = polygen(QQ) sage: S.a = NumberField(x^2+5) sage: R.b = NumberField(x^2+7) sage: a^2, b^2 (-5, -7) John Cremona When defining R, x is not a polynomial variable, but an element of S. The line R.y = NumberField(x^2+7) really is R.y = NumberField(S(2)) The only bug here might be that the error message is very confusing. It comes from sage: S(2).polynomial(QQ) ValueError: variable names must be alphanumeric, but one is 'Rational Field' which is not. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.