Mod, ?mod and matrices



One reason for mod to use balanced representation in Maxima, is that it is
slightly more economical using ordinary lisp numbers, the Chinese remainder
theorem,
and signed hardware arithmetic, and is therefore used internally in maxima.

One is basically leaving out half the possible residues by using 0 ...p-1.

Now what the top-level definition of mod, rem, div, etc should be is perhaps
irrelevant to what is used internally, but for discussion one can
distinguish the two cases:
(a) number theorists who prefer residues 0...p-1 because of convention
(b) computational mathematicians optimizing hardware utilization because of
speed.

RJF



> -----Original Message-----
> From: maxima-bounces at math.utexas.edu 
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Barton Willis
> Sent: Friday, September 01, 2006 5:59 PM
> To: Alasdair McAndrew
> Cc: maxima list
> Subject: Re: [Maxima] Mod, ?mod and matrices
> 
> -----maxima-bounces at math.utexas.edu wrote: -----
> 
> >To: "maxima list" <maxima at math.utexas.edu>
> >From: "Alasdair McAndrew" <amca01 at gmail.com>
> 
> >I have a little annoyance with the mod
> >function.  As you know mod(x,p):
> >
> >      is defined as an integer <k> in
> >
> >     `[-(-1)/2, ..., 0, ..., (-1)/2]' when <p> is odd, or
> >
> >     `[-(/2 - 1), ..., 0, ...., /2]' when <p> is even, such that
> 
> This is no longer the case (starting with maybe version 5.9.3 or so):
> 
>  -- Function: mod (<x>, <y>)
>      If <x> and <y> are real numbers and <y> is nonzero, return `<x> -
>      <y> * floor(<x> / <y>)'.  Further for all real <x>, we have `mod
>      (<x>, 0) = <x>'. For a discussion of the definition `mod (<x>, 0)
>      = <x>', see Section 3.4, of "Concrete Mathematics," by Graham,
>      Knuth, and Patashnik.
> 
> To apply mod to each element of a matrix, you'll still need 
> to use matrixmap and a lambda form. Doing 
> mod(matrix([...]),10) makes a mess...
> 
> Barton
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>