📜 ⬆️ ⬇️

Modeling Quantum Entanglement on C #

As the topic of quantum entanglement pops up more and more, I wanted to delve a little. Judging by the comments on the articles on quantum entanglement, this information will not be useful to me alone. Well, taking into account the fact that for most of us, the program code is much more convenient than any allegories - it was decided to present my understanding in the form of code.

This article expands another author 's article “Quantum entanglement for dummies” (I recommend reading, it helped me a lot). In his article, indomit gave an example of a program that clearly demonstrates the problem of the theory of hidden parameters, but could not give an example of code for particles in a superposition. In this article, we will try to simulate 2 cases:

  1. As if entangled particles behaved under determinism, when the state of particles is established before measurement, we simply cannot measure it without introducing distortions (that is the theory of hidden parameters). We get the numbers and see the discrepancy with the practice.
  2. We write a model of entangled particles in superposition (the state of the particles is not determined before the measurement). Let's try to assume how the particle is programmed inside, that is, we fit its code to the data that were obtained experimentally.

The article is based on a popular explanation of the quantum entanglement phenomenon from Mermin:

Mermin Paradox Explained
For the popular paradox report, D. Mermin proposes to construct a simple device [23]. The device should consist of a particle emitter and two detectors. Two identical particles are emitted to each of them. Catching a particle, the detector gives a binary response (0 or 1), depending on the particle and its three-position setting switch. Detection of a pair of particles should give the same answers:
')
  1. Whenever the detectors are configured equally.
  2. According to statistics in half the cases when they are configured randomly.

The first property requires that all detectors use the same coding switch position ∈ {1,2,3} ↦ response ∈ {0,1}, without any element of randomness. That is, they should agree in advance which of the responses, 0 or 1, should be given to the switch position, choosing one of eight possible functions for each particle, 000, 001, 010, 011, 100, 101, 110 and 111. Choosing 000 or 111 will result to 100% coincidence of the detectors, regardless of the position of the knob. If the detectors implement one of the six remaining functions, one of the numbers is pulled out by a randomly configured switch in 2/3 cases, the other with a probability of 1/3. The probability of coincidence of two answers at the same time will be (⅔) ² + (⅓) ² = 5/9. So whatever the algorithm of the automaton, the correlation inevitably exceeds 50%, breaking the second requirement.

But since such a machine can still be built (for example, with the position of polarizers at 120 °, as in Bohm’s experience), there can be no determinism (parameters) even in latent form. Instead, correlation responses are maintained by transferring information from one “measured” particle to another faster than the second measurement occurs.

Taken from here .

Unfortunately, I do not do physics either professionally or even at the level of an amateur; I do not pretend to infallibility. The main goal of the article is to demonstrate how to make a model that is understandable to those familiar with programming. If someone works professionally in this field, then instead of reproaching - try to write more accurate interaction models based on my article.

[Update] Explanation of the description of Mermin


Although several months have passed since the article was written and no one will return to it, I decided to clarify to calm my conscience.

He went a little deeper and came to the conclusion that the description according to Mermin was greatly simplified and attempts to bind him to real physical experiments are meaningless .

Initially, I tried to link the article to a real experiment with circular polarization and I was mistaken about that. ARad tried to develop a binding to real physical experiments, wrote about the mistakes made, and even offered its own version of the code (which also does not correspond to any physical experiment).

In order for the article to have at least some sense, it was decided to remove all imaginary bindings to real physical experiments and simply clarify Mermin’s description in the code and make it more visual. Real experiments are more difficult and for their modeling it is necessary to spend much more time.

In the first version of the article, we assumed that in the first experiment (the position of the sensors coincides) the particles give a mirror result, but in the original description by Mermin the measurement result with the same position of the sensors always coincides. This is fixed .

Additionally, I will add the “explanation to the explanation” of this Mermin himself, since it is not unequivocally written:

That is, they must agree in advance on which of the responses, 0 or 1, to give to the switch position, choosing for each particle one of the eight possible functions, 000, 001, 010, 011, 100, 101, 110 and 111.

The phrase “eight possible functions” is not straightforward. It is a question of eight possible variants of potential impact of particles on the sensor. There are three sensor positions (see full description above). If we consider that the state of two particles coincides and is set in advance, then we can determine in advance which response (0 or 1) we will potentially receive for each of the three switch positions (although we can measure only one of the three options).

Selecting 000 or 111 will result in a 100% coincidence of the readings of the detectors, regardless of the position of the adjustment knob.

If the particles can take the value at which potentially get the response "1" at any position of the switch (as well as 0, at any position of the switch) - then the second experiment in these cases will give 100% matches. To approach 50% these options can be excluded.

If the detectors implement one of the six remaining functions, one of the numbers is pulled out by a randomly configured switch in 2/3 cases, the other with a probability of 1/3.

It means that in each of 6 triples (001, 010, 011, 100, 101, 110) - only two of the three digits match (in the first version, two of the three are “0”, and one of the three is “1” ).

To estimate the probability we will create a table for the first case 001 :

Sensor position 1Sensor position 2Will the measurements match
oneone+
one2+
one3-
2one+
22+
23-
3one-
32-
33+

It is seen that in five cases out of nine measurements will coincide. The same probability will be for each of these six options (after all, in each of them two numbers are the same).

Measurements


In each of the models (both in deterministic and superpositional), we will carry out two experiments with entangled particles, corresponding to the first and second conditions according to Mermin:

  1. First set both sensors to the same position. In this case, we will get 100% identical results (if the first photon passes through the polarizer, then the associated one also passes through the polarizer at the same angle).
  2. Then we will set the position of the sensors randomly.

Here is the code for the first experiment:

var totalAttempts = 10000; //   var coincidenceCount = 0; //    for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++) { var entanglementParticles = new EntanglementParticles(); //     var position = GetRandomInteger(1, 3); //        //            int firstSensorPosition = position; int secondSensorPosition = position; bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition); //         bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition); //         if (firstValue == secondValue) //     coincidenceCount ++; } Console.WriteLine(" №1: {0}%  ", (decimal)coincidenceCount / totalAttempts * 100); //   

Here is the code for the second experiment:

 var totalAttempts = 10000; //   var coincidenceCount = 0; //    for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++) { var entanglementParticles = new EntanglementParticles(); //     int firstSensorPosition = GetRandomInteger(1, 3); //      1 int secondSensorPosition = GetRandomInteger(1, 3); //      2 bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition); //         bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition); //         if (firstValue == secondValue) //     coincidenceCount ++; } Console.WriteLine(" №2: {0}%  ", (decimal)coincidenceCount / totalAttempts * 100); 

For all models of particles there will be the same tests, only the code of particles will differ for the deterministic and superposition models (more on this below).

Deterministic model


Attention! See UPDATE at the end of the article!

For those who want to immediately run the code, this can be done from the browser: dotnetfiddle.net/N5Xg18

So, according to Mermin's explanation, we have a quantum particle with 3 parameters:

 //   ( , ) public class Particle { private bool _measured = false; public bool A { get; private set; } //       1 public bool B { get; private set; } //       2 public bool C { get; private set; } //       3 public Particle(bool a, bool b, bool c) { A = a; B = b; C = c; } //         ( 3 ). public bool GetValue(int sensorPosition) { if (_measured) throw new InvalidOperationException("    !"); _measured = true; switch (sensorPosition) { case 1: return A; case 2: return B; case 3: return C; default: throw new ArgumentOutOfRangeException(); } } } 

Since the model is deterministic, all the parameters of the particle are initialized at the moment of its creation, that is, directly in the constructor. The only condition is that measurement is allowed only once!

Further. A pair of entangled particles:

 //    public class EntanglementParticles { public Particle First { get; private set; } //   public Particle Second { get; private set; } //   //     (   ,         ) public EntanglementParticles() { //         bool a; bool b; bool c; do { a = GetRandomBoolean(); //     1 b = GetRandomBoolean(); //     2 c = GetRandomBoolean(); ; //     3 } while (a == b && b == c); //   000  111 (    ,       ) First = new Particle(a, b, c); Second = new Particle(a, b, c); //       } } 


It can be seen that the values ​​of each of the particles are set at the time of creating a pair of entangled particles, and the parameters of the second particle correspond to the parameters of the first (without this we can not pass the first test). We use random numbers, but according to the model, the parameters depend on factors at the time of entanglement (as a result, roulette depends on a number of factors at the time of unwinding).

Full sample code:

C # code of deterministic model (fixed)
 using System; public class Program { private static readonly Random Random = new Random(); //   public class Particle { private bool _measured = false; public bool A { get; private set; } //       1 public bool B { get; private set; } //       2 public bool C { get; private set; } //       3 public Particle(bool a, bool b, bool c) { A = a; B = b; C = c; } //         ( 3 ). public bool GetValue(int sensorPosition) { if (_measured) throw new InvalidOperationException("    !"); _measured = true; switch (sensorPosition) { case 1: return A; case 2: return B; case 3: return C; default: throw new ArgumentOutOfRangeException(); } } } //    public class EntanglementParticles { public Particle First { get; private set; } //   public Particle Second { get; private set; } //   //     (   ,         ) public EntanglementParticles() { //         bool a; bool b; bool c; do { a = GetRandomBoolean(); //     1 b = GetRandomBoolean(); //     2 c = GetRandomBoolean();; //     3 } while (a == b && b == c); //   000  111 (   ,       ) First = new Particle(a, b, c); Second = new Particle(a, b, c); //       } } public static void Main(string[] args) { Experiment1(); Experiment2(); } private static void Experiment1() { var totalAttempts = 10000; //   var coincidenceCount = 0; //    for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++) { var entanglementParticles = new EntanglementParticles(); //     var position = GetRandomInteger(1, 3); //        //            int firstSensorPosition = position; int secondSensorPosition = position; bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition); //         bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition); //         if (firstValue == secondValue) //     coincidenceCount ++; } Console.WriteLine(" №1: {0}%  ", (decimal)coincidenceCount / totalAttempts * 100); //   } private static void Experiment2() { var totalAttempts = 10000; //   var coincidenceCount = 0; //    for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++) { var entanglementParticles = new EntanglementParticles(); //     int firstSensorPosition = GetRandomInteger(1, 3); //      1 int secondSensorPosition = GetRandomInteger(1, 3); //      2 bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition); //         bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition); //         if (firstValue == secondValue) //     coincidenceCount ++; } Console.WriteLine(" №2: {0}%  ", (decimal)coincidenceCount / totalAttempts * 100); } private static bool GetRandomBoolean() { return GetRandomInteger(0, 1) == 1; } private static int GetRandomInteger(int from, int to) { return Random.Next(from, to + 1); //          } } 


You can run from the browser (again link: dotnetfiddle.net/N5Xg18 ).

After launch, these are the results:

Experiment No. 1: 100% of the values ​​coincided
Experiment number 2: 55.6700% of the values ​​coincided

The first test passed, corresponds to what is happening in reality. But the second - does not match, because they should get 50%!

As a result, physicists were forced to come to the conclusion that the theory of hidden parameters is erroneous. And along with it, the principle of locality was refuted and even the principle of causality was shaken.

Superposition model


Immediately link to the code of the example, for those who like specifics (can be run in the browser): dotnetfiddle.net/Mb7JqU

In order to explain the results obtained during the experiments, it was necessary to use more complex models. In modern models, the state of the particle parameters before the measurement is not defined, and the entangled particles themselves have the ability to instantly (above the speed of light) influence the state of each other. This is how our model of an elementary particle now looks like:

 //   public class Particle { private Particle _superluminalChannel; //         . private int? _measuredPosition; public bool? A { get; private set; } //       1 public bool? B { get; private set; } //       2 public bool? C { get; private set; } //       3 internal void CreateSuperluminalChannelWith(Particle particle) { _superluminalChannel = particle; } //         ( 3 ). public bool GetValue(int sensorPosition) { if (null != _measuredPosition) throw new InvalidOperationException("    !"); _measuredPosition = sensorPosition; if (null != _superluminalChannel._measuredPosition) //        { var measuredValue = _superluminalChannel.GetNakedValue(); //         (    ),   ,     . if (sensorPosition == _superluminalChannel._measuredPosition) return measuredValue; if (GetRandomInteger(1, 4) == 1) return measuredValue; return !measuredValue; } //  .        ,       -  . //   ! var value = GetRandomBoolean(); SetValue(sensorPosition, value); return value; } private bool GetNakedValue() //           ,    . { if (null == _measuredPosition) throw new InvalidOperationException(); switch (_measuredPosition.Value) { case 1: return A.Value; case 2: return B.Value; case 3: return C.Value; default: throw new InvalidOperationException(); } } private void SetValue(int position, bool value) { switch (position) { case 1: A = value; break; case 2: B = value; break; case 3: C = value; break; default: throw new ArgumentOutOfRangeException(); } } } 

First, the parameters of the steel are Nullable (they may not matter) and we do not set them in the constructor. Secondly, the CreateSuperluminalChannelWith method appeared to set up a superluminal channel between particles, i.e. now one particle can receive a state of another instantaneously, regardless of the distance. Well and, most importantly, now the state of the particle is established only at the moment of measurement (call the GetValue method) and depends on whether another particle associated with it was measured.

The interior of the GetValue method is pure assumption. How a particle is arranged inside - nobody knows, but we know that it works exactly like this: 100% mismatch when measuring the same parameter and 50% mismatch when measuring parameters in a random order.

In my version of the code, the particle over the superluminal channel checks whether the measurement is made entangled with it and acts as follows:

  1. If the measured parameter of another particle is the same as what we are trying to measure, it gives the same value.
  2. If the parameter is different, then in 1/4 cases it gives the same value, and in 3/4 cases it gives the opposite value (since we get 50/50).

If the measurement was not made - the particle uses the true random to set its value, that is, there is a violation of the causal relationship (the value did not exist before the measurement and the measurement itself did not determine its value).

By the way! You can rewrite this function in a different way, but make the test results the same. Still, no one knows how the elementary particle is arranged and how it is achieved 50% for the second test.

A pair of entangled particles has become simpler, since at the moment of entanglement no values ​​are set (values ​​are not yet defined):

 //    public class EntanglementParticles { public Particle First { get; private set; } //   public Particle Second { get; private set; } //   //     (  ,   ) public EntanglementParticles() { First = new Particle(); //   ,    Second = new Particle(); //   ,    //         First.CreateSuperluminalChannelWith(Second); Second.CreateSuperluminalChannelWith(First); } } 

Full sample code:

Superposition Model on C #
 using System; public class Program { private static readonly Random Random = new Random(); //   public class Particle { private Particle _superluminalChannel; //         . private int? _measuredPosition; public bool? A { get; private set; } //       1 public bool? B { get; private set; } //       2 public bool? C { get; private set; } //       3 internal void CreateSuperluminalChannelWith(Particle particle) { _superluminalChannel = particle; } //         ( 3 ). public bool GetValue(int sensorPosition) { if (null != _measuredPosition) throw new InvalidOperationException("    !"); _measuredPosition = sensorPosition; if (null != _superluminalChannel._measuredPosition) //        { var measuredValue = _superluminalChannel.GetNakedValue(); //         (    ),   ,     . if (sensorPosition == _superluminalChannel._measuredPosition) return measuredValue; if (GetRandomInteger(1, 4) == 1) return measuredValue; return !measuredValue; } //  .        ,       -  . //   ! var value = GetRandomBoolean(); SetValue(sensorPosition, value); return value; } private bool GetNakedValue() //           ,    . { if (null == _measuredPosition) throw new InvalidOperationException(); switch (_measuredPosition.Value) { case 1: return A.Value; case 2: return B.Value; case 3: return C.Value; default: throw new InvalidOperationException(); } } private void SetValue(int position, bool value) { switch (position) { case 1: A = value; break; case 2: B = value; break; case 3: C = value; break; default: throw new ArgumentOutOfRangeException(); } } } //    public class EntanglementParticles { public Particle First { get; private set; } //   public Particle Second { get; private set; } //   //     (  ,   ) public EntanglementParticles() { First = new Particle(); //   ,    Second = new Particle(); //   ,    //         First.CreateSuperluminalChannelWith(Second); Second.CreateSuperluminalChannelWith(First); } } public static void Main(string[] args) { Experiment1(); Experiment2(); } private static void Experiment1() { var totalAttempts = 10000; //   var coincidenceCount = 0; //    for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++) { var entanglementParticles = new EntanglementParticles(); //     var position = GetRandomInteger(1, 3); //        //            int firstSensorPosition = position; int secondSensorPosition = position; bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition); //         bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition); //         if (firstValue == secondValue) //     coincidenceCount ++; } Console.WriteLine(" №1: {0}%  ", (decimal)coincidenceCount / totalAttempts * 100); //   } private static void Experiment2() { var totalAttempts = 10000; //   var coincidenceCount = 0; //    for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++) { var entanglementParticles = new EntanglementParticles(); //     int firstSensorPosition = GetRandomInteger(1, 3); //      1 int secondSensorPosition = GetRandomInteger(1, 3); //      2 bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition); //         bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition); //         if (firstValue == secondValue) //     coincidenceCount ++; } Console.WriteLine(" №2: {0}%  ", (decimal)coincidenceCount / totalAttempts * 100); } private static bool GetRandomBoolean() { return GetRandomInteger(0, 1) == 1; } private static int GetRandomInteger(int from, int to) { return Random.Next(from, to + 1); //          } } 


Results:

Experiment No. 1: 100% of the values ​​coincided
Experiment number 2: 49.7700% of the values ​​coincided

Run in browser: dotnetfiddle.net/Mb7JqU

findings


I would like more accessible interpretations, like those expressed by Mermin. Based on this interpretation, I managed to create visual models of existing theories and even put forward an alternative model and these models are not allegorical - you can run them and see how they work.

Unfortunately, I do not have temporary resources for a deeper knowledge of quantum physics and I hope that those in the know will be able to follow my example and lead more accurate working models.

UPDATE
In the explanation of Mermin nothing about the device detectors. I, on my own initiative, added an explanation to A, B and C as a projection of the spin on the X, Y and Z axes, respectively. That is, I wanted to add a link to physical phenomena in the comments to the code so that it would not be so dry. And in this I was mistaken ...

The article has been corrected and all vain attempts to link Mermin’s explanation to real physical experiments have been removed.

Source: https://habr.com/ru/post/420611/


All Articles