MathGroup Archive 2012

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

Search the Archive

Re: Non Commutative Multiply

  • To: mathgroup at
  • Subject: [mg128607] Re: Non Commutative Multiply
  • From: Roland Franzius <roland.franzius at>
  • Date: Thu, 8 Nov 2012 19:01:50 -0500 (EST)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <k7fm4l$jko$>

Am 08.11.2012 08:14, schrieb Rodrigo AP:
> Dear group,
> I want to multiply two matrices, for example,
> A = {{e, f}, {g, h}}
> B = {{a, b}, {c, d}}
> Using A.B, Mathematica returns
> {{a e + b g, a f + b h}, {c e + d g, c f + d h}}
> I would like to get, however, the following result:
> {{e a + f c, e b + f d}, {g a + h c, g b + h d}}
> since, for me, the entries {a,b,c,d,e,f,g,h} are operators, i.e., they
> are non-commutative.
> I could solve this problem clearing the attribute "Orderless" in the
> built-in function Times:
> ClearAttributes[Times, Orderless]
> I know, however, this can be dangerous. I tried to define a function
> Times2[a_,b_]:=Times[a,b]
> and then use ClearAttributes[Times2, Orderless] but it doesn't work.
> How could I solve this problem?

Changing fundamental operators like Times is not a solution. It will 
cause a breakdown of the algebra machine.

Use operator  Inner  and

a multiplicative oprator symbol from


CircleTimes, SmallCircle.

SmallCircle[A_?MatrixQ, B_?MatrixQ]:=Inner[SmallCircle[#1,#2]&,A,B,Plus]
SmallCircle[A_,B_, C___]:=SmallCircle[SmallCircle[A,B], C]

Now you can enrich procedures like Simplify, Factor and Expand by the 
typical set of rules for the linear expressions with head Plus und Times, eg


  SmallCircle[a___,b_+c__,d___]:> SmallCircle[a,b,d]+SmallCircle[a,c,d],
SmallCircle[a___,b_?NumericQ c__:1,d___]:>b*SmallCircle[a,b,d]}

Probably it is better to give the class of noncommutative objects an 
identity by naming them explicitely in a logical statement as

operators = {P,Q, d_Q, d_P}



OperatorQ[x_]:= MemberQ	[ operators, x]

and formulate the rules in such a way that only products and powers of 
operators remain inside the noncommutative operator product.

This makes it easier to extract the typical scalar functions, starting 
with Power and in principle has to be applied to the body of all special 
complex functions.


Roland Franzius

  • Prev by Date: Re: Non Commutative Multiply
  • Next by Date: Re: Help with map /@
  • Previous by thread: Re: Non Commutative Multiply
  • Next by thread: Re: Non Commutative Multiply