1

I was doing computational experiment by using rings of polynomial like this

let $f(x)=x^6+x\in\mathbb{Z_n[x]}$ for any given $n$.

Is there any software which help me to calculate $f(a)$ where $a\in\mathbb{Z_n}$.

Thanks!

Olexandr Konovalov
  • 7,186
  • 2
  • 35
  • 73
  • 1
    I think a lot (if not all) programming languages have a "modulo" command, with which you can easily program this: http://en.wikipedia.org/wiki/Modulo_operation – hjhjhj57 Jan 09 '15 at 06:57
  • Have you tried Macaulay2? http://habanero.math.cornell.edu:3690/ – daOnlyBG Jan 09 '15 at 06:57
  • 1
    And if a language doesn't have a "modulo" command built it, one can easily program a subroutine or function or method etc. to achieve the desired effect, no? – Robert Lewis Jan 09 '15 at 07:22

1 Answers1

1

Many computer algebra systems are capable of such computation. I mainly deal with GAP (http://www.gap-system.org), where you can do this, for example, in a very simple way like this:

gap> x:=Indeterminate(Rationals,"x");
x
gap> f:=x^6+x;
x^6+x
gap> Value(f,11);
1771572
gap> Value(f,11) mod 19;
12

just to create a polynomial with rational coefficients and then calculate a remainder using mod. Note that here $12$ is in $\mathbb{Z}$, not in $\mathbb{Z_n}$.

On this way, one should know the function PowerModInt( r, e, m ) which returns r^e mod m for integers r, e and m (e non-negative): compare the runtime in the brute-force calculation

gap> 111122^131113345 mod 139; time;
2
33203

which takes about 33 seconds, with the instantly returned result of PowerModInt:

gap> PowerModInt(111122,131113345,139); time;
2
0

This happens because PowerModInt can reduce intermediate results and thus will generally be faster than using r^e mod m, which would compute r^e first and reduce the result afterwards.

A more "algebraically clean" approach could be to create a proper ring $\mathbb{Z_n}$ using Integers mod n, so that both $a$ and $f(a)$ will belong to $\mathbb{Z_n}$, for example:

gap> z42:=Integers mod 42;
(Integers mod 42)
gap> x:=Indeterminate(z42,"x");
x
gap> f:=x^6+x;
x^6+x
gap> a:=Random(z42);
ZmodnZObj( 2, 42 )
gap> Value(f,a);
ZmodnZObj( 24, 42 )

This corresponds to the fact that (2^6+2) mod 42 = 2.

It depends on the circumstances of the experiment whether to use one approach or another, or to use GAP or another system, such as for example PARI/GP (see also this question).

Remark: note the usage of parentheses because of the rules of precedence of mod in GAP: compare

gap> (2^6+2) mod 42;
24

with

gap> 2^6+2 mod 42;
66

because the latter is equivalent to 2^6 + (2 mod 42).

Olexandr Konovalov
  • 7,186
  • 2
  • 35
  • 73