proposal to rename mod to polymod, was: Fixing up the mod function to produce only positive results?



On 11/14/05, Alasdair McAndrew  wrote:

> I've been doing some modular arithmetic with Maxima, and I don't like
> the default behaviour than mod(m,n) returns a value between -(n-1)/2
> and n/2 (roughly speaking).

This topic seems to come up from time to time.
I believe this thread
http://www.math.utexas.edu/pipermail/maxima/2005/thread.html#10571
is the most recent recurrence.

It appears that mod does something different than what
people (like me) expect it to do. It appears that mod is
specifically intended for this problem:
given a polynomial in the field of polynomials over Z_n,
find an equivalent canonical polynomial in that field.
(I don't know what is the criterion for canonical here.
I would be interested to know how the "balanced modulus"
scheme fits in. I may have goofed this up entirely.)

The global variable "modulus" or the 2nd argument of mod
tells n . It can only be an integer. In particular, one cannot
get the remainder of p divided by q where q is a polynomial.

"remainder" is a function that returns the
remainder when the modulus is an integer or polynomial.
I think remainder does what some people expect mod to do.

So mod does something interesting, for sure, but it is
unfortunately not the interesting thing that some users
seem to think. This can be corrected in part by expanding
the description of mod, but beyond that we should consider
renaming mod to polymod, and nummod to mod
(as suggested by Stavros Macrakis last time this came up).

About renaming -- yes? no?

all the best,
Robert Dodier

PS. I have to admit I'm really pretty confused about mod.
mod (x^2, 2) => x^2 , although since 0^2 = 0 and 1^2 = 1
it seems like x is a simpler equivalent ...
I hope someone can clarify this.