mod - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


mod

computation with polynomials over the integers modulo m

modp

computation over the integers modulo m using positive representation

mods

computation over the integers modulo m using symmetric representation

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

Calling Sequence

e mod m

modp(e, m)

mods(e, m)

`mod`(e, m)

Parameters

e

-

algebraic expression

m

-

nonzero integer

Description

• 

The mod operator evaluates the expression e over the integers modulo m.  It incorporates facilities for doing finite field arithmetic and polynomial and matrix arithmetic over finite fields, including factorization.

• 

The operator syntax e mod m is equivalent to the function call `mod`(e, m).  The environment variable `mod` may be assigned either the modp function or the mods function.  When assigned the value modp (the default), the positive representation for integers modulo m is used;  i.e. all rational coefficients will be reduced to integers in the range 0,m1. When assigned the value mods, the symmetric representation is used; i.e. all rational coefficients will be reduced to integers in the range iquom1,2,iquom,2.

• 

If the modulus m is a prime integer, then all coefficient arithmetic is done in the finite field of integers modulo m. Elements of finite fields of characteristic m with q=mn elements are represented as polynomials in α where α is a simple algebraic extension over the integers mod m.  The extension α is a RootOf a monic univariate irreducible polynomial of degree n over the integers mod m.  See RootOf and the examples below.

• 

The following functions for polynomial and matrix arithmetic over finite rings and fields are known to mod.  See help for further details.

Berlekamp

Charpoly

Content

Det

DistDeg

Divide

Eval

Expand

Factor

Factors

Frobenius

Gausselim

Gaussjord

Gcd

Gcdex

Hermite

Interp

Inverse

Issimilar

Lcm

Linsolve

Nextpoly

Nextprime

Normal

Nullspace

Power

Powmod

Prem

Prevpoly

Prevprime

Primfield

Primitive

Primpart

ProbSplit

Quo

Randpoly

Randprime

Rem

Resultant

Roots

Smith

Sprem

Sqrfree

taylor

• 

To compute inmodm where i is an integer, it is undesirable to use this "obvious" syntax because the powering will be performed first over the integers (possibly resulting in a very large integer) before reduction modulo m. Rather, the inert operator &^ should be used: i &^ n mod m.  In the latter form, the powering will be performed intelligently by the mod operation. Similarly Powmod(a, n, b, x) mod m computes Rem(a^n, b, x) mod m (where a and b are polynomials in x) without first computing anmodm.

• 

Other modular arithmetic operations are stated in their natural form:

i+j mod m;

i-j mod m;

i*j mod m;

j^(-1) mod m;

i/j mod m;

 

  

where the latter case will perform ij1modm.

• 

The left precedence of the mod operator is lower than (less binding strength than) the other arithmetic operators.  Its right precedence is immediately higher than +, - and lower than *, /.

• 

There is an interface for user-defined mod functions. For example, if the user has defined the procedure `mod/f` then the operation  fx,ymod23 will generate the function call `mod/f`(x, y, 23).

• 

The mod operator is mapped automatically onto equations, the coefficients of polynomials, and the entries of lists and sets.

• 

Because mod is an environment variable, any assignments to it inside a procedure body are undone on exit from the procedure.

• 

For efficient modular linear algebra computations, see LinearAlgebra[Modular]. For the remainder upon division for floating point values, see frem.

Thread Safety

• 

The mod, modp and mods commands are thread-safe as of Maple 15.

• 

For more information on thread safety, see index/threadsafe.

Examples

modp12,7

5

(1)

12mod7

5

(2)

mods12,7

−2

(3)

13mod7

5

(4)

53mod7

1

(5)

51000mod100

25

(6)

a15x2+4x3mod11

a4x2+4x+8

(7)

`mod`mods:

b3x2+8x+9mod11

b3x23x2

(8)

gcda,b

1

(9)

gGcda,bmod11

gx+5

(10)

Dividea,g,qmod11

true

(11)

q

4x5

(12)

factorx3+2

x3+2

(13)

Factorx3+2mod5

x2+2x1x2

(14)

aliasα=RootOfy2+2y1:

Normal1αmod5

α+2

(15)

Factorx3+2,αmod5

xαx2x+α+2

(16)

Expandmod5

x3+2

(17)

See Also

environment variables

frem

GF

iquo

irem

LinearAlgebra[Modular]

modp1

msolve