matchdeclare syntax



On Feb 3, 2008 6:45 PM, Edwin Woollett <woollett at charter.net> wrote:

> (%i2) matchdeclare(q,integerp);
> (%i3) tellsimp( cos(q*%pi), (-1)^n );
> (%i4) declare(m,integer);
> (%i5) cos(m*%pi);
> (%o5) (-1)^m
> (%i6) tellsimp( sin(q*%pi) , 0);
> (%i7) sin(m*%pi);
> (%o7) 0
> Why does integerp(m) => false, but use in matchdeclare works?


Actually, integerp isn't doing anything different:

       tellsimp(f(q),0)$
       f(m) => f(m)
but  f(2) => 0

The reason the examples above work is because these transformations
(simplifications) are already performed by default in Maxima:

     kill(all)$
     declare(m,integer)$
     sin(m*%pi) => 0
     cos(m*%pi) => (-1)^m

and for that matter

     sin((m+1/3)*%pi) => sqrt(3)*(-1)^m/2

though for some reason tan(%pi*m) doesn't simplify to 0 (you have to expand
to sin/cos using trigsimp...).

            -s