MathGroup Archive 2008

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

Search the Archive

Re: ReplaceAll


Bruce Colletti wrote:

> Re Mathematica 6.0.2 under WinXP.
> 
> Why doesn't the following substitute x for b'**b (appears in the third, fourth, sixth and seventh summands)?  (a**b')**b/.b'**b->x does.

Note that

     (-a ** b') ** b /. b' ** b -> x

     (-a ** b') ** b

does not work either.

A quick glance at the TreeForm (or FullForm) of the expressions will 
reveal why.

     TreeForm[(a ** b') ** b]

     TreeForm[(-a ** b') ** b]


The following pattern handles correctly the negative case:


     (-a ** b') ** b /. ((f_) a ** b') ** b -> f a ** x

     -a ** x


> In[1]:= M=b**a'-a**b';
> Distribute[M**M**M,Plus]/.b'**b->x
> 
> Out[2]= (-a**b^\[Prime])**(-a**b^\[Prime])**(-a**b^\[Prime])+b**a^\[Prime]**(-a**b^\[Prime])**(-a**b^\[Prime])+(-a**b^\[Prime])**b**a^\[Prime]**(-a**b^\[Prime])+(-a**b^\[Prime])**(-a**b^\[Prime])**b**a^\[Prime]+b**a^\[Prime]**b**a^\[Prime]**(-a**b^\[Prime])+b**a^\[Prime]**(-a**b^\[Prime])**b**a^\[Prime]+(-a**b^\[Prime])**b**a^\[Prime]**b**a^\[Prime]+b**a^\[Prime]**b**a^\[Prime]**b**a^\[Prime]
> 

In[31]:= M = b ** a' - a ** b';
Distribute[M ** M ** M, Plus] /. ((f_) a ** b') ** b -> f a ** x

Out[32]= (-a ** x) ** a' ** (-a ** b') + (-a ** b') ** (-a ** x) ** a' +

   (-a ** b') ** (-a ** b') ** (-a ** b') + b ** a' ** (-a ** x) ** a' +

   b ** a' ** (-a ** b') ** (-a ** b') + (-a ** x) ** a' ** b ** a' +

   b ** a' ** b ** a' ** (-a ** b') + b ** a' ** b ** a' ** b ** a'

Regards,
-- Jean-Marc


  • Prev by Date: Re: PlotRange Trouble
  • Next by Date: Re: remote Kernel
  • Previous by thread: Re: ReplaceAll
  • Next by thread: Minimum input for GroebnerBasis