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!
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!
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:
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 returnsr^e mod mfor integersr,eandm(enon-negative): compare the runtime in the brute-force calculationwhich takes about 33 seconds, with the instantly returned result of
PowerModInt:This happens because
PowerModIntcan reduce intermediate results and thus will generally be faster than usingr^e mod m, which would computer^efirst 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: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
modin GAP: comparewith
because the latter is equivalent to
2^6 + (2 mod 42).