modp2 - Maple Programming Help

modp2

bivariate polynomial arithmetic modulo n

 Calling Sequence modp2(e, p)

Parameters

 e - algebraic expression p - prime integer

Description

 • The modp2 function offers fast arithmetic for bivariate polynomials over the integers modulo p, written ${Z}_{p}$[x,y].
 • To achieve its efficiency, modp2 uses a special representation. Explicit conversions are provided for converting the Maple sum of products'' representation to and from this representation. Knowledge of this representation is not required by the user in order to use modp2. Also, some of the Maple mod functions already take advantage of the modp2 routines.
 • The actual representation consists of a list of modp1 polynomials representing the coefficients of the main variable.
 • A typical use of modp2 would be modp2(Add(a, b), p), meaning add the modp2 polynomial a and the modp2 polynomial b together modulo p and return the result in the form of another modp2 polynomial.  The modp2 function accepts the following functions, whose names are also protected global names.

 ConvertIn ConvertOut RingMultiply One Pquo Unit VarSwap Zero

 • The Add function is n-ary. The Zero and One nullary functions create the $0$ and 1 modp2 polynomials.  The Constant function creates a modp2 polynomial for the given integer constant. The Multiply function is n-ary.  Scalar multiplication can be done using RingMultiply(n, a).
 • The Degree function computes the degree.  The TotalDegree function computes the total degree in both variables.  The Coeff function computes any coefficient.  The Diff function computes the derivative.  The Randpoly function takes two degrees as  arguments and generates a polynomial of the given degrees with random coefficients modulo p.
 • The Eval function evaluates one indeterminate of the polynomial for a specific value. The indeterminate to evaluate can be specified as the second argument (followed by the evaluation constant). If the indeterminate is left out, the main variable is evaluated
 • The ConvertIn and ConvertOut functions are used to convert to and from the modp2 representation. The modp2(ConvertIn(b, x, y), p) command converts from a bivariate polynomial b in x and y over the integers to a modp2 polynomial modulo p. The ConvertOut function does the reverse of ConvertIn.
 • Note that unlike the mod function, modp2 arithmetic operations do not take the variable as a name. Instead, 1 means take the main variable, x and 2 means use the second variable, y. If the variable argument is left out, the main variable is assumed. For example, the calling sequences of the Diff operation are Diff(a, 1), Diff(a, 2), and Diff(a). Calling sequences are similar for Coeff, Degree, Prem, and Pquo.

Examples

 > $p≔11$
 ${p}{≔}{11}$ (1)
 > $a≔{x}^{4}{y}^{2}-1$
 ${a}{≔}{{x}}^{{4}}{}{{y}}^{{2}}{-}{1}$ (2)
 > $a≔amodp$
 ${a}{≔}\left({{y}}^{{2}}{}{{x}}^{{4}}{+}{10}\right){mod}{11}$ (3)
 > $\mathrm{modp2}\left(\mathrm{ConvertOut}\left(a,x,y\right),p\right)$
 ${{x}}^{{4}}{}{{y}}^{{2}}{+}{10}$ (4)
 > $b≔\mathrm{modp2}\left(\mathrm{Randpoly}\left(3,4,x,y\right),p\right)$
 ${b}{≔}\left(\left({{y}}^{{4}}{+}{3}{}{{y}}^{{3}}{+}{7}{}{{y}}^{{2}}{+}{10}{}{y}{+}{2}\right){}{{x}}^{{3}}{+}\left({7}{}{{y}}^{{4}}{+}{4}{}{{y}}^{{3}}{+}{9}{}{{y}}^{{2}}{+}{10}{}{y}{+}{1}\right){}{{x}}^{{2}}{+}\left({3}{}{{y}}^{{4}}{+}{5}{}{{y}}^{{3}}{+}{4}{}{{y}}^{{2}}{+}{10}{}{y}\right){}{x}{+}{6}{}{{y}}^{{4}}{+}{9}{}{{y}}^{{3}}{+}{5}{}{{y}}^{{2}}{+}{y}{+}{10}\right){mod}{11}$ (5)
 > $\mathrm{modp2}\left(\mathrm{Prem}\left(a,b\right),p\right)$
 $\left(\left({2}{}{{y}}^{{10}}{+}{9}{}{{y}}^{{9}}{+}{3}{}{{y}}^{{8}}{+}{4}{}{{y}}^{{7}}{+}{6}{}{{y}}^{{6}}{+}{2}{}{{y}}^{{5}}{+}{10}{}{{y}}^{{4}}{+}{{y}}^{{2}}\right){}{{x}}^{{2}}{+}\left({4}{}{{y}}^{{10}}{+}{9}{}{{y}}^{{9}}{+}{{y}}^{{8}}{+}{{y}}^{{6}}{+}{8}{}{{y}}^{{5}}{+}{3}{}{{y}}^{{4}}{+}{7}{}{{y}}^{{3}}{+}{2}{}{{y}}^{{2}}\right){}{x}{+}{9}{}{{y}}^{{10}}{+}{10}{}{{y}}^{{9}}{+}{3}{}{{y}}^{{8}}{+}{8}{}{{y}}^{{7}}{+}{5}{}{{y}}^{{6}}{+}{2}{}{{y}}^{{5}}{+}{3}{}{{y}}^{{4}}{+}{4}{}{{y}}^{{3}}{+}{3}{}{{y}}^{{2}}{+}{4}{}{y}{+}{7}\right){mod}{11}$ (6)
 > $c≔\mathrm{modp2}\left(\mathrm{Diff}\left(a\right),p\right)$
 ${c}{≔}{4}{}{{y}}^{{2}}{}{{x}}^{{3}}{mod}{11}$ (7)
 > $\mathrm{modp2}\left(\mathrm{ConvertOut}\left(c,x,y\right),p\right)$
 ${4}{}{{x}}^{{3}}{}{{y}}^{{2}}$ (8)
 > $d≔\mathrm{modp2}\left(\mathrm{Diff}\left(a,2\right),p\right)$
 ${d}{≔}{2}{}{y}{}{{x}}^{{4}}{mod}{11}$ (9)
 > $\mathrm{modp2}\left(\mathrm{ConvertOut}\left(d,x,y\right),p\right)$
 ${2}{}{{x}}^{{4}}{}{y}$ (10)
 > $\mathrm{modp2}\left(\mathrm{Gcd}\left(a,d\right),p\right)$
 ${1}{mod}{11}$ (11)