3
$\begingroup$

I'm just starting with Qiskit and I would like to reproduce basic results about spin measurements. For that I want to prepare multiple spins each in arbitrary directions and measure them in arbitrary directions to get the probabilities.

What is the suggested way to do that in Qiskit?

$\endgroup$
2
3
$\begingroup$

The suggested way to do measurements in a different axis is to change the orientation of the state vector at the end and measure in the $z$-basis as usual.

To go from one basis to the other you can use $H$ and $S=\sqrt{Z}$ gates that act as unitary transformations of your system. If you apply $H$ to your qubit and then do a measurement, it is the same as measuring in the $x$-axis. $HS^\dagger+$measurement is the same as measuring in the $y$-axis. A visual representation can be found in this answer: https://quantumcomputing.stackexchange.com/a/13611/15775

If you need to do a measurement in any other basis you can use rotation gates $R_y(\theta),R_z(\theta)+$measurement (two rotation gates are enough to do all kind of rotations).

To prepare an arbitrary state, you can use .initialize. Alternatively, you can also use the rotation gates.

The details of the gate operations and arbitrary initialization in Qiskit can be found here: https://qiskit.org/documentation/tutorials/circuits/3_summary_of_quantum_operations.html

$\endgroup$

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.