# Defining a*b=-b*a

I am fairly new to using Mathematica and was wondering if it's possible to define something along the lines of: $$a*b=-b*a$$ a sort of antisymmetry or skew symmetry if you will. I would like to do this so that when I multiply by some number say: $$a*b*3=-b*a*3$$ where the order in which the "a" and "b" are multiplied is preserved since there would be a antisymmetry. Hence, $$\left(a*b*3 \right) + \left(b*a*3 \right)=0$$ Would this be possible to do in Mathematica.

Edit: Essentially what I would like to define is the following

$$a_{i} a_{j}=\left\{\begin{array}{ll}-a_{j} a_{i}, & \text { For } i \neq j \\ 1, & \text { For } i=j\end{array}\right.$$

I have written the following in Mathematica using NonCommutativeMultiply[],

Unprotect[a]
ClearAll@a
a /: NonCommutativeMultiply[a[i_], a[j_]] /;
i < j := -NonCommutativeMultiply[a[j], a[i]]
a /: NonCommutativeMultiply[a[i_], a[i_]] := 1
Protect[a]


which gets only half the job done. I guess I would like to have this noncommutative multiplication follow all the usual axioms that the usual binary operation of multiplication does, (factoring out like terms, distributive property, works on vectors, etc.). There is no guide in how to define new rules for this new operation and the NonCommutativeMultiply[] only gets me so far. Is there any where I can read or get some assistance in order to properly define this? Thank you

• a *b == b * a gives True by default, so you would have to "undo" previously defined rules of multiplication. My advice is to define a new operation that acts as your multiplication, instead of overwriting the existing one. This is also done in the Quaternions package, defining ' ** ' as the quaternion multiplication. reference.wolfram.com/language/Quaternions/tutorial/… . In the case of Matrices, dot acts as the multiplicative operation. Apr 24, 2020 at 3:53
• Take a look at Defining rules for anti-commutative multiplication and Symbolic calculations with generators and relations. You May also be interested in the general ideas from Hot to define a non-standard algebra in Mathematica. Apr 24, 2020 at 3:55
• More to the point, please look up NonCommutativeMultiply[] already, if you haven't done so yet. Apr 24, 2020 at 3:56
• Thank you all for your comments and help! I'll be sure to check them all out Apr 24, 2020 at 4:01
• I'm not sure but the package NCAlgebra might be useful. Apr 28, 2020 at 15:51

What you are trying to do is implement a Grassmann Algebra. A Grassmann Algebra is exactly the algebra of anti commuting numbers you describe above. That kind of algebra is frequently met in quantum many particle physics. Fermion coherent states for example have eigenvalues which anti commute.

Since Grassmann numbers are well known in Physics it's obvious that someone implemented this before and a with a quick internet search a very nice package by Mathew Headrick named grassmann.m can be found on his site.

You can define the generators of your algebra with the Fermion function:

Fermion[a, b]


Afterwards you can use them with the NonCommutativeMultiply operator.

A few tests:

a**b + b**a
Out: 0


Another test

a**b + 2*b**a
Out: -a**b


Final test

a**a
Out: 0


That package has many more features, which might be useful depending on your area of interest. The package also includes an extensive documentation. As stated on the website if you use that package for research always remember to give proper credit to the author.

• Thank you so very much this helps immensely! And I sure will! May 1, 2020 at 18:44

Make use of FeynCalc. It is a package from the online Mathematica package repository on github.com: FeynCalc

The command is:

DeclareNonCommutative[a, b]


And then:

DataType[a, b, NonCommutative]


This has the datatypes: NonCommutative, PositiveInteger, NegativeInteger, PositiveNumber, FreeIndex, and GrasmannParity.

There are definitions like Anticommutator, DotSimplify, CommutatorExplicit and more.

With the package, FeynCalc comes great documentation with good examples.