# How can I measure a qubit on a generic axis on Qiskit?

I'm trying to prove Bell's inequality by following the one made by Wigner, that is:

$$P(+_a,+_b) \le P(+_a,+_c) + P(+_c,+_b)$$

And that this proof is NOT satisfied for angles between the various axes $$\hat a$$, $$\hat b$$ and $$\hat c$$. In particular I have chosen the coplanar axes (plane x-y) and that the $$\hat c$$ axis is the bisector of $$\hat a$$ and $$\hat b$$.

So I'm in the situation in the picture Graph

My idea is to take the singlet state (represented in this case by a specific state of the Bell state) and measure one qubit on one axis ($$\hat a$$, $$\hat b$$, $$\hat c$$) and the other qubit on one of the remaining axes in in such a way as to make all possible combinations.

In the specific situation represented in the graph, the angle that I can choose between the various axes must be a value between $$0$$ and $$\frac \pi2$$.

Now I come to my question: my doubt is whether it is correct how to interpret the measurement phase after I have created the singlet state (entagled state).

The entangled state I create it like this:

circ = QuantumCircuit(2,2)
circ.x(0)
circ.x(1)

circ.h(0)
circ.cx(0,1)


Referring to the graph I put earlier, if I wanted to now measure a long qubit $$\hat a$$ and a long $$\hat b$$ I would have to measure along x (no rotation for the first case) and rotate the second theta qubit around z and then measure along x, correct?

I thought about doing it this way

# Long a-axis for qubit 1
circ.h(0)

# Long b-axis for qubit 2
circ.rz(pi/3, 1)
circ.h(1)

circ.measure(range(2),range(2))


I wonder if these steps are correct or I forgot something or I can do it in another way. Because if I measured directly without applying the Hadamard operator before the measurement I would make a measurement along the z-axis I suppose, right?

I hope I was clear enough and that we can resolve my doubts! Thank you for your time!

• Here is a method to measure a single qubit in an arbitrary basis: quantumcomputing.stackexchange.com/questions/13124/… Dec 14 '20 at 13:02
• @MarcoGobbo Welcome to QCSE. You might find Section 3 of this paper helpful, which lays out a general method for testing Bell's inequality with Qiskit. Dec 14 '20 at 16:33
• Thank you guys! If I want to make it more generic? Can I use UGate with the 3 Euler angles instead of R_z? Instead of H-gate (x-basis), what can I use if I want to define an arbitrary axis other than x, y or z? I understand mathematically what keisure.akira sent, but I don't know how to implement this. Dec 16 '20 at 9:10