After several iterations of

  1. Read the next chapter of IBM Quantum Experience User Guide
  2. Research & Learn the theory mentioned in chapter just read
  3. Run the examples provided at the end of chapter
  4. Go to 1.

I found myself at brinks of trying Something Really Useful on IBM 5Q. A Bell’s Theorem example proof.

What is the Bell’s Theorem? Well, check the article on Wikipedia for the really scientific explanation. I’ll try to put it in the simplest way possible.

Bell’s Theorem says that quantum entanglement of two subatomic particles (or qubits for that matter) is actually the “spooky action at a distance”, and that it doesn’t involve any preset setting of the particles before measurement. It defies the opinion stated in EPR Paradox that quantum entanglement basically does not exist, and that “entangled” particles had actually already been in some definite preset states before their physical separation, and that the subsequent measurement only displays those states.

Quantum mechanics says that the particles are only behaving as a part of the same wave function, and that they get their definite states only when we measure them (that’s what the quantum physicists call the wave function collapse). At the moment of measurement, particles exhibit the interdependent behavior caused by entanglement, no matter the distance between them. It seems, if we could rely on classic physics here, that they exchange information faster than light, and this caused Einstein’s dissatisfaction with the quantum theory in the first place, as stated in the EPR paper from 1935.

Some thirty years later (in 1964.) John Stewart Bell presented his Bell’s Theorem, basically stating that the probabilities of measuring the same state for entangled particles should differ for classic physics vs quantum physics explanations of the phenomenon. It turned out that the experiments are more in line with the quantum mechanics.

IBM Quantum Experience User Guide gives you the opportunity to test the Bell’s theorem, thus checking if the quantum mechanics is a valid theory! How do you get to be more cool than this?

So, there is a proof of Bell’s theorem called the CHSH inequality. On IBM Quantum Experience User Guide, there is a chapter dedicated to this proof, together with sample quantum programs which you can use to check the inequality – read the chapter. Basically, you run four quantum programs operating on two entangled qubits, and check the results. You should get some probabilities for 4 possible results -(00, 01, 10, and 11), and calculate the result <AB> so that <AB>=P(00)+P(11)-P(01)-P(10). Sum C of absolute values of 4 <AB>s should be <= 2 if there are local hidden variables and the classic physics is right, and it should be 2*sqrt(2) if quantum physics is right. This is the CHSH put simply, and it reflects the Bell’s Theorem notion that measurement probabilities should differ for two possible explanations.

The IBM guys got their results as follows in the example. They ran the programs for 8192 shots each.

belltest 8192 example

For this purpose, 2.56 is pretty close to 2.828427 as predicted by theory – at least much closer than 2.56 is to <=2. ZW, ZV, XW and XV are measurements for different settings as required by CHSH inequality.

I didn’t want to spend too much of my precioussssss credits, so I ran the examples for 1024 times each, thus spending 3 credits per program instead of 5 (4×5=20, 4×3=12, so I saved myself 8 credits!). Here are my results:

IBM Q5
1024 shots
P(00) P(01) P(10) P(11) <AB>
ZW 0.413086 0.086914 0.110352 0.389648 0.605469
ZV 0.389648 0.104492 0.073242 0.432617 0.644531
XW 0.470703 0.09082 0.082031 0.356445 0.654297
XV 0.12207 0.43457 0.366211 0.077148 -0.60156
C 2.505859
Cexp 2.828427
Diff 0.322568

So 2.505859 for 1024 shots is not as good as the result for 8192 shots, but it still proves that quantum theory stands its ground! As cool as 5Q!

For the record, this is what we get when we run the programs on the ideal quantum computer simulator:

Simulator ideal settings
P(00) P(01) P(10) P(11) <AB>
ZW 0.427 0.073 0.073 0.427 0.708
ZV 0.427 0.073 0.073 0.427 0.708
XW 0.427 0.073 0.073 0.427 0.708
XV 0.073 0.427 0.427 0.073 -0.708
C 2.832

Allow me to comment on the XKCD image, for people not familiar with quantum theory. There is really no faster-than-light exchange of information between two entangled particles, at least not in the way we can use for communication of any kind. That simply seems to be the way the world works.

Proving Bell’s Theorem is really not for the news – it has been proven decades ago. But what we are proving here is that the IBM 5Q is the real quantum computer and that it works as expected. New era has begun indeed.