Euclidean remainder

### 10.3.3 Euclidean remainder

The rem command finds the remainder of the Euclidean division of two polynomials.

- rem takes two mandatory arguments and one optional argument:
  - P and Q, two polynomials.
  - Optionally x, the variable (by default x), if P and Q are given as expressions.
- rem(P,Q ⟨,x⟩) returns the Euclidean remainder of P divided by Q.

Rem is the inert form of rem; namely, it evaluates to rem for later evaluation. It is used when Xcas is in Maple mode (see Section 2.5.2) to compute the euclidean remainder of the division of two polynomials with coefficients in ℤ/pℤ using Maple-like syntax.

#### Examples

rem(x^3-1,x^2-1)

x−1 |  |  |  |  |  |  |  |  |  |

To have the remainder of x2+2x+4 by x2+x+2, you can also do:

rem([1,2,4],[1,1,2])

| ⎡ ⎣ | 1,2 | ⎤ ⎦

i.e. the polynomial x+2.

Input in Xcas mode:

Rem(x^3-1,x^2-1)

rem | ⎛ ⎝ | x3−1,x2−1 | ⎞ ⎠

Input in Maple mode:

Rem(x^3+3*x,2*x^2+6*x+5) mod 5

2x |  |  |  |  |  |  |  |  |  |

This division was done using modular arithmetic, unlike with the following command, where the division is done in ℤ[X] and reduced afterwards:

rem(x^3+3*x,2*x^2+6*x+5) mod 5

after to:

12x |  |  |  |  |  |  |  |  |  |

If Xcas is not in Maple mode, polynomial division in ℤ/pℤ[X] is entered like this:

rem((x^3+3*x)%5,(2x^2+6x+5)%5)

x | ⎛ ⎝ | 2 mod 5 | ⎞ ⎠