MathGroup Archive 2000

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

Search the Archive

Re: Re: Conversion of Orderless functions to non Orderless one

  • To: mathgroup at
  • Subject: [mg24158] Re: [mg24083] Re: [mg24046] Conversion of Orderless functions to non Orderless one
  • From: Andrzej Kozlowski <andrzej at>
  • Date: Wed, 28 Jun 2000 22:50:41 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

I don't think you can do this. Or rather, as you observed in your original
posting, you would have to clear the Orderless attribute in Times (and you
can't do this just for selected arguments). This is however highly
inadvisable for  various reasons (certain basic functions would break down).
The best thing I  can think of is to define your non-commutative times, e.g.

times[l___] :=  Times @@ DeleteCases[{l}, _?NonCommutativeQ] *
    NonCommutativeMultiply @@ Cases[{l}, _?NonCommutativeQ]


NonCommutativeQ[a] = True; NonCommutativeQ[b] = True;

and so on. You can then use the Notation package (<<Utilities`Notation`) to
define the infix notation * (in TraditionalForm) to mean "times" instead of
"Times". As long as users were working in TraditionalForm (and used * for
mutlitplication) they should not encounter any problems.


on 6/23/00 3:26 PM, zhl67 at at zhl67 at wrote:

> In article <8is7td$h61 at>,
> Andrzej Kozlowski <andrzej at> wrote:
>> It seems you want to be able to do some non-commutative algebra. The
>> question is "how much?" If you want to do only what you wrote in your
>> posting and no more than the following might be enough.
>> In[1]:=
>> SetAttributes[times, {Flat, OneIdentity}]
>> In[2]:=
>> times[l___] :=
>> Times @@ DeleteCases[{l}, a | b | c] **
>> NonCommutativeMultiply @@ Cases[{l}, a | b | c]
>> Now you can get something like what you asked for:
>> In[4]:=
>> times[c, x, y, b, v, a, z]
>> Out[4]=
>> (v x y z) ** c ** b ** a
>> However,if  you want be able to do any algebra, e.g. expand
> expressions etc.
>> then the the only choice (not involving a lot of
>> programming) seems to be to download the NonCommutative algebra
> package
>> available on MathSource. It is a powerful package which I used quite
> lot
>> about a year ago. You should be warned however of several problems.
> First of
>> all, the documentation is very inconvenient, being in the form of a
> dvi file
>> without hyperlinks. Secondly, it is not really a proper Mathematica
> package
>> (it does not use contexts). The easiest way to load it is  to use
>> SetDirectory to enter the NCAlgebra directory and load the
> NCAlgebra.m file
>> (which loads in  a number of individual  files of which this "package"
>> consists of) with:
>> << NCAlgebra`
>> The functions defined in this "package" allow you to do a lot of
>> non-commutative algebra, of the kind
>> you seem to be interested in, but you have to carefully  avoid using
> many
>> built in functions (e.g. you should use NonCommutativeExpand, not
> Expand,
>> you can't use the built in  Power, and so on. Of course I do not mean
> that
>> your computer will explode if ytou do so, just that you will get
> answers
>> which are likely to be wrong). It would certainly seem a good idea for
>> Mathematica to include more non-commutative functions than the very
>> rudimentary NonCommutativeMultiply. There has been some talk about
> this for
>> a long time but so far other things seem to have been given higher
> priority.
> First of all, thanks, Andrzej.
> I think I didn't state my question in  full clearence. Actually I know
> about the package NCAlgebra and have kept my eyes open toward it for
> quite some time, but gradually frustrated with it in some aspects (Not
> all). Besides the inconveniences mentioned above, there are some other
> problems with the NCAlgebra packages, for instance, it leaves
> expressions like a**a**a unchanged by default, rather than changes it
> into powers of a. Of cause there is the function NCUnMonimial defined
> in the subpackage NCMonomial.m, but that function has some bugs in it,
> for example
> In[1]:= NCUnMonimial[Exp[a]**Exp[b]]
> gives the result
> Out[1]:=
> Exp[a+b]
> regardless of the fact that a and b are both noncommutative. Other
> aspects of shortcomings of the NCAlgebra package include:
> (1)there is only a limited capability in the function NCInverse (which
> treats only 2 by 2 matrices)
> (2)the Gauss decomposition of matrices works also only for 2 by 2
> matrices
> (3)there isn't a function towards the evaluation of Commutators, which
> is necessary for a study of Lie algebra
> (4)though NCSolve does a careful check for the solution it gets, its
> capability in solving a system of noncommutative based linear equations
> is very weak
> and so on. Due to these reasons, I have started writing an alternative
> noncommutative algebra package which contains a selected subset of
> capabilities of NCAlgebra package and adds some more, and I expect that
> there will be some enhancements or improvements in the first parts of
> the functions comparing to NCAlgebra.
> My original question just emerged during the process of the development
> of the package I am writing: I realize that it is often meaningless to
> write the usual multiplication between noncommutative objects, and I
> wish my program will forgive the users (if they happen to have written
> such an expression) in such a way that it converts the ordinary Times
> into noncommutative multiplication (which actually bears a different
> function name in my package because I would not like to get my
> expressions messed up by the joint effect of my package and NCAlgebra)
> automatically and issue a warning message at the same time. This might
> not at all be necessary, but I am just curious whether this could be
> possible.
> Liu Zhao
> Sent via
> Before you buy.

  • Prev by Date: Re: Export to Word2000
  • Next by Date: RE: RE: Mathematica for High School Students
  • Previous by thread: Re: Conversion of Orderless functions to non Orderless one
  • Next by thread: Need good Mathematica programmer