Skip to content

Quantum Entanglement with Classiq

View on GitHub

Entanglement is an important aspect to study the quantum algorithms. In this tutorial, we show how to create a bell pair state \(|\Phi^{+}\rangle\) of 2 qubits, using the Hadamard and the Controlled-NOT transformation.

from classiq import *


@qfunc
def my_bell_state(reg: QArray[QBit]) -> None:
    H(reg[0])
    CX(reg[0], reg[1])


@qfunc
def main(registers: Output[QArray[QBit]]) -> None:
    allocate(2, registers)
    my_bell_state(registers)


model = create_model(main)
write_qmod(model, "bell_state_of_2_qubits")


qprog = synthesize(model)

circuit = QuantumProgram.from_qprog(qprog)

circuit.show()
Opening: https://platform.classiq.io/circuit/5134159f-5b5d-4f36-9242-584b79303722?version=0.42.0

Mathematical Background

Alice has a qubit which is initially set to \(|0\rangle\)
Bob has a qubit which is initally set to \(|0\rangle\)

Alice applies 2x2 Hadamard Matrix (H) to create a superposition of her qubit's state. It is defined as:

\[H \cdot \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{pmatrix} \cdot \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix} = \frac{1}{\sqrt{2}} \left| 0 \right\rangle + \frac{1}{\sqrt{2}} \left| 1 \right\rangle\]

Alice and Bob combine their qubits and generate the composite quantum state as:

\[\begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix} \otimes \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ \frac{1}{\sqrt{2}} \\ 0 \end{pmatrix}\]

Alice now applies the Controlled NOT gate operation, with her qubit being the control qubit and Bob's qubit as the target qubit. The Controlled NOT qubit when applied only affects the target qubit by inverting its state if the control qubit is \(|1\rangle\). The 4x4 matrix for Controlled NOT(CNOT) transformation matrix is defined as:
\((\text{CNOT} = \begin{pmatrix} 1 & 0 & 0 & 0 \ 0 & 1 & 0 & 0 \ 0 & 0 & 0 & 1 \ 0 & 0 & 1 & 0 \end{pmatrix} (\(The new quantum state is:\)\) \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix} \begin{pmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ \frac{1}{\sqrt{2}}\\ 0 \end{pmatrix} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \end{pmatrix} = \frac{1}{\sqrt{2}} \left| 00 \right\rangle + \frac{1}{\sqrt{2}} \left| 11 \right\rangle\)\)

In this situation the qubit's of Alice and Bob are correlated to each other.
If we measure both the qubits we will either get the state \(|00\rangle\) or the state \(|11\rangle\) with equal probability.

It is described as:

  • When Alice observes her state as \(|0\rangle\) then the state of Bob's qubit collapses to the state \(|0\rangle\)

  • When Alice observes her state as \(|1\rangle\) then the state of Bob's qubit collapses to the state \(|1\rangle\)

The resultant entangled state is designated as a bell pair state \(|\Phi^{+}\rangle\)

\[|\Phi^{+}\rangle = \frac{1}{\sqrt{2}} \left( |00\rangle + |11\rangle \right)\]