3
$\begingroup$

I am working with sympy.physics.quantum.qubit to help teach myself more about quantum computing.

I'm confused about how best to simplify two ket expressions that appear to me to be identical. Seems to me that B and C below should be the same:

B = Qubit('01')

C = TensorProduct(Qubit('0'),Qubit('1'))

because their representation is identical, i.e.

B.represent() == C.represent()       #returns True

it feels like they are the same qubit state. So far, so good.

But now when I print out B and C I get:

print("B is", B)

B is |01>

but

print("C is", C)

C is |0>x|1>

My question:

Is there some way I could get the Python library to use the output of B and C so that the equivalence between the two would be obvious? Basically, how do I get C to simplify it's output so that it exactly resembles B?

Am grateful for any help you could provide.

$\endgroup$

1 Answer 1

2
$\begingroup$

After some more reading of the documentation, I now realize the C above is a TensorProduct object (and not a Qubit) but B is a Qubit. The way you can make the tensor product become a Qubit (and print it out in a way that's comparable with B) is to just call:

matrix_to_qubit(represent(C))

which returns a Qubit with the answer you'd expect.

Thanks for being patient with me as I worked that out.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.