3
$\begingroup$

How do I get the amplitude of each qubit, like plot_bloch_multivector(), but not output the tensor product of all qubits.enter image description here

In this case I need output [0.707, -0.707], [0, 1], [0.707, 0.707], [0.707, 0.707]. How can I get this?

$\endgroup$

1 Answer 1

5
$\begingroup$

You mean something like this?

from qiskit import Aer, execute, QuantumCircuit
from qiskit.quantum_info import Statevector

backend = Aer.get_backend("statevector_simulator")
qc = QuantumCircuit(1, 1)
qc.h(0)
print(qc)
result = execute(qc, backend=backend, shots=1).result()
print('State Vector:', result.get_statevector() )

enter image description here


Update: If you have two qubits or more, then you can also use this function as shown here:

from qiskit import Aer, execute, QuantumCircuit
from qiskit.quantum_info import Statevector

backend = Aer.get_backend("statevector_simulator")
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.h(1)
print(qc)
result = execute(qc, backend=backend, shots=1).result()
print('State Vector:', result.get_statevector() )

enter image description here


Now, if you are working with multi-qubit system then one of the thing you have to remember is that they might be entangled together. So you don't expect any two qubit state $|\psi \rangle \in \mathbb{C}^4$ can be written as $|\psi \rangle = |\phi_1 \rangle \otimes |\phi_2 \rangle $ where $|\phi_1\rangle$ and $|\phi_2\rangle$ belongs to $\mathbb{C}^2$. For example, if you look at this circuit:

enter image description here

You can't write each qubit state individually! That is the state $|\psi \rangle = \dfrac{1}{\sqrt{2}}\begin{pmatrix} 1 \\ 0 \\ 0 \\ 1 \end{pmatrix} \neq \begin{pmatrix} a \\ b \end{pmatrix} \otimes \begin{pmatrix} c \\ d \end{pmatrix} $ with $a,b,c,d \in \mathbb{C}$ and $|a|^2 + |b|^2 =1 $ and $|c|^2 + |d|^2 = 1$.


Now the state is separable and you want to measure on one of them, you can do this:

from qiskit import Aer, execute, QuantumCircuit
from qiskit.quantum_info import Statevector

backend = Aer.get_backend("statevector_simulator")
qc = QuantumCircuit(2, 1)
qc.h(0)
qc.h(1)
qc.measure([1],[0])
print(qc)
result = execute(qc, backend=backend, shots=1).result()
print('State Vector:', result.get_statevector() )

enter image description here

As you can see, the qubit that got measured will collapsed its state to either the state $|0\rangle$ or $|1\rangle$.... Now, if it collapsed to the state $|0\rangle$ then the State Vector now is $|\psi \rangle \otimes |0\rangle$ . Similarly, if it collapsed to the state $|1 \rangle$ then you get $|\psi \rangle \otimes | 1 \rangle$. Either way, this allow you to observe what $|\psi\rangle$ is now... For instance, the State vector above tells you that $|\psi \rangle$ is the the superposition state $\dfrac{|0\rangle + |1 \rangle}{\sqrt{2}}$, which is what you expected as you applied the Hadamard gate $H$ to it.

And I can extend this to higher system as well... Just measured the other states.


Now having said all that, if your circuit only consist of single qubit gates, then you can just decompose that to multiple circuits consisting of single qubit in each. This will make thing easier to consider!

$\endgroup$
5
  • $\begingroup$ If I have multiple qubits, how do I separate the statevector? $\endgroup$
    – Gao Think
    Commented Nov 6, 2020 at 3:12
  • $\begingroup$ Yeah, but that gives you the tensor product of all the qubits,I need the respective states of each qubit, as shown by the plot_bloch_multivector() output $\endgroup$
    – Gao Think
    Commented Nov 6, 2020 at 3:22
  • $\begingroup$ but why plot_bloch_multivector() can output |ϕ1⟩ and |ϕ2⟩ respectively?If no entanglement is generated, does the system preserve the state of each qubit separately? $\endgroup$
    – Gao Think
    Commented Nov 6, 2020 at 3:26
  • $\begingroup$ In the case of entanglement, it is not possible to output separately. But if not, I wonder is there a way to output it?Because the bloch sphere cannot see the global phase of -|1>, I need the amplitude of a single quantum state. $\endgroup$
    – Gao Think
    Commented Nov 6, 2020 at 3:30
  • 1
    $\begingroup$ Thank you for your patience and that's one way to do it $\endgroup$
    – Gao Think
    Commented Nov 8, 2020 at 0:30

Your Answer

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

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