I'd like to be able to use Mathematica to preform some basic quantum mechanics and quantum computation operations using Dirac's Bra-Ket notation.
I've seen several solutions to defining basic behaviors, and can roll my own with something rudimentary that takes lists of components expressed in a fixed basis, like
Bra[1]=Bra[{1,0}];Ket[1]=Ket[{1,0}];
Bra[0]=Bra[{0,1}];Ket[0]=Ket[{0,1}];
Bra[l_]:={Conjugate[l]}
Ket[l_]:=Transpose@{l}
AngleBracket[0,y_]:=0
AngleBracket[x_,0]:=0
AngleBracket[x_,y_]:=Bra[x].Ket[y]//First//First
Clear[VerticalSeparator]
AngleBracket[bra___,VerticalSeparator[x_,y_],ket___]:=AngleBracket[x,y]
But this only goes so far. For example I'd minimally also like to implement outer products
$$\left|u\right>\left<v\right|$$
basic tensor notation
$$\left|u\right>\otimes\left|v\right>\otimes\left|w\right>\equiv\left|u,v,w\right>\equiv\left|uvw\right>$$
and the key properties of bras and kets — e.g. ($\left|u\right>)^*=\left<v\right|$.
Ideally I'd like more, such as factoring and decomposition, or easy change of bases.
I also understand that there are some sophisticated packages that do all this and more. But these seem to be far more complex than I need, and are also quite old (and produce odd formatting that makes me wonder if they can even be relied on in the current version of MMA (the latest version mentioned for QUANTUM in 8).
There are two possible solutions I'd be interested in:
Are there simple things I can do myself, e.g., extending the rudimentary start I've made above, that will get me most of what I want?
Is there a more recent comprehensive package stable current package available than QUANTUM. (Alternatively perhaps someone can confirm that QUANTUM works error-free with v.11; and can help fix the odd formatting of bras and kets.)
Truth be told, I'd prefer the former solution, to keep things simple and to avoid introducing too many definitions and redefinitions; but I'd also be interested in the latter if a current easy to use and well documented package is available.
Using Notation
I can get something started with
<<Notation`
Notation[|1\[RightAngleBracket] \[DoubleLongRightArrow] |{1,0}\[RightAngleBracket]];Notation[\[LeftAngleBracket]1| \[DoubleLongRightArrow] \[LeftAngleBracket]{1,0}|];
Notation[|0\[RightAngleBracket] \[DoubleLongRightArrow] |{0,1}\[RightAngleBracket]];Notation[\[LeftAngleBracket]0| \[DoubleLongRightArrow] \[LeftAngleBracket]{0,1}|];
Notation[|x_\[RightAngleBracket] \[DoubleLongRightArrow] Transpose@{x_}]
Notation[\[LeftAngleBracket]y_| \[DoubleLongRightArrow] {Conjugate[y_]}]
Notation[\[LeftAngleBracket]x_\[VerticalSeparator]y_\[RightAngleBracket] \[DoubleLongRightArrow] \[LeftAngleBracket]x_|.|y_\[RightAngleBracket]]
Notation[|x_\[RightAngleBracket]\[LeftAngleBracket]y_| \[DoubleLongRightArrow] |x_\[RightAngleBracket].\[LeftAngleBracket]y_|]
(It looks neater in MMA.)
AngleBracket
? There's the symbolBraKet
which you could work with instead. And[esc]bra[esc]
will give you aBra
to work with,[esc]ket[esc]
will give you aKet
, and[esc]brakey[esc]
will give you aBraKet
. $\endgroup$Notation
looks interesting. $\endgroup$Notation
looks pretty cool (see addition to Q). $\endgroup$