lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


In message <428C6822.1070407@gimp.org> you wrote:


> On the other hand changing the behaviour of math.mod
> to be a modulus instead of remainder operation could
> subtly break some old code.  Ho hum.

The remainder theorem can be articulated in different
ways and the definition of "remainder" depends on which
you use. For example:

1. "For all integers x and y, y nonzero implies there exist
unique integers q and r such that x = qy + r and 0 <= r < abs(y)."

2. "For all integers x and y, y nonzero implies there exist
unique integers q and r such that x = qy + r, sgn(r) = sgn(x) and
abs(r) < abs(y)."

So for (x,y) = (-3,2) the first formulation of the remainder
theorem gives (q,r) = (-2,1) and the second gives (q,r) = (-1,-1).

My belief is that most number theorists tend to use the first
formulation. So in using words like "remainder" and "quotient"
you have to be careful about precisely what you mean. The second
variant comes about, I think, because it tends to be formulated
by those to whom real numbers have primacy, who are not used
to thinking about integer arithmetic as a system in itself.
They dislike the idea that a "quotient" of -3 by 2 can be -2
because they think that the "real" quotient is 1.5 - a
psychological predisposition of which a pure mathematician,
or at least an algebraist, tries to rid himself.

-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/