Quantum mechanics and Encoding of Quantum Information#

Introduction#

How well can you see in the dark? How well does your GPS work? How do materials work? These questions are answered first and foremost by the rules of quantum mechanics. In this tutotial, we’ll start to get acquainted with some of these effects and with methods to predict them.

!pip install qutip > null
!pip install ipympl > null

from numpy import cos, sin, pi, exp
import numpy as np
^C
ERROR: Operation cancelled by user

Problem 1. Traveling Electromagnetic Waves#

In class, we discussed electromagnetic fields propagating in a direction $\mathbf{z}$ with electric and magnetic fields in the transverse ($x-y$) plane. We can describe any electric field vector in that plane by recording its projection onto two orthogonal basis vectors – such as the $\mathbf{x}$ and $\mathbf{y}$ unit vectors, which humans like to denote as the ‘horizontal’ (H) and ‘vertical’ (V) polarization vectors in their earth-centric reference frames.

Mathematically, we can describe a transverse electromagnetic field of arbitrary polarization as a sum of two modes (solutions to Maxwell’s equations) that are individually polarized in these directions – for example, $\vec{E}\propto E_x(\vec{r},t) \mathbf{x} + E_y(\vec{r},t) \mathbf{y}$, where in classical electromagnetism, $E_x(\vec{r},t),E_y(\vec{r},t)$ denote the field amplitudes at coordinates $\vec{r},t$. For example, a laser field could be approximated by $E_x(\vec{r},t)=E_{x,0} \cos(\omega t - k z + \phi_x)$ and $E_y(\vec{r},t)=E_{y,0} \cos(\omega t - k z + \phi_y)$, where $E_{x/y,0} \in \mathbb R $ is a ‘slowly varying envelope’. But if we turn down their amplitudes, measurements of these fields eventually show some unusual behavior, including the discreteness of optical energy – the `quantization’ of the EM field.

Thus, Maxwell’s equation describes the shape of a field; quantum mechanics describes a field’s excitation.

1.1 Number states#

We can express the instantaneous state of the transverse EM field, $|\psi\rangle $, by reference to the modes that constitute it, as well as their excitation. If we restrict ourselves to exactly one quantum (photon) of excitation between modes H and V, then we could write the state as $|\psi\rangle = \alpha |1_H 0_V\rangle + \beta |0_H 1_V\rangle $, where $|m_H n_V\rangle$ is the Dirac notation for $m$ photons in mode $H$ and $n$ photons in mode $V$, respectively, and $m,n\in \mathbb N $.

In the case of a single-photon excitation, it’s common to abbreviate the logical-qubit notation to $|V\rangle \equiv |0_H 1_V\rangle$ and $|H\rangle \equiv |1_H 0_V\rangle$ to write the state as $|\psi\rangle = \alpha |H\rangle + \beta |V\rangle $. Be careful what’s written in the bracket: it’s purely notation, no algebra.

  • Q: Given the constraints imposed by $|\langle \psi | \psi \rangle|=1$, how many degrees of freedom remain in $\alpha$ and $\beta$ to describe an arbitrary $ | \psi \rangle$ ?

####>

  • A: $\alpha$ and $\beta$ are complex amplitudes so we start with 4 degrees of freedom. The constraint $|\alpha|^2 + |\beta|^2 = 1$ leaves us with 3 degrees of freedom. However, as mentioned in class, the global phase can in this case be dropped, so in this problem 2 degrees of freedom would suffice to accurately describe the state evolution and measurements.

Let’s start to use qutip, the premier quantum mechanics package in python!

from qutip import basis, tensor
from numpy import cos, sin, pi, exp

# Let's start to use qutip, the premier quantum mechanics package in python

# Define basis states
ket_H = basis(2, 0)  # |1_H 0_V>
ket_V = basis(2, 1)  # |0_H 1_V>

# Define arbitrary α and β such that |α|^2 + |β|^2 = 1
α = cos(pi/4)  # Setting α as cos(pi/4)
β = sin(pi/4)   # Setting β as sin(pi/4)

# Construct the state |ψ>
ψ = α * tensor(ket_H, basis(2, 0)) + β * tensor(basis(2, 0), ket_V)  # Constructing the state |ψ>

# A: α and β are complex amplitudes so we start with 4 degrees of freedom.
# The constraint |α|^2 + |β|^2 = 1 leaves us with 3 degrees of freedom. However,
# as mentioned in class, the global phase can in this case be dropped, so in this problem
# 2 degrees of freedom would suffice to accurately describe the state evolution and measurements.
/usr/local/lib/python3.10/dist-packages/qutip/__init__.py:65: UserWarning: The new version of Cython, (>= 3.0.0) is not supported.
  warnings.warn(
# interactive plotting
import numpy as np
from ipywidgets import interactive
import ipywidgets as widgets
import matplotlib
import matplotlib.pyplot as plt
from google.colab import output
output.enable_custom_widget_manager()
from numpy import cos, sin, pi, exp

%matplotlib ipympl

from qutip import Bloch, basis

# Set the text font size to 8 pt
matplotlib.rcParams.update({'font.size': 10})  # Set the overall font size to 10 pt

# Initialize the Bloch sphere outside the function
b = Bloch()
b.fig = plt.figure(figsize=(3, 3))

# Customize Bloch sphere labels
b.xlabel = ['$|H+V⟩$', '$|H-V⟩$']
b.ylabel = ['$|H+iV⟩$', '$|H-iV⟩$']
b.zlabel = ['$|H⟩$', '$|V⟩$']

# Set the font size for the annotation
b.font_size = 8  # Set the font size to 8 pt

#def f(theta, phi, time=0):
def f(theta, phi):

    theta, phi = pi * theta / 180, pi * phi / 180  # Convert angles from degrees to radians

    # Define quantum states |0> and |1>
    ket0 = basis(2, 0)
    ket1 = basis(2, 1)

    # Create a quantum state on the Bloch sphere using theta and phi
    psi = cos(theta/2) * ket0 + exp(1j * phi) * sin(theta/2) * ket1
 #   psi2 = cos(theta/3) * ket0 + exp(1j * phi) * sin(theta/2) * ket1

    # Clear the previous states added to the Bloch sphere
    b.clear()

    # Add the new state to the Bloch sphere
    b.add_states(psi)
#    b.add_states(psi2)

    # Render the Bloch sphere on the existing figure
    b.render()
    plt.draw()

# Create interactive plot
interactive_plot = interactive(f,
                              theta=widgets.FloatSlider(value=45, min=0, max=180.0, step=10, description='Theta (deg)'),
                              phi=widgets.FloatSlider(value=45, min=0, max=360.0, step=10, description='Phi (deg)'),
                              #time=widgets.FloatSlider(value=0, min=0, max=6.28, step=0.1, description='Time'),
)
interactive_plot

1.2 Photon energy#

The `number states’ $|m_H n_V\rangle$ constitute a complete orthonormal basis for the transverse EM field considered here – i.e., we can express all EM states $|\phi\rangle$ with arbitrary tranverse polarization and field strengths as a sum over these basis states.

1.2.1 Estimate#
  • Q: For a wavelength of 1 $\lambda=\mu$m, calculate the energy $\hbar \omega$ of one quanta of excitation (1 photon) of the H or V mode, in electron volt (eV)? Here, $\omega$ is the angular frequency and $\hbar \equiv h/2\pi$.

# To calculate $\hbar \omega$ for a 1 µm wavelength, we can use the formula $\omega = \frac{2\pi c}{\lambda}$ and $\hbar = \frac{h}{2\pi}$, where $\lambda = 1,\mu\text{m}$. We can perform this calculation using QuTiP:

import numpy as np
from scipy.constants import h, c, micro

# Wavelength in meters
wavelength = 1.0 * micro  # 1 µm in meters

# Calculate angular frequency omega
omega = 2 * np.pi * c / wavelength

# Calculate photon energy in electron volts (eV)
hbar = h / (2 * np.pi)
photon_energy_ev = hbar * omega / 1.60218e-19  # Convert to eV

photon_energy_ev
1.2398393795634255

1.2.2 Photon energy compared to thermal energy#

  • Q: Assuming the EM modes are thermalized with the environment at $T=300$ K, how does the photon energy $\hbar \omega$ compare to $k_B T$? What’s the mean thermal occupation of this mode – i.,e, what’s the mean number of photons you’d measure over some time at frequency $\omega$?

To find the mean occupation, you can assume the Bose-Einstein distribution:

$$ \bar{n} = \frac{1}{e^{\frac{\hbar \omega}{k_B T}} - 1} $$

A: To compare $\hbar \omega$ to $k_B T$, where $k_B$ is the Boltzmann constant and $T$ is the temperature (in Kelvin), we can calculate both and compare their magnitudes. We can also calculate the probability of measuring a thermally excited photon. THis is very small:

from scipy.constants import Boltzmann , h
from scipy.special import expit

# Given wavelength in meters
wavelength = 1e-6  # 1 µm

# Calculate angular frequency (in rad/s) using c = 3e8 m/s
omega = 2 * np.pi * 3e8 / wavelength

# Photon energy in electron volts (eV)
photon_energy = omega * h/(2*np.pi)

# Temperature in Kelvin
T = 300  # 300 K

# Calculate thermal energy k_B * T
thermal_energy = Boltzmann * T

# Compare photon energy to thermal energy
print(photon_energy, thermal_energy / 1.60218e-19)  # Convert thermal energy to eV

# Calculate probability of measuring a thermally excited photon using expit
thermal_occupation = 1 / (np.exp(photon_energy /thermal_energy) - 1)

print(thermal_occupation)
1.987821045e-19 0.025851945474291278
1.4359924589903149e-21

1.2.3 Thermal occupation at microwave frequency#

Q: What if we considered instead microwaves at $\omega/2\pi = 3 $ GHz (near your kitchen microwave’s frequency) – what’s the thermal occupation of an electromagnetic mode? If you wanted to bring the probability of thermal photon excitation of your microwave cavity below 1%, to what temperature would you need to cool the temperature of the mode? Order of magnitude answer is fine.

A: To calculate the thermal occupation of an electromagnetic mode at $\omega/2\pi = 3$ GHz and determine the required temperature to achieve less than 1% thermal photon excitation, we can use QuTiP as follows:

# Microwave frequency in Hz
microwave_freq = 3e9  # 3 GHz in Hz

# Calculate angular frequency omega for microwaves
omega_microwave = 2 * np.pi * microwave_freq

# Calculate thermal occupation using Bose-Einstein distribution
thermal_occupation = 1 / (np.exp(hbar * omega_microwave / (Boltzmann * T)) - 1)

# Calculate temperature to achieve < 1% thermal occupation, in Kelvin
desired_occupation = 0.01  # 1% probability
required_temperature = hbar * omega_microwave / (Boltzmann * np.log(1 / (desired_occupation) + 1))

thermal_occupation, required_temperature
(2083.1619523267705, 0.031196865103650512)

1.3 Logical encoding#

Let’s use our modes to encode a qubit – i.e., a physical state that, when measured, yields one of two possible measurement outcomes (a `two-level system’).

  • Q: Define a set of orthonormal logical qubit states $|0\rangle_L$ and $|1\rangle_L$ in terms of the H and V polarizations. What would be a suitable measurement apparatus? (Sketch the apparatus, using linear optical components like beamsplitters and waveplates)

A: We can define the orthonormal logical qubit states as follows:

$|0\rangle_L = |H\rangle$

$|1\rangle_L = |V\rangle$

In this notation, $|0\rangle_L$ corresponds to a qubit in the horizontal polarization state, and $|1\rangle_L$ corresponds to a qubit in the vertical polarization state.

A suitable measurement apparatus for measuring these logical qubit states can involve linear optical components like beamsplitters and waveplates. To measure the logical qubit states, we can use a polarization beam splitter (PBS) and two single-photon detectors. Here’s a sketch of the measurement apparatus:

                  PBS
                  / \
                 /   \
           |0⟩_L/     \ |1⟩_L
               /       \
              /         \
        Detector 1    Detector 2

In this setup:

The PBS (Polarization Beam Splitter) splits the incoming photon based on its polarization. If the input photon is in the $|0\rangle_L$ state (horizontal polarization), it will pass through the upper path and be detected by Detector 1. If the input photon is in the $|1\rangle_L$ state (vertical polarization), it will be reflected down and be detected by Detector 2. This measurement scheme allows us to distinguish between the logical qubit states $|0\rangle_L$ and $|1\rangle_L$ based on their polarization. If the photon is in superposition, its state can be expressed as a linear combination of $|0\rangle_L$ and $|1\rangle_L$, and the measurement will project it onto one of these states based on its polarization.

This is a basic example of a quantum measurement apparatus for logical qubits encoded in polarization states.

1.4 Mutually unbiased bases#

  • Q: Can you think of an alternative qubit encoding that is `mutually unbiased’ to your choice above – i.e, the inner product defined as $|\langle \psi_A | \psi_B \rangle|^{2}=1/2$ for any two logical qubits drawn from basis $A$ and the other basis $B$?

Such mutually unbiased logical bases are commonly used in quantum key distribution (QKD) schemes among two trusted parties, A and B, to minimize information leakage to possible eavesdroppers. If the eavesdropper measures in a basis different from the sender, their measured signal would not correlate with the sender’s – and, conversely, the eavesdropper can minimize information leakage to the legitimate parties by measuring in a basis mutually unbiased to theirs.

Yes, another basis would be the Hadamard Basis:

|+⟩ = (|0⟩ + |1⟩) / √2 |-⟩ = (|0⟩ - |1⟩) / √2

.. or the Circular Basis:

|↻⟩ = (|0⟩ + i|1⟩) / √2 |↺⟩ = (|0⟩ - i|1⟩) / √2

1.5 Generalization#

The polarization encoding of the 1-photon qubit encoding is one example of a `two-mode’ or `dual-rail’ encoding on any two electromagnetic modes. For example, we could also encode the qubit on the forward- and backward-propagating modes, or we could encode the qubit on two spatially offset light fields.

An alternative logical encoding would be to use only one mode – let’s say field H – but to realize the two levels by the number state. I.e., we could choose $|0\rangle_L=|m_H=0\rangle$ and $|1\rangle_L=|m_H=1\rangle$. However, this `number-state’ qubit basis is almost never used.

  • Q: Why do people prefer the dual-rail encoding, and how does it relate to optical loss?

A: The dual-rail encoding is preferred for quantum communication due to its robustness against optical loss. When quantum information is encoded in two spatially separated modes, such as horizontal (H) and vertical (V) polarizations, optical loss in one of the modes does not result in complete information loss. The redundancy in the dual-rail encoding offers the following advantages:

Fault Tolerance: If one of the modes experiences optical loss or attenuation during transmission, the information can still be retrieved from the remaining mode. This redundancy makes the encoding more resilient against optical losses, which are common in practical quantum communication scenarios.

Error Detection and Correction: The redundancy allows for error detection and correction. By comparing the information stored in both modes, errors can be identified, and appropriate error correction techniques can be applied to recover the original quantum state.

Q: How many sets of mutually unbiased bases are there for single-photon polarization encoding in our logical qubit example?

A: For a quantum system with two mutually unbiased bases, there are a total of three such sets of bases. This is a general result for a qubit system.

In the context of qubits, the standard basis is typically denoted as {|0⟩, |1⟩}, which corresponds to the logical basis. The other two mutually unbiased bases can be defined in terms of different sets of basis states.

Here are the three sets of mutually unbiased bases for qubits:

Standard Basis (Logical Basis):

|0⟩ |1⟩ Hadamard Basis:

|+⟩ = (|0⟩ + |1⟩) / √2 |-⟩ = (|0⟩ - |1⟩) / √2 Circular Basis:

|↻⟩ = (|0⟩ + i|1⟩) / √2 |↺⟩ = (|0⟩ - i|1⟩) / √2 These bases are mutually unbiased because the inner product of any pair of basis states from different bases has a magnitude of 1/√2, satisfying the condition for mutual unbiasedness.

Comment: There’s a systematic construction that starts from the Lie algebra (group theory). Here, the following set of rotations forms a basis for the Lie algebra su(2), representing the group of unitary 2x2 matrices. The Pauli matrices, including X and Y, generate rotations in the Bloch sphere, allow us to transform between different bases.

Basis

Basis State

Construction

Hadamard Basis

|0⟩_H

H

|1⟩_H

HX

Circular Basis

|0⟩_C

S

(X-Basis)

|1⟩_C

SX

Standard Basis

|0⟩_Z

I

(Computational Basis)

|1⟩_Z

X

Let’s use Qutip to demonstrate these bases.

from qutip import *

# Define the basis states
ket_H = basis(2, 0)  # |H⟩
ket_V = basis(2, 1)  # |V⟩
ket_D1 = (ket_H + ket_V).unit()  # |D1⟩
ket_D2 = (ket_H - ket_V).unit()  # |D2⟩
ket_C1 = (ket_H + 1j * ket_V).unit()  # |C1⟩
ket_C2 = (ket_H - 1j * ket_V).unit()  # |C2⟩

# Check mutual unbiasedness
basis_sets = [
    ("Standard (Z) Basis", [ket_H, ket_V]),
    ("Diagonal (D) Basis", [ket_D1, ket_D2]),
    ("Circular (C) Basis", [ket_C1, ket_C2])
]

for basis_name, basis_states in basis_sets:
    print(f"{basis_name}:")
    for i, state1 in enumerate(basis_states):
        for j, state2 in enumerate(basis_states):
            if i != j:
                inner_product = abs(state1.overlap(state2)) ** 2
                print(f"|⟨{state1}|{state2}⟩|^2 = {inner_product:.2f}")
    print()


from qutip import Bloch, basis

# Create Bloch sphere instance
b = Bloch()

# Define basis states
ket_H = basis(2, 0)  # |H⟩
ket_V = basis(2, 1)  # |V⟩
ket_D1 = (ket_H + ket_V).unit()  # |D1⟩
ket_D2 = (ket_H - ket_V).unit()  # |D2⟩
ket_C1 = (ket_H + 1j * ket_V).unit()  # |C1⟩
ket_C2 = (ket_H - 1j * ket_V).unit()  # |C2⟩

# Add states to the Bloch sphere
b.add_states([ket_H, ket_V, ket_D1, ket_D2, ket_C1, ket_C2])

# Render the Bloch sphere
b.show()

Problem 2. Matrix algebra#

In the context of single-photon polarization encoding, consider the following notation for the basis states: $|H⟩$ represents the state $|1_H,0_V⟩$ $|V⟩$ represents the state $|0_H 1_V⟩$

Now, let’s examine an arbitrary state |ϕ⟩, which can be represented in the logical qubit basis as: $$|ϕ⟩ = ⟨H|ϕ⟩ |H⟩ + ⟨V|ϕ⟩ |V⟩$$

Here, $⟨H|ϕ⟩$ and $⟨V|ϕ⟩$ are the wavefunction values corresponding to the logical qubit states |H⟩ and |V⟩.

Suppose there exists a transformation from |ϕ⟩ to |ψ⟩, which is represented by a 2x2 matrix U: $$|\psi\rangle = U |\phi\rangle$$

Show that this transformation matrix U must be unitary. In other words, demonstrate that for the conjugate transpose U*, also known as the Hermitian adjoint U†, the following equality holds: $$U^\dagger U = U U^\dagger= I_2$$ Where $I_2$ is the 2x2 identity matrix.

A:

  1. Expand the expressions $\langle H|U^\dagger U|H\rangle$ and $\langle V|U^\dagger U|V\rangle$ using matrix multiplication and Hermitian conjugation: $$ \langle H|U^\dagger U|H \rangle = \begin{pmatrix}1 & 0\end{pmatrix} U^\dagger U \begin{pmatrix}1 \ 0 \end{pmatrix} = u_{11}^* u_{11} + u_{12}^* u_{12} = |u_{11}|^2 + |u_{12}|^2 \ \langle V|U^\dagger U|V\rangle = \begin{pmatrix}0 & 1\end{pmatrix} U^\dagger U \begin{pmatrix}0 \ 1 \end{pmatrix} = u_{21}^* u_{21} + u_{22}^* u_{22} = |u_{21}|^2 + |u_{22}|^2 $$

  2. Use the fact that the norm of a state is equal to its inner product with itself: $$|H|^2 = 1 \quad \text{and} \quad |V|^2 = 1$$

  3. Deduce that ( |u_{11}|^2 + |u_{12}|^2 = 1 ) and ( $|u_{21}|^2 + |u_{22}|^2 = 1$ ), which means that the matrix $U $ satisfies the condition for being unitary. Hence, if a 2x2 matrix $ |H\rangle $ preserves the normalization of probability amplitudes for polarization states $ |H\rangle $ and $ |V\rangle $ , it must be unitary.