Reputation: 140
I'm trying to use Dirac Bra-Ket notation in Maxima using the code from here http://raoul.koalatux.ch/sites/ladderoperator/ladder_operator.html
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));
For most expressions it works:
bra(0) . ket(0);
ket(1) . bra(0) . ket(0);
bra(1) . ket(1) . bra(0) . ket(0);
all simplify correctly, but
bra(1) . ket(1) . bra(0);
fails to simplify to bra(0). How can I get Maxima to simplify this case?
Upvotes: 1
Views: 257
Reputation: 5768
I think you can start with this:
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);
Upvotes: 2