Quantum Computing Asked on January 22, 2021
I’m new to qiskit and I want to know how do I define a projector operator in qiskit? Specifically, I have prepared a 3 qubit system, and after applying a whole lot of gates and measuring it in a state vector simulator, I have to apply the projector operator $|0rangle_{1}|0rangle_{2} langle0|_{1}langle0|_{2}$ on the state that I get after I measured all the qubits in the circuit. I do know the physics and math behind it, and the tensor product it represents but I’m unable to code this successfully. I was thinking maybe a 4×4 matrix representation of this operator might help but I’m not sure about it.
So I’m asking 2 questions here-
Thanks in advance
So, there actually is a method called to_operator() for the class Statevector which takes a statevector and converts it into a projector operator. Here is the code to write your specific projector operator:
from qiskit.quantum_info import Statevector
zero = Statevector([1,0])
zero_state = zero.tensor(zero) # or zero_state = Statevector([1,0,0,0])
projector = zero_state.to_operator()
As you can see, you can input a state as a python list, or as a numpy array. If you print this projector, you will get the following output:
Then, after making your operator, you can use the method evolve() to apply the projector operator on a statevector:
statevector.evolve(projector)
Answered by Winona on January 22, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP