On Sep 12, 2:50 pm, Maarten Derickx <m.derickx.stud...@gmail.com>
wrote:
> sage: a=GF(7)(0)
> sage: a^a
> ...
> ArithmeticError: 0^0 is undefined.
>
> sage: a=Integers(7)(0)
> sage: a^a
> ...
> ArithmeticError: 0^0 is undefined.

I think something else is going wrong here. It's not so much that the
exponent is 0, it's that the exponent is a finite field element! Sage
seems frighteningly unconcerned with that, though:

sage: k=GF(7)
sage: a=k(2)
sage: a^a
4
sage: a^(k(-1)) #would Fermat find this amusing?
1

This should be raising an error. Finite fields do no act on themselves
via exponentiation. One could have Integers(6) act on it but it's
probably not worth the effort.

Checking a little further:

sage: parent(2^a)
Integer Ring
sage: cm = sage.structure.element.get_coercion_model()
sage: cm.explain(2,a,operator.pow)
Coercion on left operand via
    Natural morphism:
      From: Integer Ring
      To:   Finite Field of size 7
Arithmetic performed after coercions.
Result lives in Finite Field of size 7
Finite Field of size 7

I guess the last examples show that the coercion framework is indeed
not used for pow (explain expects an answer in k, but in actuality it
lives in ZZ). Apparently, GF(7) is silently lifted to ZZ prior to
exponentiation?

Doesn't the coercion framework support actions (such as scalar
multiplication etc.)? Exponentiation is probably most cleanly handled
via that, because it very rarely is a "binary operation" in the usual
sense.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to