Simple question: modulo



On Jan 27, 2008 6:48 AM, Hanno Behrens <pebbles at schattenlauf.de> wrote:

> Perfect! Why didn't mod(x,y) work, when I tried it?


Perhaps you were using an old version of Maxima?  The mod function has been
changed....

Another way to perform modular arithmetic is to set a global modulus, which
applies to all calculations on Canonical Rational Expressions, which you
create using rat(...).  For example:

m: matrix( [15,2,7],  [8,10,23],  [0,2,8])$
determinant(m) => 494        <<<<<<<<< calculate over Z
modulus:23;
   => 23
rm:rat(m);
  =>  matrix([-8,2,7],[8,10,0],[0,2,8])
determinant(rm);        <<<<<<<<<<<<  calculate over Z23
   => 11
rm^^-1;                        <<<<<<<<<<<<<< inverse over Z23
  => matrix([1,4,2],[-10,-10,3],[-9,-9,8])
rm . rm^^-1;
  => matrix([1,0,0],[0,1,0],[0,0,1])


              -s