## Name:

mod Computes the euclidian division of polynomials or numbers and returns the rest

## Library name:

sollya_obj_t sollya_lib_euclidian_mod(sollya_obj_t, sollya_obj_t)

## Usage:

mod(p, q) : (function, function) -> function

## Parameters:

• p is a polynomial.
• q is a polynomial.

## Description:

• When both a and b are constants, mod(a,b) computes a less the product of b and the largest integer less than or equal to a divided by b. In other words, it returns the rest of the Euclidian division of a by b.
• When at least one of a or b is a polynomial of degree at least 1, mod(a,b) computes two polynomials q and r such that a is equal to the product of q and b plus r. The polynomial r is of least degree possible. The mod command returns r. In order to recover q, use the div command.
• When at least one of a or b is a function that is no polynomial, mod(a,b) returns a.

## Example 1:

> mod(1001, 231);
77
> mod(13, 17);
13
> mod(-14, 15);
1
> mod(-213, -5);
-3
> print(mod(23/13, 11/17));
105 / 221
> print(mod(exp(13),-sin(17)));
exp(13) + 460177 * sin(17)

## Example 2:

> mod(24 + 68 * x + 74 * x^2 + 39 * x^3 + 10 * x^4 + x^5, 4 + 4 * x + x^2);
0
> mod(24 + 68 * x + 74 * x^2 + 39 * x^3 + 10 * x^4 + x^5, 2 * x^3);
24 + x * (68 + x * 74)
> mod(x^2, x^3);
x^2

## Example 3:

> mod(exp(x), x^2);
exp(x)
> mod(x^3, sin(x));
x^3