On Jan 18, 2008 8:53 AM, David Harvey <[EMAIL PROTECTED]> wrote:
>
>
> On Jan 18, 2008, at 11:32 AM, William Stein wrote:
>
> >> Let A be a matrix not over ZZ or QQ:
> >>
> >>   A.adjoint()
> >>   A.inverse()
> >>
> >> are not implemented.
> >
> > I don't think they should be.   There are already (at least) 3 ways
> > to do this:
>
> Wait a sec.... I agree with David K on the adjoint issue.

I'm sorry -- I was _only_ talking about "inverse".

> The adjoint
> doesn't require the fraction field to even be constructed, and it
> makes perfect sense over non-domains.

True.  I agree with him about adjoint.

> > sage: A = random_matrix(ZZ,2)
> > sage: ~A
> >
> > [ 1/34  1/17]
> > [-6/17  5/17]
> > sage: A.__invert__()
> >
> > [ 1/34  1/17]
> > [-6/17  5/17]
> > sage: A^(-1)
> >
> > [ 1/34  1/17]
> > [-6/17  5/17]
>
> I vaguely recall being stung several times by the lack of an inverse
> () method. For someone who doesn't know python that well, neither ~
> nor __invert__ are obvious alternatives. I don't think it would hurt
> at all to have an inverse() method.

I'm dubious.  That sure is a lot of different ways to do the same thing
(which is very unpythonic), and it adds to confusion because this inverse
method will only work for (some) Sage Elements, but of course won't
be available for any builtin Python numeric type, or anything in any
third party library that Sage uses.

> >>  For x a commutative ring element:
> >>
> >>   x.inverse()
> >>
> >> is not implemented even if x^-1 exists.
> >
> > Same remark as above.
> >
> >> sage: x = 7
> >> sage: type(x)
> >> <type 'sage.rings.integer.Integer'>
> >> sage: x^-1
> >> 1/7
> >> sage: type(x^-1)
> >> <type 'sage.rings.rational.Rational'>
> >> sage: x = -1
> >> sage: type(x^-1)
> >>
> >> Should the field of fractions be created?
>
> 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.

>
> >> 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.

 -- William
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to