conversion issue (from QQ to GF(p))

47 views
Skip to first unread message

John Cremona

unread,
Aug 17, 2020, 9:04:41 AM8/17/20
to SAGE devel
I'm sure this used to work:

sage: F = GF(2)
sage: r = 5/3
sage: F(1)*r
TypeError: unsupported operand parent(s) for *: 'Finite Field of size
2' and 'Rational Field'

Of course I know that the could not be a coercion from QQ to GF(2) but
there is a conversion which works fine (when the denominator is odd):

sage: F(1)*F(r)
1

Has something changed, and if so, was it deliberate?

John

Nils Bruin

unread,
Aug 17, 2020, 9:40:20 AM8/17/20
to sage-devel
On Monday, August 17, 2020 at 6:04:41 AM UTC-7, John Cremona wrote:
I'm sure this used to work:

sage: F = GF(2)
sage: r = 5/3
sage: F(1)*r
TypeError: unsupported operand parent(s) for *: 'Finite Field of size
2' and 'Rational Field'

Of course I know that the could not be a coercion from QQ to GF(2) but
there is a conversion which works fine (when the denominator is odd):

It would surprise me if this used to work. Perhaps a LONG time ago? It shouldn't work, because of the reason you mention [conversions aren't used for figuring out common parents]. What *does* work is

F(1)*5/3

because it's parsed as (F(1)*5)/3: dividing by integers is something that GF(2) allows.

If one would absolutely be intent on making it work, I guess one solution could be to have a (partial) multiplicative action of Q on GF(q); or more generally: on ZZ-modules. It would just have to be a lower priority solution than common parent finding.

Justin C. Walker

unread,
Aug 17, 2020, 1:34:41 PM8/17/20
to SAGE Development
Just for the record:

> On Aug 17, 2020, at 06:40 , Nils Bruin <nbr...@sfu.ca> wrote:
>
> On Monday, August 17, 2020 at 6:04:41 AM UTC-7, John Cremona wrote:
> I'm sure this used to work:
>
> sage: F = GF(2)
> sage: r = 5/3
> sage: F(1)*r
> TypeError: unsupported operand parent(s) for *: 'Finite Field of size
> 2' and 'Rational Field'
>
> Of course I know that the could not be a coercion from QQ to GF(2) but
> there is a conversion which works fine (when the denominator is odd):
>
> It would surprise me if this used to work. Perhaps a LONG time ago? It shouldn't work, because of the reason you mention [conversions aren't used for figuring out common parents]. What *does* work is

Depends on what LONG means :-}. I tried a couple of different versions back to sage-2.11, and all fail with the same error message.

>
> F(1)*5/3
>
> because it's parsed as (F(1)*5)/3: dividing by integers is something that GF(2) allows.

This did work as well in 2.11 :-}

HTH

Justin

--
Justin C. Walker
Director
Institute for the Enhancement of the Director's Income
--
Fame is fleeting, but obscurity
just drags on and on. F&E



John Cremona

unread,
Aug 19, 2020, 3:49:27 AM8/19/20
to sage-devel
Thanks to both.  It's funny since I have some code I am sure worked OK a year ago but when I ran it this week the only change I had to make was to insert an explicit conversion from QQ to GF(ell).

Nils may be interested to know that this is for a project on making a database of modular forms mod ell.

John

Reply all
Reply to author
Forward
0 new messages