In sympy I have defined a two kets and a corresponding bra, when I apply the bra to the kets...
from sympy import sqrt
from sympy.physics.quantum import Bra,Ket,qapply
superpos = (Ket('Dead')+Ket('Alive'))/sqrt(2)
d = qapply(Bra('Dead')*superpos)
...I get this result:
sqrt(2)*<Dead|Alive>/2 + sqrt(2)*<Dead|Dead>/2
How do I set 'Dead' and 'Alive' as orthogonal states, so that d.doit()
gives sqrt(2)/2
?
So far I've only been able to substitute the brakets by hand:
d.subs(Bra('Dead')*Ket('Dead'),1).subs(Bra('Dead')*Ket('Alive'),0)
But how do I make the brakets evaluate automatically? Why doesn't the InnerProduct
result to 1 for identical brakets and 0 for brakets with different labels?