2

**Note:** *Cross-posted on Physics SE.*

I made some circuit to prepare a 2 qubit state, but I am having trouble understanding how to measure Bell's inequality. I know the inequality is of the form

$$|E(a,b)-E(a,b')+E(a',b)+E(a',b')| \leq 2$$

where for each $E$

$$E = \frac{N_{++} + N_{--} - N_{-+} - N_{+-}}{N_{++} + N_{--} + N_{-+} + N_{+-}} $$

My problem is, what would the different $a,a',b,b'$ be? With this question, I don't mean what their values would be (since IBM Q just outputs $0$ or $1$ in the $01$ basis), but how do I implement this?

Can I just do $a,b$ in $01$ basis and $a',b'$ in $\pm$ basis? And if so, how do I proceed with this? Do I just apply a Hadamard gate before the measurement and take whatever $0$ or $1$ value it outputs?

Not sure if this is exactly what you are looking for, but here is an article explaining Bell inequality and incorporating it inside of IBMQ Composer.

https://github.com/Qiskit/ibmqx-user-guides/blob/master/rst/full-user-guide/003-Multiple_Qubits_Gates_and_Entangled_States/002-Entanglement_and_Bell_Tests.rst