MathGroup Archive 1993

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

Search the Archive

Problem with Times. Bug ????


I am trying to implement a fast non-commutative operation  under
Mma to work with non-commutative algebras (see a  previous post). 
Among the things I tried, one was to redefine the Times operation
in order to make it non- commutative on a certain class of
objects, and to  reimplement the commutativity for all other
standard objects for which Times is usually commutative. I know that this
is _highly_ discouraged by the authors of Mma. I tried various
implementations, and got contradictory or inconsistent results, I
tracked down the problem and found this :

In[1]:= b a

Out[1]= a b      ! this is the standard order, Times is
		 ! commutative

In[2]:= Unprotect[Times];              

In[3]:= ClearAttributes[Times,Orderless]
                 ! This removes the commutativity of Times

In[4]:= b a

Out[4]= b a      ! OK, it doesn't commute anymore

In[5]:= a_*(b_+c_):=a*b + a*c;

		! This introduces the left ditributivity
		! of Times on Plus

In[6]:= 2 (1 + b a)

Out[6]= 2 + b a

		! the result is as expected.

In[7]:= 2 (1 - b a)

Out[7]= 2 - 2 a b

		! ????  the expression In[7] matches the pattern
		! on the left handside of In[5], but in the
		! replacement process Mma seems to have forgotten
		! that Times is not commutative anymore !!!

Is this a bug ? Is it due to a specific implementation of Times
in the Kernel of Mma, so that Times does not tolerate
modifications of its attributes ?

Thanks for your answers,

Adriano Barenco

Adriano Barenco
Inst. for Micro- and Optoelectronics
Dept. of Physics                         
Swiss Fed. Inst. of Technology (EPFL)
CH-1015 Lausanne  (Switzerland)
email: barenco at

  • Prev by Date: trig functions
  • Next by Date: new bug in Limit
  • Previous by thread: Re: trig functions
  • Next by thread: RE: Problem with Times. Bug ????