Issue with sympy quantum module

18 views
Skip to first unread message

Iman

unread,
Nov 21, 2022, 11:51:43 AM11/21/22
to sympy
Hello,

I encountered a issue with the output of the following script:

from sympy.physics.quantum import *
represent(Y(0)*Y(0),nqubits=1)

I am expecting the ouput being a 2 by 2 identity matrix. But instead,
the output is a single number 1.

I don't know if it is a bug in the Python code or I misused the python function.

Thank you,
Iman

Oscar Benjamin

unread,
Nov 21, 2022, 11:56:14 AM11/21/22
to sy...@googlegroups.com
It probably is a bug but the code shown does not run for another reason:

In [1]: from sympy.physics.quantum import *
...: represent(Y(0)*Y(0),nqubits=1)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-ba167e22823e> in <cell line: 2>()
1 from sympy.physics.quantum import *
----> 2 represent(Y(0)*Y(0),nqubits=1)

NameError: name 'Y' is not defined

--
Oscar

Iman

unread,
Nov 21, 2022, 12:03:19 PM11/21/22
to sympy
It runs on my PC. 
I imported additional modules: 
from sympy.physics.quantum import *
from sympy.physics.quantum.qubit import *
from sympy.physics.quantum.gate import *
from sympy.physics.quantum.grover import *
from sympy.physics.quantum.qft import QFT, IQFT, Fourier
from sympy.physics.quantum.circuitplot import circuit_plot

Sorry about the confusion. 
The output of a single Y(0) is correct. But two Y(0) multiplying is not. 
represent(Y(0),nqubits=1)

Oscar Benjamin

unread,
Nov 21, 2022, 5:44:27 PM11/21/22
to sy...@googlegroups.com
This is perhaps related to this issue:
https://github.com/sympy/sympy/issues/24153
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/ed61e2bc-b3ca-4209-b31f-fe35bfff0233n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages