6
$\begingroup$

I am trying to define some operators I use frequently. For example, I defined a KroneckerProduct operator as $\otimes $ as follows:

a_⊗b_:=a.b-b.a 

And this works fine.

Then I want to define a commutator used in quantum mechanics act like follows:

$${\left[ {a,b} \right]_ - } = a.b - b.a$$ $${\left[ {a,b} \right]_ + } = a.b + b.a$$

where a and b are matrices.

So I naively write the definition in Mathematica as follows:

$${\left[ {a{\rm{\_}},b{\rm{\_}}} \right]_ - }: = a.b - b.a$$ $${\left[ {a{\rm{\_}},b{\rm{\_}}} \right]_ + }: = a.b + b.a$$

But this will not work.

  1. How do I define the commutator in this form (appearance)?

  2. And why does the definition for a_⊗b_ hold, but the similar definition for commutator [a_, b_] does not hold?


There is another question which actually should create another post. But I choose just to add it here.

If I defined the KroneckerProduct as the operator in the way I did, then I found that in parallel computing, I can't simply distribute such a definition of like:

DistributeDefinitions[⊗] 

Mathematica doesn't allow me to do that. Of course the Parallelize will not distribute the definition automatically either. So if an expression contains a , simply Parallelize it, the computation will get stuck and no answer will come out.

So my second question is:

How do I distribute such an operator definition in parallel computing?

$\endgroup$
1
  • $\begingroup$ Unfortunately I have no time for a complete answer now, but for the first part, Notation package is your friend. See wolfram link here $\endgroup$ Commented Jan 31, 2013 at 10:59

2 Answers 2

7
$\begingroup$

Maybe it's this that you are looking for.

Using the notation Package you can write:

enter image description here

I used a image to show these yellow box. To create it, use the notation pallet that Popup when you call the Package. This is the pallet:

enter image description here

Use the second button to do your new notation.

More information about this in Wolfram help in this link.

$\endgroup$
0
$\begingroup$

Too long for a comment but not a complete answer. From the end

-I don't know how (or if it is possible) to distribute the operation in parallel computing.

-See this, and this question for defining a commutator.

In particular there is advice in the second one by Szabolics on how to use better notation if you don't like the one below.

-An anticommutator would be sufficiently defined by a rule I think, like so:

HoldAll[(l m + m l + l^2 + m m l )] /. {(a_ b_ + b_ a_) -> Anitcom[a, b], a_ a_ -> 0, a_^_->0} 

Where you can define Anticom on a case by case basis.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.