A lists of some issues with sympy.physics.quantum that needs fixing...

Robert Johansson

In [1]:
from sympy import *
init_printing()

from sympy.physics.quantum import *

Innerproducts of tensor products are not evaluated

In [2]:
ket1 = FermionFockKet(0)
ket2 = FermionFockKet(1)

tp = TensorProduct(ket1, ket2)
In [3]:
p = Dagger(tp) * tp

p, p.doit()  # Does not evaluate
Out[3]:
$$\begin{pmatrix}{{\left\langle 0\right|}}\otimes {{\left\langle 1\right|}} {{\left|0\right\rangle }}\otimes {{\left|1\right\rangle }}, & {{\left\langle 0\right|}}\otimes {{\left\langle 1\right|}} {{\left|0\right\rangle }}\otimes {{\left|1\right\rangle }}\end{pmatrix}$$

Qubits does not work with TensorProduct

The Qubit class has its own way of managing composite quantum systems (tensorproducts)...

In [4]:
from sympy.physics.quantum.qubit import *
In [5]:
q1 = Qubit("0")
q2 = Qubit("1")
In [6]:
p = Dagger(q1) * q2

p, p.doit()  # OK
Out[6]:
$$\begin{pmatrix}\left\langle 0 \right. {\left|1\right\rangle }, & 0\end{pmatrix}$$
In [7]:
tp = TensorProduct(Qubit("0"), Qubit("1")); tp
Out[7]:
$${{\left|0\right\rangle }}\otimes {{\left|1\right\rangle }}$$
In [8]:
p = Dagger(tp) * tp

p, p.doit()  # Does not work. 
Out[8]:
$$\begin{pmatrix}{{\left\langle 0\right|}}\otimes {{\left\langle 1\right|}} {{\left|0\right\rangle }}\otimes {{\left|1\right\rangle }}, & {{\left\langle 0\right|}}\otimes {{\left\langle 1\right|}} {{\left|0\right\rangle }}\otimes {{\left|1\right\rangle }}\end{pmatrix}$$
In [9]:
TensorProduct(Qubit("10"), Qubit("10"))  # not working properly either
Out[9]:
$${{\left|10\right\rangle }}\otimes {{\left|10\right\rangle }}$$

TensorProducts of bra's and ket's is printed with double vertical bars

In [10]:
bra = Bra("psi")
ket = Ket("phi")
In [11]:
bra * ket  # OK
Out[11]:
$$\left\langle \psi \right. {\left|\phi\right\rangle }$$
In [12]:
TensorProduct(bra, bra) * TensorProduct(ket, ket)  # Double vertical bars
Out[12]:
$${{\left\langle \psi\right|}}\otimes {{\left\langle \psi\right|}} {{\left|\phi\right\rangle }}\otimes {{\left|\phi\right\rangle }}$$
In [13]:
type(bra * ket)
Out[13]:
sympy.physics.quantum.innerproduct.InnerProduct
In [14]:
type(TensorProduct(bra, bra) * TensorProduct(ket, ket))  # not recognized as an InnerProduct
Out[14]:
sympy.core.mul.Mul

Nonsense tensorproducts

In [15]:
bra = Bra("psi")
ket = Ket("phi")
In [16]:
TensorProduct(bra, ket)
Out[16]:
$${{\left\langle \psi\right|}}\otimes {{\left|\phi\right\rangle }}$$
In [16]:
 
In [ ]: