If you type

x = polygen(GF(7))

before defining mpoly, then mpoly.factor() will factor it mod 7.
Probably better though is to type

x = polygen(ZZ)

before defining mpoly, so that mpoly knows that it is an integer polynomial:

sage: mpoly.parent()
Univariate Polynomial Ring in x over Integer Ring

and now you can do

sage: mpoly.change_ring(GF(7)).factor()
(x + 1) * (x + 6) * (x^15 + x^14 + 3*x^13 + 2*x^12 + 6*x^11 + 5*x^10 +
2*x^9 + 6*x^7 + 6*x^6 + 5*x^5 + 5*x^4 + x^2 + 2*x + 6)

and easily change from 7 to other primes.

On 15 January 2014 18:13, William Stein <wst...@gmail.com> wrote:
> ---------- Forwarded message ----------
> From: "Stavros Garoufalidis" <stav...@math.gatech.edu>
> Date: Jan 15, 2014 12:36 PM
> Subject: factoring polynomials modulo primes in Mathematica/Sage?
> To: <wst...@uw.edu>
> Cc: "stavros" <stav...@math.gatech.edu>
>
> Dear William,
>
> I would like to ask you a Sage question: suppose we have a Mathematica
> object in sage:
>
> sage: mpoly
> 4096 - 8192*x + 63488*x^2 + 36864*x^3 + 216576*x^4 + 78080*x^5 + 215424*x^6
> -
>  9472*x^7 + 106672*x^8 - 29200*x^9 + 34736*x^10 - 13528*x^11 + 3447*x^12 -
>  893*x^13 + 561*x^14 - 124*x^15 + 8*x^16 + x^17
>
> I would like to factor it (using Mathematica) inside Sage, modulo 7.
> I know the command:
>
> sage: mpoly.Factor()
>
> which factors over Q. Mathematica has an option Factor[mpoly,Modulus->7].
> How can I access this option in Sage?
>
> Thank you very much,
>
> Stavros
>
>  -----------------------------------------------------------------------
> | Stavros Garoufalidis            | Phone:     (404) 894-6614           |
> | School of Mathematics           | FAX:       (404) 894-4409           |
> | Georgia Institute of Technology | e-mail:    stav...@math.gatech.edu  |
> | Atlanta, GA  30332-0160, USA    | http://www.math.gatech.edu/~stavros |
>  -----------------------------------------------------------------------
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to