MathGroup Archive 2008

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

Search the Archive

Re: ReplaceAll

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90419] Re: [mg90372] ReplaceAll
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Wed, 9 Jul 2008 04:51:24 -0400 (EDT)
  • References: <200807080622.CAA17930@smc.vnet.net>

On 8 Jul 2008, at 15:22, 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.
>
> Thankx.
>
> Bruce
>
> 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]
>
>


You can see the reason more simply on this case:

s = b ** a1 ** (-a ** b1) ** b ** a1;

s /. b1 ** b -> x
b ** a1 ** (-a ** b1) ** b ** a1

No substitution is made. If you, however, replace -a by some symbol,  
say c, everything is fine:

  b ** a1 ** (c ** b1) ** b ** a1 /. b1 ** b -> x
b ** a1 ** c ** x ** a1

The problem is that your formula involves not simply  
NonCommutativeMultipply but also Times:

FullForm[s]

NonCommutativeMultiply[b,a1,Times[-1,NonCommutativeMultiply[a,b1]],b,a1]

Note that the following will work fine:

  b ** a1 ** ((-a) ** b1) ** b ** a1 /. b1 ** b -> x
b ** a1 ** (-a) ** x ** a1

The key point are the parentheses around -a .

Andrzej Kozlowski





  • References:
    • ReplaceAll
      • From: Bruce Colletti <bwcolletti@verizon.net>
  • Prev by Date: Re: Minimum input for GroebnerBasis
  • Next by Date: Re: PlotRange Trouble
  • Previous by thread: ReplaceAll
  • Next by thread: Re: ReplaceAll