5

I've written the following code for simple quantum mechanics operators on spin states:

enter image description here

It seems to work, but the output could be better - how do I let Mathematics know that $0**\ 0==0$, and can I let it compress the up/down ket to have only the 2 arrows, not the "$**$" in between?

Frank
  • 387
  • 1
  • 7
  • You can use Bra, Ket and you can Unprotect NonCommutativeMultiply. – evanb May 08 '15 at 23:13
  • Do you have details about Bra and Ket? I can't seem to find much documentation about these two in Mathematica's help itself... – Frank May 09 '15 at 03:41
  • Unfortunately, no. As far as I know they're Heads with no meaning (unless you give them meaning!) that simply render very nicely. – evanb May 10 '15 at 07:32

1 Answers1

8

Unprotecting and giving meaning to ** (NonCommuntativeMultiply) will do the trick:

Unprotect[NonCommutativeMultiply]
NonCommutativeMultiply[H___, 0, T___] := 0
evanb
  • 6,026
  • 18
  • 30