Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Conversion of Orderless functions to non Orderless one

  • To: mathgroup at
  • Subject: [mg24107] Re: [mg24046] Conversion of Orderless functions to non Orderless one
  • From: Daniel Lichtblau <danl at>
  • Date: Tue, 27 Jun 2000 00:51:59 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

zhl67 at wrote:
> Hi, there
> My question might be silly to somebody out there but it really bothers
> me: Is there any way to convert an orderless function into non
> orderless ones for a certain range of arguments?
> For instance, let's say have a set Operators:
> Operators={a,b,c}
> What I wanted to do is that whenever expressions like Times[b,a,c] is
> entered, the outcome should look like b**a**c (i.e. Times turned into
> NonCommutativeMultiply). The special requirement is that this change
> happens only for members of the set Operators (otherwise I can just
> ClearAttributes[Times,Orderless] ), and that the output keeps the order
> of the input argument, i.e. it should be b**a**c, NOT a**b**c. Could
> anyone help the case?
> Liu Zhao
> Univ. York, UK
> Sent via
> Before you buy.

Rather than mess with Times, you could make a function that separates
the factors into noncommuting and commuting variables. Below is an
example of how this might be done.

In[6] := operators = {a, b, c};

In[7] := myMultiply[nclist_List, x__] := 
    Module[{j, fax = {x}, len, comm = {}, noncomm = {}}, len =
      For[j = 1, j <= len, j++, fac = fax[[j]];
        If[MemberQ[nclist, fac], noncomm = {noncomm, fac}, 
          comm = {comm, fac}];];
      Apply[Times, Flatten[comm]]*
        Apply[NonCommutativeMultiply, Flatten[noncomm]]]

In[8] := myMultiply[operators, q, r, s, b, t, y, a, x, w, q, c, d, f]
Out[8] = d f q r s t w x y b ** a ** c

Daniel Lichtblau
Wolfram Research

  • Prev by Date: Unix Sound Problems
  • Next by Date: How to operate on strictly numerical functions ?
  • Previous by thread: Conversion of Orderless functions to non Orderless one
  • Next by thread: Re: Conversion of Orderless functions to non Orderless one