Thanks, but here is the error message:

TypeError: polynomial must be over a field of characteristic 0.


On May 30, 11:09 pm, Alex Ghitza <aghi...@gmail.com> wrote:
> Hi,
>
>
>
> On Sun, May 31, 2009 at 3:34 PM, wkehowski <wkehow...@cox.net> wrote:
>
> > Hello,
>
> > I would like to take a create a function that takes a polynomial over
> > the integers and returns its roots in ZZ mod p for p a prime. I want
> > to assume the polynomial is globally defined but the prime is the
> > argument.
>
> > Here is what I have in mind but can't quite get the types right.
>
> > x = var('x') #necessary?
>
> > poly=x^2+x+1
>
> > def myroots(p):
> >    R=IntegerModRing(p)
> >    RR.<t>=R[]
> >    f=poly.substitute(x=t) #coercion here
> >    return f.roots(R)
>
> > How do I convert or coerce poly to be in R?
>
> Here is one option:
>
> def myroots(p):
>     R = IntegerModRing(p)
>     RR.<t> = R[]
>     f = poly(x=t)
>     return f.roots(R)
>
> Best,
> Alex
>
> --
> Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne
> -- Australia --http://www.ms.unimelb.edu.au/~aghitza/
--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to