A pattern hard to recognize?



Hello.

I can see this is a busy moment, because of the new
Maxima release, but I try to ask my question the same.

My goal is to make this simplification:

-(k+1)*binomial(n,k+1)/(2*(n-k)*2^n)    --->
     -binomial(n,k)/2^(n+1)

I tried to set a suitable rule with defrule and
apply1, but I had no success.
My experiments (I posted it below) show that
the operations * and / seem to be right-associative,
and the "-" is referred to the symbol close to it,
and not to the whole expression.
I think these are the main obstacles for the parser
to recognize my pattern.
May I have to use some more rule, like
             a * b / c  ->  (a * b) / c
or
   -a * b  ->  -(a * b)  and  -a / b  ->  -(a / b)

but how can I make them work together with the
"main" rule?

My tests:

(%i1) a(k):= -(k+1)*binomial(n,k+1)/(2*(n-k)*2^n);

              (- (k + 1)) binomial(n, k + 1)
      a(k) := ------------------------------
                                  n
                       2 (n - k) 2

(%i2) defrule(h,
        (k+1)*binomial(n,k+1),(n-k)*binomial(n,k));
(%o2) h : (k + 1) binomial(n, k + 1) 
              -> (n - k) binomial(n, k)


(%i3) apply1(a(k),h);
              (- k - 1) binomial(n, k + 1)
(%o3)         ----------------------------
                                 n
                      2 (n - k) 2


(%i4) b(k):= -(k+1)*binomial(n,k+1);
(%i5) apply1(b(k),h);
(%o5)         (- k - 1) binomial(n, k + 1)


(%i6) c(k):= (k+1)*binomial(n,k+1);
(%i7) apply1(c(k),h);
(%o7)           (n - k) binomial(n, k)


Best regards
Giovanni Gherdovich

Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com