Re: a finicky rule
- To: mathgroup at smc.vnet.net
- Subject: [mg41725] Re: [mg41714] a finicky rule
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Tue, 3 Jun 2003 07:13:06 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On Monday, June 2, 2003, at 05:35 pm, Selwyn Hollis wrote: > Group, > > I'm having a difficult time understanding the following behavior. > > I define this rule: > > pullx := c_. + (a_.) x_^(p_.) + (b_.)x_^(q_.) -> > c + x (a x^(p-1) + b x^(q-1)) > > and it works here: > > x^3 + x^2 - 1 /. pullx > > -1 + x*(x + x^2) > > but not here: > > x^3 - x^2 - 1 /. pullx > > -1 - x^2 + x^3 > > even though the pattern matches: > > MatchQ[x^3 - x^2 - 1, pullx[[1]]] > > True > > I thought perhaps some simplification was being done on the result, > but: > > (x^2 - x)*x - 1 > > -1 + x (-x + x^2) > > Any ideas? (This is 4.1, Mac OS X.) > > Thanks. > > ----- > Selwyn Hollis > http://www.math.armstrong.edu/faculty/hollis The answer is that you did get a match, and the function was transformed. The problem is that the match is not what you expected it to be. Just look at x^3 - x^2 - 1 /. pullx // Trace and you will see clearly the match and the translformation, whch by accident taks you back to what you started with. To see all possible matches use ReplaceList: ReplaceList[x^3 - x^2 - 1, pullx] {-1 - x^2 + x^3, -1 - x^2 + x^3, -1 + x*(-x + x^2), -1 + x*(-x + x^2)} Simplify[%] {-1 - x^2 + x^3, -1 - x^2 + x^3, -1 - x^2 + x^3, -1 - x^2 + x^3} Andrzej Kozlowski Yokohama, Japan http://www.mimuw.edu.pl/~akoz/ http://platon.c.u-tokyo.ac.jp/andrzej/