On 22 October 2016 at 19:08, John Cremona <[email protected]> wrote: > On 22 October 2016 at 17:28, Vincent Delecroix > <[email protected]> wrote: >> On 22 October 2016 at 16:10, Ralf Stephan <[email protected]> wrote: >>> On Saturday, October 22, 2016 at 4:04:55 PM UTC+2, John Cremona wrote: >>>> >>>> So Ralf, do you want to catch the case where the exponent in QQbar is >>>> actually rational and then do what QQbar already knows how to do >>>> (raise to a rational power), returning an element of QQbar; and raise >>>> an Error of some kind in the other case? >>> >>> >>> Exactly, if noone is objecting. >> >> I am strongly objecting. The behavior of any operation in Sage is that >> the parent of op(a, b) should only depend on the operator op, >> parent(a) and parent(b). Powers are a bit special but not enough to >> use conversion instead of coercion. > > Counterexamples: > > sage: parent(RR(1).sqrt()) > Real Field with 53 bits of precision > sage: parent(RR(-1).sqrt()) > Complex Field with 53 bits of precision > > and: > > sage: parent(QQ(1).sqrt()) > Rational Field > sage: parent(QQ(2).sqrt()) > Symbolic Ring
This is indeed a bad behavior. I would prefer sqrt to behave uniformly as it does for number fields in the following example sage: K.<a> = NumberField(x^3 - x - 1) sage: K(4).sqrt() 2 sage: _.parent() Number Field in a with defining polynomial x^3 - x - 1 sage: K(2).sqrt() Traceback (most recent call last): ... ValueError: 2 not a square in Number Field in a with defining polynomial x^3 - x - 1 sqrt is much more useful as an internal but partial operation. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
