1 | initial version |
Here is what I've found. You can define the coefficients in the ring R=Integer(9)
. Then, define the polynomial ring K.<x>=R[]
. After that, you can do calculations in the polynomial ring and can find the quotient and remainder. See below.
sage: R=Integers(9)
sage: list(R)
[0, 1, 2, 3, 4, 5, 6, 7, 8]
sage: K.<x>=R[]
sage: p1=x^4-3*x
sage: print p1
x^4 + 6*x
sage: p2=x^2+5
sage: p1*p2
x^6 + 5*x^4 + 6*x^3 + 3*x
sage: p1.quo_rem(p2)
(x^2 + 4, 6*x + 7)
sage: (x^2+4)*p2+(6*x+7)
x^4 + 6*x
2 | added comment on factoring |
Here is what I've found. You can define the coefficients in the ring R=Integer(9)
. Then, define the polynomial ring K.<x>=R[]
. After that, you can do calculations in the polynomial ring and can find the quotient and remainder. That handles the long division. See below.
sage: R=Integers(9)
sage: list(R)
[0, 1, 2, 3, 4, 5, 6, 7, 8]
sage: K.<x>=R[]
sage: p1=x^4-3*x
sage: print p1
x^4 + 6*x
sage: p2=x^2+5
sage: p1*p2
x^6 + 5*x^4 + 6*x^3 + 3*x
sage: p1.quo_rem(p2)
(x^2 + 4, 6*x + 7)
sage: (x^2+4)*p2+(6*x+7)
x^4 + 6*x
In terms of factoring, I get an error.
sage: p1.factor()
Traceback (most recent call last):
...
NotImplementedError: factorization of polynomials over rings with composite characteristic is not implemented
So this won't work for $p^n$ with $p$ prime and $n>1$. However, it will work nicely for just prime $p$.
3 | added UFD info |
Here is what I've found. You can define the coefficients in the ring R=Integer(9)
. Then, define the polynomial ring K.<x>=R[]
. After that, you can do calculations in the polynomial ring and can find the quotient and remainder. That handles the long division. See below.
sage: R=Integers(9)
sage: list(R)
[0, 1, 2, 3, 4, 5, 6, 7, 8]
sage: K.<x>=R[]
sage: p1=x^4-3*x
sage: print p1
x^4 + 6*x
sage: p2=x^2+5
sage: p1*p2
x^6 + 5*x^4 + 6*x^3 + 3*x
sage: p1.quo_rem(p2)
(x^2 + 4, 6*x + 7)
sage: (x^2+4)*p2+(6*x+7)
x^4 + 6*x
In terms of factoring, I get an error.error, since $Z/p^nZ[x]$ is not an unique factorization domain, $n>1$.
sage: p1.factor()
Traceback (most recent call last):
...
NotImplementedError: factorization of polynomials over rings with composite characteristic is not implemented
So this won't work for $p^n$ with $p$ prime and $n>1$. However, it will work nicely for just prime $p$.