### 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

##### mod-power_mod

power_mod(66,173,323);

mod(288,5);

Calculate

##### mod

mod(658^2,27212325191);

Calculate

##### mod

mod(7^(147219),294439);

Calculate

mod(100091,2);

Calculate

mod(1,33);

Calculate

mod(2^1, 221);

Calculate

##### mod

mod (14^(12*13), 17);

Calculate

##### mod-power_mod

power_mod(2,3,7);

Calculate

##### mod

mod(254448^1147,360883);

Calculate

##### mod

mod(87009^87953,15625...

Calculate