qiskit-tutorials icon indicating copy to clipboard operation
qiskit-tutorials copied to clipboard

Function to write the state as bra and ket

Open aburousan opened this issue 4 years ago • 3 comments

What is the expected behavior?

Is it possible to write the state using bra-ket notation rather than array?

aburousan avatar Jul 08 '21 03:07 aburousan

@aburousan Do you mean to improve code readability by theorists? In that case, what about the usage of some specialized objects like in SymPy?

MartinBeseda avatar Jul 20 '21 12:07 MartinBeseda

Yes. As @MartinBeseda said you can use SymPy to do exactly what you want. You can try

from sympy.physics.quantum import Bra,Ket
from sympy import symbols, I
Ket('00')+Ket('11')

or maybe... Ket(symbols('psi')) @aburousan Hope it helps. Please do close the issue if you got the answer to your questions. Thanks 🙂

Shashank-Ravi-0 avatar Aug 12 '21 17:08 Shashank-Ravi-0

I have asked about this in stack exchange ( https://quantumcomputing.stackexchange.com/questions/18372/how-to-convert-the-output-column-vector-or-matrix-into-bra-ket-notation-using-py ). The first answer is what I was looking for. I hope someone in the future, can see this and get some help. I am curious if the new function (mentioned in the answer) is added or not in qiskit?

aburousan avatar Aug 12 '21 18:08 aburousan

Closing as not relevant to Qiskit tutorials and OP appears to have found a solution to their issue 😃

javabster avatar Aug 18 '23 20:08 javabster