Skip to content

Quantum entanglement simulation with Rust macros and a 2d tensor implementation

Notifications You must be signed in to change notification settings

felipetavares/q30m

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quantum Entanglement in 30 minutes

Following Quantum in 30 seconds, the next step in simulating quantum systems involves simulating entanglement.

Experiment

This experiment is quite simple. We first initialize a system of two qubits to an entangled state. That means we cannot describe this state from the individual states of qubits:

$$S = \frac{\lvert 00 \rangle}{\sqrt{2}} + \frac{\lvert 11 \rangle}{\sqrt{2}}$$

Then, we measure each qubit individually. Since this state is a superposition of either both qubits being 0 or both being 1, whenever one of them is measured, this forces the state of the other to match!

Implementation

To create a simulator capable of entanglement, there are a few operations that must be implemented:

  • 2d tensors
  • Kronecker product
  • Projectors

Those are needed for a couple important concepts:

(1) Generating a n-qubit state can be done by using the Kronecker product ($\otimes$) of n-qubits:

$$b_{1} \otimes b_{2} \otimes \ldots \otimes b_{n}$$

(2) The probability of a qubit being in a state, for example the first qubit in a two qubit state being $\lvert 0 \rangle$ can be calculated by:

$$\lVert \lvert 0 \rangle \langle 0 \rvert \otimes I_2 \times S \rVert^2$$

Where $I_2$ is a $2 \times 2$ identity tensor.

The projector in this case is the result of the ket-bra multiplication. The idea here is to build a n-gate operation out of the Kronecker product of identity tensors and the projector for the qubit we are interested in.

The state after the measurement can be described similarly:

$$\frac{\lvert 0 \rangle \langle 0 \rvert \otimes I_2 \times S}{\lVert\lvert 0 \rangle \langle 0 \rvert \otimes I_2 \times S\rVert}$$

Outcomes

cargo run --release
    Finished release [optimized] target(s) in 0.00s
     Running `target/release/q30m`
[src/main.rs:16] register.measure(0) = true
[src/main.rs:17] register.measure(1) = truecargo run --release
    Finished release [optimized] target(s) in 0.00s
     Running `target/release/q30m`
[src/main.rs:16] register.measure(0) = false
[src/main.rs:17] register.measure(1) = false

About

Quantum entanglement simulation with Rust macros and a 2d tensor implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages