Suppose we start from 2 wires (q0 and q1) and through some quantum gates, suppose we measure q1 wire only.

As we measure the q1 wire, the state vector of this quantum state would be determined immediately. How can I print out this state vector?

In addition, I would like to print out the state vector of q0 wire only. Does anyone know how to do this task via qiskit or cirq or pyquil? (Any other package language is also fine!)

  • 1
    $\begingroup$ Do you mean the state before or after measurement? Note that, in general, before measurement this is not possible, because the two qubits can be entangled, which is exactly saying that the state of one of the qubits cannot be described without also describing the other qubit. Furthermore, after measurement the state is just the particular state associated with the measurement outcome. $\endgroup$ – JSdJ Jun 24 '20 at 7:30

This task can be done using Microsoft Q#

If you have two qubits which after quantum operations are in the state $|\psi\rangle$, and you wish to find the state of the qubit q0 before/without measurement, You can use Q#'s DumpRegister function which will print to the console the state of your qubits.

The output would look something like this

# wave function for qubits with ids (least to most significant): 0
∣0❭:     1.000000 +  0.000000 i  ==     ******************** [ 1.000000 ]     --- [  0.00000 rad ]
∣1❭:     0.000000 +  0.000000 i  ==                          [ 0.000000 ]    

If you choose to Measure the qubit q0 then its state collapses to the result of your measurement.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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