Euclidean remainder: Rem

### 5.35.2 Euclidean remainder: Rem

In Xcas mode, Rem is simply the inert form of rem; namely, it returns the Euclidean remainder of two polynomials without evaluation. (See Section 5.28.3.) In Maple mode, the rem command can additionally be used in conjunction with mod to compute the Euclidean remainder of two polynomials with coefficients in ℤ/pℤ.

- (In Maple mode.)
  Rem takes two arguments:
  P and Q, two polynomials with coefficients in ℤ/pℤ.
- Rem(P,Q) returns the Euclidean remainder of P divided by Q.

#### Examples:

- Input (in Xcas mode):
  Rem((x^3+x^2+1) mod 13,(2*x^2+4) mod 13)
  Output:

  rem | ⎛ ⎝ | ⎛ ⎝ | 1%13 | ⎞ ⎠ | x3+ | ⎛ ⎝ | 1%13 | ⎞ ⎠ | x2+1%13, | ⎛ ⎝ | 2%13 | ⎞ ⎠ | x2+4%13 | ⎞ ⎠

  To get the result of the division:
  Input:
  eval(ans())
  Output:

  | ⎛ ⎝ | ⎛ ⎝ | −2 | ⎞ ⎠ | %13 | ⎞ ⎠ | x+ | ⎛ ⎝ | −1 | ⎞ ⎠ | %13

- Input (in Maple mode):
  Rem(x^3+x^2+1,2*x^2+4) mod 13
  Output:

  −2x−1

- Input (in Maple mode):
  Rem(x^2+2*x,x^2+6*x+5) mod 5
  Output:

  x