Go to the first, previous, next, last section, table of contents.

### `sdiv`, `sdivm`, `srem`, `sremm`, `sqr`, `sqrm`

sdiv(poly1,poly2[,v])
sdivm(poly1,poly2,mod[,v])
:: Quotient of poly1 divided by poly2 provided that the division can be performed within polynomial arithmetic over the rationals.
srem(poly1,poly2[,v])
sremm(poly1,poly2,mod[,v])
:: Remainder of poly1 divided by poly2 provided that the division can be performed within polynomial arithmetic over the rationals.
sqr(poly1,poly2[,v])
sqrm(poly1,poly2,mod[,v])
:: Quotient and remainder of poly1 divided by poly2 provided that the division can be performed within polynomial arithmetic over the rationals.
return
`sdiv()`, `sdivm()`, `srem()`, `sremm()` : polynomial `sqr()`, `sqrm()` : a list `[quotient,remainder]`
poly1 poly2
polynomial
v
indeterminate
mod
prime
• Regarding poly1 as an uni-variate polynomial in the main variable of poly2, i.e. var(poly2) (v if specified), `sdiv()` and `srem()` compute the polynomial quotient and remainder of poly1 divided by poly2.
• `sdivm()`, `sremm()`, `sqrm()` execute the same operation over GF(mod).
• Division operation of polynomials is performed by the following steps: (1) obtain the quotient of leading coefficients; let it be Q; (2) remove the leading term of poly1 by subtracting, from poly1, the product of Q with some powers of main variable and poly2; obtain a new poly1; (3) repeat the above step until the degree of poly1 become smaller than that of poly2. For fulfillment, by operating in polynomials, of this procedure, the divisions at step (1) in every repetition must be an exact division of polynomials. This is the true meaning of what we say "division can be performed within polynomial arithmetic over the rationals."
• There are typical cases where the division is possible: leading coefficient of poly2 is a rational number; poly2 is a factor of poly1.
• Use `sqr()` to get both the quotient and remainder at once.
• Use `idiv()`, `irem()` for integer quotient.
• For remainder operation on all integer coefficients, use `%`.
```[0] sdiv((x+y+z)^3,x^2+y+a);
x+3*y+3*z
[1] srem((x+y+z)^2,x^2+y+a);
(2*y+2*z)*x+y^2+(2*z-1)*y+z^2-a
[2] X=(x+y+z)*(x-y-z)^2;
x^3+(-y-z)*x^2+(-y^2-2*z*y-z^2)*x+y^3+3*z*y^2+3*z^2*y+z^3
[3] Y=(x+y+z)^2*(x-y-z);
x^3+(y+z)*x^2+(-y^2-2*z*y-z^2)*x-y^3-3*z*y^2-3*z^2*y-z^3
[4] G=gcd(X,Y);
x^2-y^2-2*z*y-z^2
[5] sqr(X,G);
[x-y-z,0]
[6] sqr(Y,G);
[x+y+z,0]
[7] sdiv(y*x^3+x+1,y*x+1);
divsp: cannot happen
return to toplevel
```
References
section `idiv`, `irem`, section `%`.

Go to the first, previous, next, last section, table of contents.