On Sat, Nov 5, 2011 at 3:11 AM, Aaron Meurer <[email protected]> wrote:

> This is probably the same bug.  Try using Integer(1) everywhere where
> you have 1 (a shorter version that also should work is S(1)).
>
> I opened http://code.google.com/p/sympy/issues/detail?id=2824 for this.
>
> Aaron Meurer
>

Thanks! I changed every number with S(0) and S(1), but get the same error:

from sympy import *
from sympy.physics.quantum import *
from sympy.physics.quantum.qubit import *

q0 = Qubit(S(0))
q1 = Qubit(S(1))
state = TensorProduct(q0,q1) # a 2-qubit state
id = q0*Dagger(q0)+q1*Dagger(q1) # identity
proj = TensorProduct(id, q1*Dagger(q1)) # a projection op. IxP on H1xH2
print qapply(tensor_product_simp(proj*state)) # error

To make it clear I wrote down the intended calculation here:
http://mathurl.com/3pe3v7c It fails at qapply step.

I hope this helps. Have a good day!
vug



>
> 2011/11/4 Uğur Güney <[email protected]>:
> > Thanks! "Integer(1)" worked as expected. But can you please tell me why
> > "Qubit(0)*Dagger(Qubit(0))+Qubit(1)*Dagger(Qubit(1))" does not work as
> the
> > identity operator?
> > from sympy import *
> > from sympy.physics.quantum import *
> > from sympy.physics.quantum.qubit import *
> > state = TensorProduct(Qubit(0),Qubit(1)) # example state
> > id1 = Integer(1) # identity op. type 1
> > id2 = Qubit(0)*Dagger(Qubit(0))+Qubit(1)*Dagger(Qubit(1)) # identity op.
> > type 2
> > proj1 = TensorProduct(id1, Qubit(1)*Dagger(Qubit(1))) # projection op
> which
> > affect only the second Hilbert space
> > proj2 = TensorProduct(id2, Qubit(1)*Dagger(Qubit(1)))
> > # apply operator on the state
> > print "1)"
> > print qapply(tensor_product_simp(proj1*state)) # this works
> > print "2)"
> > print qapply(tensor_product_simp(proj2*state)) # this gives an error
> > # AttributeError: 'int' object has no attribute 'is_commutative'
> > Regards,
> > vug
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sympy" 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?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" 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?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" 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?hl=en.

Reply via email to