HP Forums

Full Version: polynomial calculations over Z/Zp (for prime p)?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Does the Prime have some way to compute with polynomials whose coefficients are in Z/pZ (for prime p)? If so, I'd be grateful for an example.

thank you,
Jeff
You have several ways of implementing \( \mathbb{Z}/\mathbb{Z}_p[x]\). You can use vectors (of coefficients), actual symbolic expressions, or the "poly" type:
Code:

p:=3;

// examples below
p1:=[ 12 13 -20 5 ] % p;
p2:=(12x^3 + 13x^2 - 20x + 5) % p;
p3:=poly[ 12 13 -20 5 ] % p;
Hi,
What are the CAS settings for this to work? For example, quo() is documented in the xcas manual (2.25.3), but I cannot get it to work in the HP prime:
quo( (x^3+3x)%5,(2x^2+6x-5)%5)
should output -2x+1 but I get an error. Same if % is replaced by MOD (or mod). In fact, the HP prime example in the Help for MOD is 9 mod 5 results in an error. Maybe my CAS settings are wrong.
(12-24-2013 04:09 AM)Han Wrote: [ -> ]
Code:

p:=3;
p1:=[ 12 13 -20 5 ] % p;
p2:=(12x^3 + 13x^2 - 20x + 5) % p;
p3:=poly[ 12 13 -20 5 ] % p;

These didn't work for me (using the latest firmware).

However, last night I stumbled upon the CAS %%(n,p) operator, which seems to be the % operator in xcas. With %% instead of %, example p1 worked fine. Example p2 produces a polynomial with non-modular coefficients. For example p3, I needed to say poly([ 12 13 -20 5 ] %% p).

Linear algebra seems to work with integers mod p. The expression [[4,3],[5,1]]%%3 defines a matrix of integers mod 3.
Yes, %% does the job. The single % is for percentage in the Prime. Very convoluted notation thou.
(12-24-2013 11:56 AM)Jeff Nye Wrote: [ -> ]
(12-24-2013 04:09 AM)Han Wrote: [ -> ]
Code:

p:=3;
p1:=[ 12 13 -20 5 ] % p;
p2:=(12x^3 + 13x^2 - 20x + 5) % p;
p3:=poly[ 12 13 -20 5 ] % p;

These didn't work for me (using the latest firmware).

However, last night I stumbled upon the CAS %%(n,p) operator, which seems to be the % operator in xcas. With %% instead of %, example p1 worked fine. Example p2 produces a polynomial with non-modular coefficients. For example p3, I needed to say poly([ 12 13 -20 5 ] %% p).

Linear algebra seems to work with integers mod p. The expression [[4,3],[5,1]]%%3 defines a matrix of integers mod 3.

Thank you for the corrections
I wonder if one has a choice of residue system used. The %% uses the minimal residue system mod n. Is there a way to display results using the common (or least) residue system mod n (that is, {0,1,...,n-1})? The negative signs combined with the double %% make the results rather cumbersome to read.
You can remove the %% by the %% 0 command, then run irem on each coefficient.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :