Re: algebraic substitution rules
- To: mathgroup at smc.vnet.net
- Subject: [mg30743] Re: algebraic substitution rules
- From: bghiggins at ucdavis.edu (Brian Higgins)
- Date: Sun, 9 Sep 2001 03:26:36 -0400 (EDT)
- References: <9ncfq6$pt5$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
You want to apply the last rule a_->Expand[a], after you have applied
all the other rules. Thus
In[1]:=1 + x^2 + x^3 + x^4 /. {x^2 -> 1 + x, x^3 -> x*(1 + x),
x^4 -> (1 + x)^2} /. a_ :> Expand[a]
Out[1]=3 + 4*x + 2*x^2
Brian
Cattiaux Isabelle <Isabelle.Cattiaux at univ-valenciennes.fr> wrote in message news:<9ncfq6$pt5$1 at smc.vnet.net>...
> Hi,
>
> Could someone tell me why the first substitution rule
> works and the second doesn't
>
> In[1]:==
> 1+x^2+x^3+x^4 /. {x^2->1+x ,x^3->x(1+x) ,x^4->(1+x)^2}
>
> Out[1]==
> 2 + x + x(1 + x)+ (1 + x)^2
>
> In[78]:==
> 1+x^2+x^3+x^4 /. {x^2->1+x ,x^3->x(1+x) ,x^4->(1+x)^2,a_->Expand[a]}
>
> Out[78]==
> 1 + x^2 + x^3 + x^4