Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

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

Search the Archive

Re: Dot[]->1

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: Dot[]->1
  • From: John Lee <lee at math.washington.edu>
  • Date: Fri, 7 Aug 92 08:18:32 -0700

Michael Trott <trott at physik.th-ilmenau.de> writes:

>  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?

>  Actually I observed this behaviour first in expressions of the
>  above type with Dot --> NonCommutativeMultiply.


The reason for this behavior is that Dot has the Flat attribute, which
means that Dot[x,y] is equivalent to Dot[Dot[],x,y] for pattern matching
purposes.  The same goes for NonCommutativeMultiply. 

Here is an alternative pattern that does what you want:

  In[2]:= (Dot[] + Dot[x,y]) /. (x_Dot /; Length[x]==0) :> 1

  Out[2]= 1 + x . y

Jack Lee
Dept. of Mathematics
University of Washington
Seattle, WA








  • Prev by Date: Re: Dot[]->1
  • Next by Date: Re: CrossProduct[ ]
  • Previous by thread: Re: Dot[]->1
  • Next by thread: [no subject]