On 11/19/2012 02:06 AM, Nils Bruin wrote:
On Nov 18, 9:22 am, Dima Pasechnik <dimp...@gmail.com> wrote:

How different is "rational number"*"finite field element"
from division, which is also a partial operation?
(Well, I admit I don't know Sage's coersion model at all...)

Robert is probably more qualified to explain, but I'll try for now.
Both
<finite field element> * <rational number>
and
<finite field element> / <integer>
fit the pattern
<element of A> <binary operation> <element of B>

In order to make sense of this, sage tries to find/construct a
"minimal" common parent C into which both A and B coerce. Integers
coerce into finite fields; all of them. It's the operation that later
fails.

Rationals don't coerce into finite fields and that's probably a good
thing.

How damaging would it be to borrow the same mechanism as scalar
multiplication for this, i.e., define a "partial" action of Q on
GF(p)?

How much would we gain by doing so? If we don't automatically get a
"partial" action of Q on GF(p)['x'] and VectorSpace(GF(p),3) it's
probably not worth the effort.


In fact, the behavior in Sage is *inconsistent*, and I think in this particular case, the inconsistency should get priority of getting fixed over trying to enforce rigor.:


sage: GF(7)(4)*2/3
5
sage: 2/3*GF(7)(4)
TypeError: unsupported operand parent(s) for '*': 'Rational Field' and 'Finite Field of size 7'


By following precedence in evaluation, the first one works while the second one doesn't. Mathematically speaking, if the first one gives a particular answer, then the second one should also give the same answer, as should

sage: GF(7)(4)*(2/3)

which also fails because of precedence in the evaluation.

It is not like it is hard to coerce the numbers into the finite field, because the numerator and the denominators can be individually accessed by doing (2/3).numerator() and (2/3).denominator().


--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To post to this group, send email to sage-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-devel+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.


Reply via email to