public void Verify_Entangled_Photons_Maintain_Entanglment() { Photon one = new Photon(); Photon two = new Photon(); int count_same = 0; int count_all = 0; // measure two entangled photons at 0 degrees. for (int i = 0; i < num_trials; ++i) { one.Randomize(); two.EntanglePolarization(one); // measure two entangled photons at 0 degrees, lots of times. for (int j = 0; j < 100; ++j) { ++count_all; if (one.Polarized(0 * sixty) == two.Polarized(0 * sixty)) { ++count_same; } } } // measure two entangled photons at 60 degrees. for (int i = 0; i < num_trials; ++i) { one.Randomize(); two.EntanglePolarization(one); // measure two entangled photons at 60 degrees, lots of times. for (int j = 0; j < 100; ++j) { ++count_all; if (one.Polarized(1 * sixty) == two.Polarized(1 * sixty)) { ++count_same; } } } // measure two entangled photons at 120 degrees. for (int i = 0; i < num_trials; ++i) { one.Randomize(); two.EntanglePolarization(one); // measure two entangled photons at 120 degrees, lots of times. for (int j = 0; j < 100; ++j) { ++count_all; if (one.Polarized(2 * sixty) == two.Polarized(2 * sixty)) { ++count_same; } } } Assert.True(count_same == count_all, "Must always be correlated."); }
public void Verify_Entangled_Photons_Decohere() { Photon one = new Photon(); Photon two = new Photon(); int count_same = 0; int count_all = 0; // measure two entangled photons at 120 degrees, then test at 0 degrees. for (int i = 0; i < num_trials; ++i) { one.Randomize(); two.EntanglePolarization(one); ++count_all; bool measure_once = one.Polarized(2 * sixty); // measuring at 120 randomized 0 if (one.Polarized(0 * sixty) == two.Polarized(0 * sixty)) { ++count_same; } } // measure two entangled photons at 0 degrees, then test at 60 degrees. for (int i = 0; i < num_trials; ++i) { one.Randomize(); two.EntanglePolarization(one); ++count_all; bool measure_once = one.Polarized(0 * sixty); // measuring at 0 randomized 60 if (one.Polarized(1 * sixty) == two.Polarized(1 * sixty)) { ++count_same; } } // measure two entangled photons at 60 degrees, then test at 120 degrees. for (int i = 0; i < num_trials; ++i) { one.Randomize(); two.EntanglePolarization(one); ++count_all; bool measure_once = one.Polarized(1 * sixty); // measuring at 60 randomized 120 if (one.Polarized(2 * sixty) == two.Polarized(2 * sixty)) { ++count_same; } } Assert.False(count_same == count_all, "Must not always be correlated."); }
/// <summary> /// Tests photons on two axes looking for specific goals. /// Generates the counts of that axis meeting that goal. /// </summary> /// <param name="A"> The angle Alice want to measure against. </param> /// <param name="goalA"> This is <c>true</a> if Alice is looking for successful test /// on this polarization angle. A <false> if Alice is looking for a failure on /// this polarization angle. </param> /// <param name="countA"> This <c>out</c> variable is set to the number of tests that /// matched Alice's goal. </param> /// <param name="B"> The angle Bob want to measure against. </param> /// <param name="goalB"> This is <c>true</a> if Bob is looking for successful test /// on this polarization angle. A <false> if Bob is looking for a failure on /// this polarization angle. </param> /// <param name="countB"> This <c>out</c> variable is set to the number of tests that /// matched Bob's goal. </param> /// <param name="count"> The optional number of trials to run, /// defaults to the <see cref="num_trials"/> constant. </param> public static void CountPhotonsSeparatelyOnAxes(double A, bool goalA, out double countA, double B, bool goalB, out double countB, int count = num_trials) { Photon one = new Photon(); Photon two = new Photon(); countA = 0; countB = 0; for (int i = 0; i < count; ++i) { one.Randomize(); two.EntanglePolarization(one); // just count how many times each goal is met. // no calculations involving both Alice and Bob. // if (one.Polarized(A) == goalA) { countA += 1; } if (two.Polarized(B) == goalB) { countB += 1; } } }
/// <summary> Runs trials testing at the specified angles, /// counting the various results and then calculating the probability /// of sameness between those two angles. </summary> /// <param name="A"> The angle that Alice want to test against. </param> /// <param name="B"> The angle that Bob want to test against. </param> /// <param name="count"> The optional number of tests to run. /// Defaults to the <see cref="num_trials"/> constant. </param> /// <returns> The probability of photon alignment being the same when /// measured at these two angles. </summary> public static double PhotonsPerSameOnAxes(double A, double B, int count = num_trials) { Photon one = new Photon(); Photon two = new Photon(); double count_same = 0.0; double count_all = 0.0; for (int i = 0; i < count; ++i) { one.Randomize(); two.EntanglePolarization(one); bool isA = one.Polarized(A); bool isB = two.Polarized(B); count_all += 1.0; if (isA == isB) { count_same += 1.0; } } return(count_same / count_all); }
/// <summary> /// Run the three axes Bell Inequality Test against Polarized Photons. /// </summary> /// <remarks> /// See https://en.wikiversity.org/wiki/Bell%27s_theorem /// </remarks> internal static void BellTriAxisPhotonPolarizationTest() { // 30 degress, in radians, is convenient to calculate the three angles. // double thirty = 30.0 / (180.0 / Math.PI); double[] filters = { 2 * thirty, // === 60 == 240 3 * thirty, // === 90 == 270 4 * thirty // === 120 == 300 }; // every test works with two photons. Photon one = new Photon(); Photon two = new Photon(); // various counts of the tests that pass the alignment filter. int count_A = 0; int count_B = 0; int count_AB = 0; // as in both int count_all = 0; // as in all tests run. for (int i = 0; i < 1000; ++i) { // force them to pick different filters // 0 + 1, 1 + 2, 2 + 0 double Alice = filters[(i + 0) % 3]; double Bob = filters[(i + 1) % 3]; // each test starts with a randomized particle one.Randomize(); // and a particle in _perfect_ entanglement with it. two.EntanglePolarization(one); bool answer_A = one.Polarized(Alice); bool answer_B = two.Polarized(Bob); count_all++; count_AB += (answer_A && answer_B)?1:0; count_A += (answer_A)?1:0; count_B += (answer_B)?1:0; } double percent_A = ((count_A * 100.0) / (count_all + 0.0)); double percent_B = ((count_B * 100.0) / (count_all + 0.0)); double percent_AB = ((count_AB * 100.0) / (count_all + 0.0)); bool spooky = (percent_AB < 33.33) && (percent_AB >= 25.00); Console.WriteLine(String.Format("{0} of {1} Agreement, for {2}% == {3}", count_AB, count_all, percent_AB, spooky ? "Spooky" : "Classic")); Console.WriteLine(">=33.333 suggests classic hidden variables."); Console.WriteLine("<33.333 >=25.000 suggests spooky action at a distance."); }
/// <summary> Runs trials testing at the specified angles, /// counting the various results and then calculating the correltion /// between those two angles. </summary> /// <param name="A"> The angle that Alice want to test against. </param> /// <param name="B"> The angle that Bob want to test against. </param> /// <param name="count"> The optional number of tests to run. /// Defaults to the <see cref="num_trials"/> constant. </param> /// <returns> The correlation of photon slignment between these two angles. </summary> public static double CorrelatePhotonsTheHardWay(double A, double B, int count = num_trials) { Photon one = new Photon(); Photon two = new Photon(); double count_PP = 0.0; double count_PM = 0.0; double count_MP = 0.0; double count_MM = 0.0; double count_all = 0.0; for (int i = 0; i < count; ++i) { one.Randomize(); two.EntanglePolarization(one); bool isA = one.Polarized(A); bool isB = two.Polarized(B); count_all += 1.0; if (isA && isB) { count_PP += 1; } if (isA && !isB) { count_PM += 1; } if (!isA && isB) { count_MP += 1; } if (!isA && !isB) { count_MM += 1; } } return(Math.Abs(count_PP + count_PM) - Math.Abs(count_MP - count_MM)); }
/// <summary> /// Tests photons on two axes looking for specific goals. /// Generates the counts of that axis meeting that goal. /// </summary> /// <param name="A"> The angle Alice want to measure against. </param> /// <param name="goalA"> This is <c>true</a> if Alice is looking for successful test /// on this polarization angle. A <false> if Alice is looking for a failure on /// this polarization angle. </param> /// <param name="B"> The angle Bob want to measure against. </param> /// <param name="goalB"> This is <c>true</a> if Bob is looking for successful test /// on this polarization angle. A <false> if Bob is looking for a failure on /// this polarization angle. </param> /// <param name="countHits"> This <c>out</c> variable is set to the number of tests that /// matched both Alice's and Bob's goals. </param> /// <param name="count"> The optional number of trials to run, /// defaults to the <see cref="num_trials"/> constant. </param> public static void CountPhotonsTogetherOnAxes(double A, bool goalA, double B, bool goalB, out double countHits, int count = num_trials) { Photon one = new Photon(); Photon two = new Photon(); countHits = 0; for (int i = 0; i < count; ++i) { one.Randomize(); two.EntanglePolarization(one); // here we count only when both goals are met. // if ((one.Polarized(A) == goalA) && (two.Polarized(B) == goalB)) { countHits += 1; } } }
/// <summary> Runs trials testing at the specified angles, /// counting the various results and then calculating the correltion /// between those two angles. </summary> /// <param name="A"> The angle that Alice want to test against. </param> /// <param name="B"> The angle that Bob want to test against. </param> /// <param name="count"> The optional number of tests to run. /// Defaults to the <see cref="num_trials"/> constant. </param> /// <returns> The correlation of photon alignment between these two angles. </summary> public static double CorrelatePhotonsOnAxes(double A, double B, int count = num_trials) { Photon one = new Photon(); Photon two = new Photon(); double count_same = 0.0; double count_diff = 0.0; double count_all = 0.0; for (int i = 0; i < count; ++i) { one.Randomize(); two.EntanglePolarization(one); bool isA = one.Polarized(A); bool isB = two.Polarized(B); count_all += 1.0; if (isA == isB) { count_same += 1.0; } else { count_diff += 1.0; } } // sadly, I forget where I saw this equation for calculating the correlation. // usually it is more like: // // C = (num_pp + num_mm - num_pm - num_mp) / (num_pp + num_mm + num_pm + num_mp) // // but this is arithmetically equivalent. ( when strictly using real numbers. ) // return((count_same - count_diff) / count_all); }
/// <summary> /// Run the CHSH Bell Inequality Test against Polarized Photons. /// </summary> /// <remarks> /// </remarks> internal static void BellChshPhotonTest() { // just a convenient angle to get all others from. double fortyfive = 45.0 / (180.0 / Math.PI); double[] filters_A = { 0 * fortyfive, // === 0 1 * fortyfive // === 45 }; double[] filters_B = { 0.5 * fortyfive, // === 22.5 1.5 * fortyfive // === 67.5 }; // track counts baed on which pair of angles are used. tracks[] E = new tracks[4] { new tracks(), new tracks(), new tracks(), new tracks() }; // our two photons. Photon one = new Photon(); Photon two = new Photon(); // and various individual counts regardless of test angle. int count_A_y = 0; int count_A_n = 0; int count_B_y = 0; int count_B_n = 0; int count_all = 0; for (int i = 0; i < 1000; ++i) { // let Alice nad Bob pick random filter angles from their lists. int index_A = RandomIndex(2); int index_B = RandomIndex(2); // and calculat teh track number of this choice. int index_T = index_A * 2 + index_B; double A = filters_A[index_A]; double B = filters_B[index_B]; // each test has a randomized particle one.Randomize(); // and a perfectly entangled particle two.EntanglePolarization(one); bool answer_A = one.Polarized(A); bool answer_B = two.Polarized(B); // now count up the results in their various tracks. if (answer_A) { count_A_y++; } else { count_A_n++; } if (answer_B) { count_B_y++; } else { count_B_n++; } if (answer_A && answer_B) { E[index_T].yy++; } if (answer_A && !answer_B) { E[index_T].yn++; } if (!answer_A && answer_B) { E[index_T].ny++; } if (!answer_A && !answer_B) { E[index_T].nn++; } count_all++; } // And sum the correlations of each track. double S = E[0].Value() - E[1].Value() + E[2].Value() + E[3].Value(); Console.WriteLine(String.Format("CHSH of {0} == {1}", S, (S > 2.0) ? "Spooky" : "Classic")); Console.WriteLine("<=2.0 suggests classic hidden variables."); Console.WriteLine("> 2.0 suggests spooky action at a distance."); }