[sage-devel] Combining finite/rational fields

2012-11-17 Thread Michael Orlitzky
I just opened,

  http://trac.sagemath.org/sage_trac/ticket/13720

intending to submit a patch a few minutes later, but I've hit a problem.
The current examples feature,

  sage: legendre_P(3, GF(11)(5))
  8

which works due to a quirk in Maxima's string representation of the
polynomial:

  sage: maxima.eval('legendre_p(%s,x)'%ZZ(3))
  '-6*(1-x)-5*(1-x)^3/2+15*(1-x)^2/2+1'

In Sage, this becomes,

  sage: -6*(1-x)-5*(1-x)^3/2+15*(1-x)^2/2+1
  5/2*(x - 1)^3 + 15/2*(x - 1)^2 + 6*x - 5

with division (in Maxima) replaced by rational multiplication in Sage.
This kills the last example:

  sage: GF(11)(5) / 2
  8

  sage: (1/2) * GF(11)(5)
  --
  TypeError
  ...
  TypeError: unsupported operand parent(s) for '*': 'Rational Field'
  and 'Finite Field of size 11'

So, substituting GF(11)(5) into the equation before converting it to
Sage works. But doing the entire computation in Sage fails.

How easy would this be to fix? I could convert my polynomials to Maxima
and back I guess, but that seems a little goofy.

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




Re: [sage-devel] Combining finite/rational fields

2012-11-17 Thread Robert Bradshaw
How about doing

sage: f = legendre_P(3, GF(11)['x'].gen()); f
 8*x^3 + 4*x
sage: parent(f)
 Univariate Polynomial Ring in x over Finite Field of size 11
sage: f(5)
 8

However, the implementation (manipulating strings) is pretty horrid.


On Sat, Nov 17, 2012 at 8:08 PM, Michael Orlitzky mich...@orlitzky.com wrote:
 I just opened,

   http://trac.sagemath.org/sage_trac/ticket/13720

 intending to submit a patch a few minutes later, but I've hit a problem.
 The current examples feature,

   sage: legendre_P(3, GF(11)(5))
   8

 which works due to a quirk in Maxima's string representation of the
 polynomial:

   sage: maxima.eval('legendre_p(%s,x)'%ZZ(3))
   '-6*(1-x)-5*(1-x)^3/2+15*(1-x)^2/2+1'

 In Sage, this becomes,

   sage: -6*(1-x)-5*(1-x)^3/2+15*(1-x)^2/2+1
   5/2*(x - 1)^3 + 15/2*(x - 1)^2 + 6*x - 5

 with division (in Maxima) replaced by rational multiplication in Sage.
 This kills the last example:

   sage: GF(11)(5) / 2
   8

   sage: (1/2) * GF(11)(5)
   --
   TypeError
   ...
   TypeError: unsupported operand parent(s) for '*': 'Rational Field'
   and 'Finite Field of size 11'

 So, substituting GF(11)(5) into the equation before converting it to
 Sage works. But doing the entire computation in Sage fails.

 How easy would this be to fix? I could convert my polynomials to Maxima
 and back I guess, but that seems a little goofy.

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



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