我正在尝试使用此处的代码http://raoul.koalatux.ch/sites/ladderoperator/ladder_operator.html
在Maxima中使用Dirac Bra-Ket表示法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));
对于大多数表达方式,它都有效:
bra(0) . ket(0);
ket(1) . bra(0) . ket(0);
bra(1) . ket(1) . bra(0) . ket(0);
所有都正确简化,但
bra(1) . ket(1) . bra(0);
无法简化为bra(0)。我怎样才能让Maxima简化这种情况呢?
答案 0 :(得分:2)
我想你可以从这开始:
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);