Bell Inequality (CHSH) Calculator
Choose four measurement angles, simulate an entangled pair and see whether the CHSH value beats the classical limit of 2. At the best angles it reaches 2.828 — the reason no local hidden-variable theory can explain quantum mechanics.
Choose the four measurement angles
Correlation against detector angle
Show the Larzscript program that just ran
Run a calculation to see the exact program.
This is the real program the page sent to the Larzscript interpreter (compiled to WebAssembly) in your browser. The library it imports is the same code the automated tests check.
The CHSH game
Alice and Bob share an entangled pair of qubits in the state (|00⟩ + |11⟩)/√2. Each picks one of two measurement directions in the x–z plane (Alice: a0 or a1, Bob: b0 or b1) and reads a ±1 result. Let E(a, b) be the average of the product of their results. The CHSH quantity is
If the results were fixed in advance by hidden information carried by each particle, every product would be ±1 and |S| could never exceed 2 — you can check by brute force over the 16 possible assignments. Quantum mechanics predicts E(a, b) = cos(a − b) for this state, and at the best angles S reaches 2√2.
Worked example, computed above
With the angles 0°, 90°, 45°, −45° the four correlations, obtained by measuring the simulated two-qubit state (not by using the cosine formula), are 0.7071067812, 0.7071067812, 0.7071067812 and -0.7071067812, so S = 2.8284271247. That exceeds the classical limit of 2 and matches Tsirelson's bound 2√2 = 2.8284271247. With every detector set to the same angle S = 2.0000000000: no violation.
What is verified
The library computes each correlation as a combination of Pauli-string expectation values of the simulated state, and its tests check that this equals cos(a − b), that S = 2√2 to 14 digits at the optimal angles, that no classical strategy exceeds 2, and that a null choice gives no violation.
Limits: this is the ideal two-qubit prediction. Real experiments must close loopholes (detector efficiency, communication between stations) and deal with noise, so measured values are lower than 2√2 but, in the best experiments, still significantly above 2.
Frequently asked questions
What is Bell's theorem?
John Bell proved in 1964 that no theory in which measurement outcomes are fixed in advance by local hidden variables can reproduce all the predictions of quantum mechanics. The CHSH form (Clauser, Horne, Shimony and Holt, 1969) turns that into a single number S: any local hidden-variable theory has |S| ≤ 2, while quantum mechanics predicts up to 2√2 ≈ 2.828.
Has the Bell inequality been violated in real experiments?
Yes, repeatedly, from Aspect's experiments in the early 1980s to 'loophole-free' tests in 2015 and later. The 2022 Nobel Prize in Physics went to Alain Aspect, John Clauser and Anton Zeilinger for their experiments with entangled photons that established the violation of Bell inequalities.
Does entanglement send signals faster than light?
No. Each side's results, looked at alone, are perfectly random. The correlations only appear when the two lists of results are compared, which requires ordinary communication. Bell's theorem rules out local hidden variables, but relativity's ban on faster-than-light signalling stands.
Why is the maximum 2√2?
That is Tsirelson's bound: the largest value quantum mechanics allows for the CHSH quantity. It arises for a maximally entangled pair and measurement directions 45° apart, and this page reproduces it as 2.828427… from an actual simulation of the two qubits.
What is the dashed line in the plot?
The correlation predicted by one simple, well-known local hidden-variable model, 1 − 2θ/180° for a measurement angle θ between the two detectors. It agrees with quantum mechanics at 0°, 90° and 180° but lies below the cosine curve in between — the gap is what an experiment can detect.
Every number on this page is computed by the open-source larzscript-cosmos library (qalgo, quantum, physmath), written in Larzscript, and checked against independent references in its test suite. How it is verified →