Quantum Entanglement is a superposition of two or more particles. This is a quantum state which has a special subset of all measurements of a particle. It is a correlated measurement outcome of two or more particles. Quantum entanglement happens when multiple particles generated together or closely interacted. The particle cannot be described independently and becomes part of a connected system. Measurement of one particle affects the other particle’s state.
Let us look at the implementation of deterministic entanglement.
The setup of the Microsoft Development Kit is discussed below.
Install Microsoft Development Kit from the link on Microsoft.com
- Install the .NET Core SDK 2.0 or later from the .NET downloads site.
- To download the latest templates for creating new Q# applications and libraries, execute dotnet new -i “Microsoft.Quantum.ProjectTemplates::0.3.1811.2802-preview”
- Pick the download for your platform from the Visual Studio Code website.
- Go to the Microsoft Quantum Development Kit for Visual Studio Code extension on the Visual Studio Marketplace and Install.
The Driver source code will be used to invoke the State Test.
using System; using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators; namespace FirstQuantum { class Driver { static void Main(string[] args) { using (var qsim = new QuantumSimulator(randomNumberGeneratorSeed: 31)) { Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var res = DeterministicTest.Run(qsim, 1000, initial).Result; var (numZeros, numOnes,agree) = res; System.Console.WriteLine( $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree,-4}"); } } } } }
The PerformXGate operation and operation DeterministicTest’s code is shown below.
namespace DeterministicTest { open Microsoft.Quantum.Canon; open Microsoft.Quantum.Primitive; operation PerformXGate (desired: Result, q1: Qubit) : Unit { let current = M(q1); if (desired != current) { X(q1); } }
operation DeterministicTest (count : Int, initial: Result) : (Int, Int) { mutable numOnes = 0; using (qubit = Qubit()) { for (test in 1..count) { PerformXGate (initial, qubit); H(qubit); let res = M (qubit); if (res == One) { set numOnes = numOnes + 1; } } Set(Zero, qubit); } return (count-numOnes, numOnes); } }
In the deterministic test, the number of times zero and one values come in the run of 1000 times are printed. Qubit is halfway between 0 and 1 as presented in the output below.
Init:Zero 0s=512 1s=488 agree=1000 Init:One 0s=503 1s=497 agree=1000