Re: Dot[]->1
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re: Dot[]->1
- From: David Withoff <withoff>
- Date: Fri, 7 Aug 1992 11:21:32 -0500
> On simplifying some large expressions via some rules I ended with
> expressions of the following type:
>
> Dot[]+Dot[x,y] .
> In this expression I would like to replace the first part by 1. So I tried:
>
> (Dot[] + Dot[x,y])/.{Dot[]->1}.
>
> But the result was not what I expected (1+x.y), but rather
>
> 1 + 1.x.y .
>
> Can somebody tell me how to do my disired replacement and what happens
> in the described example?
This is a consequence of Dot having the attribute Flat, and the way
Flat is currently implemented internally.
In[1]:= Dot[] + Dot[x, y] /. Dot[] -> 1
Out[1]= 1 + 1 . x . y
In[2]:= Attributes[Dot]
Out[2]= {Flat, OneIdentity, Protected}
In[3]:= Unprotect[Dot]; Attributes[Dot] = OneIdentity;
In[4]:= Dot[] + Dot[x, y] /. Dot[] -> 1
Out[4]= 1 + x . y
I've tried this particular change before, and although it's never caused
me any trouble I should add the warning that messing the the attributes of
built-in functions represents an incompatibility and sometimes breaks
other things in ways that can be hard to track down.
Dave Withoff
withoff at wri.com