### The Maxima on-line user's manual

Algebra Calculator

#### Mod

Function: mod (<x>, <y>) If <x> and <y> are real numbers and <y> is nonzero, return `<x> - <y> * floor(<x> / <y>)`. Further for all real <x>, we have `mod (<x>, 0) = <x>`. For a discussion of the definition `mod (<x>, 0) = <x>`, see Section 3.4, of "Concrete Mathematics," by Graham, Knuth, and Patashnik. The function `mod (<x>, 1)` is a sawtooth function with period 1 with `mod (1, 1) = 0` and `mod (0, 1) = 0`.

To find the principal argument (a number in the interval `(-%pi, %pi]`) of a complex number, use the function `<x> |-> %pi - mod`

``     (%pi - <x>, 2*%pi)`, where <x> is an argument.`

When <x> and <y> are constant expressions (`10 * %pi`, for example), `mod` uses the same big float evaluation scheme that `floor` and `ceiling` uses. Again, its possible, although unlikely, that `mod` could return an erroneous value in such cases.

For nonnumerical arguments <x> or <y>, `mod` knows several simplification rules:

```          (%i1) mod (x, 0);
(%o1)                           x
(%i2) mod (a*x, a*y);
(%o2)                      a mod(x, y)
(%i3) mod (0, x);
(%o3)                           0```

There are also some inexact matches for `mod`. Try `?? mod` to see them.

```(%o1)                                true
(%i2) ```

### Related Examples

P:1239085698;

Q:3216895496;

R:P*Q;

Calculate

##### mod-numer-true

numer:true;

215124901057000099028...

mod(73011155,11);

Calculate

##### mod

mod(6^(147219),294439);

Calculate

##### mod

mod(254848^423919,786...

mod(97^211,786396);

mod(118^211,786396);

Calculate

mod(x,7);

Calculate

##### mod-power_mod

power_mod(7, 7^1000, ...

Calculate

##### mod-numer-power_mod-true

numer:true;

power_mod (308,1253,2...

Calculate

mod(31^4,33);

Calculate

##### mod

mod(2073402,2671);

Calculate

##### mod

mod(468^1109,2881);

Calculate