defining simplification rules



On 1/1/2011 2:49 AM, Pouya D. Tafti wrote:
> Hi,
>
> I am very new to maxima and CAS in general, and also to this list.  So
> I hope you will excuse me if my question happens to be trivial.
It doesn't look that the question is trivial. Or at least the answer is not.

Your rules will probably not work in sufficient generality because you 
need to
deal with situations in which you have <something>*gamma(..)*gamma(..),  
and for the
rule to succeed you need to match <something>  also.
It would probably help if you specified z ahead of time, e.g.
gammasimp(f,z) := ...

You should realize that you are not specifying rules for gamma, really.  
You are
specifying rules for multiplication, and as such, they will affect the 
speed of
simplifying '*'  everywhere.


Other than that, I don't see, offhand, what's wrong with gammarule2, and 
it should work.
The best I can see is this:

the matcher finds gamma(z) as one factor in e= gamma(z)*gamma(z+1/2).
It then tries to match
     gamma(z+1/2)    to   e/(gamma(z).  But the quotient is not 
simplified to gamma(z+1/2),
and so it fails.   Possible programs to trace (in lisp) are  
compilematch  [when the rule is defined]
and meval, findfun  [when the rule is run, e.g. by   gammarule2( 
gamma(n)*gamma(n+1/2));
]

RJF



> I am trying to define some new simplification rules for gamma
> functions.  After looking at the help files and some sources in
> maxima's share directory (and not quite understanding what was going
> on), I came up with the following definitions:
>
> (%i1) matchdeclare(z,true)$
> (%i2) defrule(gammarule0,z!,gamma(z+1))$
> (%i3) defrule(gammarule1,gamma(1-z)*gamma(z),%pi/sin(%pi*z))$
> (%i4) defrule(gammarule2,gamma(z)*gamma(z+1/2),2^(1-2*z)*sqrt(%pi)*gamma(2*z))$
> (%i5) defrule(gammarule3,z*gamma(z),gamma(z+1))$
> (%i6) gammasimp(f) :=
> apply1(expand(f),gammarule0,gammarule1,gammarule2,gammarule3)$
>
> Now, when I try to simplify, say, n!*(-1-n)!, I get
>
> (%i7) gammasimp(n!*(-1-n)!);
>                                        %pi
> (%o7)                            - ----------
>                                     sin(%pi n)
>
> which is what I want.  On the other hand, if I try something like
>
> (%i8) gammasimp(gamma(n)*gamma(n+1/2));
>                                                  1
> (%o8)                        gamma(n) gamma(n + -)
>                                                  2
> (which, I imagine, should be matched by gammarule2), there is no
> simplification in the output.
>
> What am I doing wrong?
>
> Thanks, and happy new year too,
> Pouya
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima