Ask Your Question

Revision history [back]

There is a problem with your approach because the $c_i$ commute while $D_i$ anticommute.

After your definition of D, you can use noncommutative polynomials instead:

A = FreeAlgebra(SR, 2, names='c_')
c = A.gens()
exp = 0
for i in range(q):
    for j in range(q):
        exp = exp + c[i]*c[j]
print exp
print exp.subs({c[i] : D[i] for i in range(q)}).display(eU)

Output:

c_0^2 + c_0*c_1 + c_1*c_0 + c_1^2
[0] + [0] + [0] + [0] + [0]

The result is zero due to anticommutativity.