MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Transformation rule problem

  • To: mathgroup at
  • Subject: [mg58088] Re: Transformation rule problem
  • From: "Peltio" <peltio at>
  • Date: Sat, 18 Jun 2005 06:07:40 -0400 (EDT)
  • References: <d8rnfg$l4b$>
  • Reply-to: "Peltio" <peltioNOSPAM at>
  • Sender: owner-wri-mathgroup at

"Oliver Buerschaper" wrote:

>In a sum like for example
>    a^2 b^4 + a^3 b + a^5 + a^5 b
>I'd like to replace every instance of the product (a b) by a different
>expression, let's call it d. Thus my result should look like
>    d^2 b^2 + a^2 d + a^5 + a^4 d

Brute force to the rescue!

    rulen[a_, b_][d_] = a^n_*b^m_ :> d*(a^(n - 1)*b^(m - 1));
    rulea[a_, b_][d_] = a*b^m_ :> d*b^(m - 1);
    ruleb[a_, b_][d_] = a^n_*b :> d*a^(n - 1);

    mySimplify[expr_, a_ b_ -> d_] :=
        (expr //. rulen[a, b][d]) /. {rulea[a, b][d], ruleb[a, b][d]}

This only works when a and b are not "mixable", i.e. they are immediately
identifiable by sheer pattern matching.

Invalid address in reply to. Crafty demunging required to mail me.

  • Prev by Date: Re: delete something from a complex list
  • Next by Date: Re: splitting sublists
  • Previous by thread: Re: Transformation rule problem
  • Next by thread: associative arrays