Created
December 31, 2015 18:00
-
-
Save tymat/d7d475a7d8c87f9be120 to your computer and use it in GitHub Desktop.
Maxima - Proper use of Dirac bra-ket notation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare(bra, nonscalar); | |
declare(ket, nonscalar); | |
dotscrules:true; | |
matchdeclare(m,lambda([t],featurep(t,integer))); | |
matchdeclare(n,lambda([t],featurep(t,integer))); | |
tellsimp(bra(m).ket(n), kron_delta(m,n)); | |
simp:false; | |
matchdeclare(aa, true); | |
matchdeclare(bb, true); | |
matchdeclare(cc, true); | |
tellsimp (aa.(bb.cc),(aa.bb).cc); | |
simp:true; | |
/* Tests */ | |
bra(0) . ket(0); | |
ket(1) . bra(0) . ket(0); | |
bra(1) . ket(1) . bra(0) . ket(0); | |
bra(1) . ket(1) . bra(0); | |
ket(1) . bra(1) . ket(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is very helpful! Though I would add
dotdistrib:true;
for(bra(2) + 1) . ket(2);
to give the correct result.