On Jan 18, 2008, at 12:46 PM, William Stein wrote:
>> Oooh these are hard. We still haven't settled on consistent semantics >> for the power operator. Given the types of A and B, I'm never sure >> what to expect the type of A^B to be. For example: >> >> sage: type(Integer(2)^Rational(2)) >> <type 'sage.rings.integer.Integer'> >> >> sage: type(Integer(2)^Rational(1/2)) >> <class 'sage.calculus.calculus.SymbolicArithmetic'> >> >> That really bothers me. > > Why do you think the type of an expression should be trivial to > determine from the inputs to the expression? This would be nice, > but it really makes no sense to expect in something as complicated > as a computer algebra system. Of course, we could make it so > a^b has either the type of a, the type of b, or raises an error. > That's > how it used to be. But then so many things don't work, or become much > harder, or frustrating if you actually want to _use_ Sage. I think we should try to make the types easy to figure out as often as we can. For example, the fact that "5/1" gives you a rational instead of an integer is I think a Good Thing. It means that it's easier to write code that uses the / operator, the system is more predictable. But I agree ^ is much more complicated, and I can't see how to do it. >>>> Certaily x.inverse() should return an error for non-units. >>> >>> No it shouldn't. It should compute the inverse as an element of a >>> natural >>> larger structure. >> >> Huh? How do you do this? What's the inverse of 2 mod 6? What is the >> larger structure? If anything it's the localisation, but that's not >> "larger". > > An error. You only do this when it makes sense. E.g., if A is a > matrix > with integer entries, there is a reasonably natural place in which to > compute the inverse of A, namely matrices over the rationals. To say, > "sorry you can't do that", will just make Sage that much harder to > use. > Inverting 2 mod 6 is completely different, since there is no standard > agreed upon meaning, since there is no ring that contains Z/6Z in > which > 2 is invertible. Sounds fine. david --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---