Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Transformation rule problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58088] Re: Transformation rule problem
  • From: "Peltio" <peltio at trilight.zone>
  • Date: Sat, 18 Jun 2005 06:07:40 -0400 (EDT)
  • References: <d8rnfg$l4b$1@smc.vnet.net>
  • Reply-to: "Peltio" <peltioNOSPAM at despammed.com.invalid>
  • Sender: owner-wri-mathgroup at wolfram.com

"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.

cheers,
Peltio
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