Comment #1 on issue 3372 by [email protected]: Pauli algebra problems
http://code.google.com/p/sympy/issues/detail?id=3372
Lets look at the evaluate function:
tmp = arg.as_coeff_mul()
sigma_product = 1
com_product = 1
for el in tmp[1]:
if isinstance(el, Pauli):
sigma_product *= el
else:
com_product *= el
return (sigma_product*com_product)
This is all the code. If we start to execute it "by hand" we find:
In [33]: X = -I*Pauli(1)*Pauli(2)
In [34]: X.as_coeff_mul()
Out[34]: (-1, (I, sigma1, sigma2))
which is "tmp" and the -1 is inside tmp[0]. In the code, however,
tmp[0] is never used! Hence the sign dropped. That we loose factors
can be seen from this example:
In [39]: X = -I*4*Pauli(1)*Pauli(2)
In [40]: X.as_coeff_mul()
Out[40]: (-4, (I, sigma1, sigma2))
In [41]: evaluate_pauli_product(X)
Out[41]: -sigma3
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.