mod - Maple Help

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 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 $\left[0,\left|m\right|-1\right]$. When assigned the value mods, the symmetric representation is used; i.e. all rational coefficients will be reduced to integers in the range $\left[-\mathrm{iquo}\left(\left|m\right|-1,2\right),\mathrm{iquo}\left(\left|m\right|,2\right)\right]$.
 • 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={m}^{n}$ elements are represented as polynomials in $\mathrm{\alpha }$ where $\mathrm{\alpha }$ is a simple algebraic extension over the integers mod m.  The extension $\mathrm{\alpha }$ 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.

 • To compute ${i}^{n}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}m$ 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 ${a}^{n}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}m$.
 • 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 $i{j}^{-1}\mathbf{mod}m$.
 • 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  $f\left(x,y\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}23$ 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.

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

Examples

 > $\mathrm{modp}\left(12,7\right)$
 ${5}$ (1)
 > $12\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}7$
 ${5}$ (2)
 > $\mathrm{mods}\left(12,7\right)$
 ${-2}$ (3)
 > $\frac{1}{3}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}7$
 ${5}$ (4)
 > $5\cdot 3\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}7$
 ${1}$ (5)
 > $5\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&ˆ\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}1000\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}100$
 ${25}$ (6)
 > $a≔15{x}^{2}+4x-3\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}11$
 ${a}{≔}{4}{}{{x}}^{{2}}{+}{4}{}{x}{+}{8}$ (7)
 > $\mathrm{mod}≔\mathrm{mods}:$
 > $b≔3{x}^{2}+8x+9\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}11$
 ${b}{≔}{3}{}{{x}}^{{2}}{-}{3}{}{x}{-}{2}$ (8)
 > $\mathrm{gcd}\left(a,b\right)$
 ${1}$ (9)
 > $g≔\mathrm{Gcd}\left(a,b\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}11$
 ${g}{≔}{x}{+}{5}$ (10)
 > $\mathrm{Divide}\left(a,g,'q'\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}11$
 ${\mathrm{true}}$ (11)
 > $q$
 ${4}{}{x}{-}{5}$ (12)
 > $\mathrm{factor}\left({x}^{3}+2\right)$
 ${{x}}^{{3}}{+}{2}$ (13)
 > $\mathrm{Factor}\left({x}^{3}+2\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}5$
 $\left({x}{-}{2}\right){}\left({{x}}^{{2}}{+}{2}{}{x}{-}{1}\right)$ (14)
 > $\mathrm{alias}\left(\mathrm{\alpha }=\mathrm{RootOf}\left({y}^{2}+2y-1\right)\right):$
 > $\mathrm{Normal}\left(\frac{1}{\mathrm{\alpha }}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}5$
 ${\mathrm{\alpha }}{+}{2}$ (15)
 > $\mathrm{Factor}\left({x}^{3}+2,\mathrm{\alpha }\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}5$
 $\left({x}{+}{\mathrm{\alpha }}{+}{2}\right){}\left({x}{-}{2}\right){}\left({x}{-}{\mathrm{\alpha }}\right)$ (16)
 > $\mathrm{Expand}\left(\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}5$
 ${{x}}^{{3}}{+}{2}$ (17)