Quantum Fundamentals

Explore the building blocks of quantum computing

Introduction to Quantum Gates

Quantum gates are the fundamental building blocks of quantum circuits, analogous to logic gates in classical digital circuits. They operate on qubits, transforming their quantum states. Each gate is represented by a unitary matrix, ensuring that quantum information is preserved.

Single-Qubit Gates

Hadamard Gate (H)

The Hadamard gate creates a superposition state. When applied to a basis state ($|0\rangle$ or $|1\rangle$), it transforms it into an equal superposition of both states.

Matrix Representation:

$$ H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} $$

Action on basis states:

$$ H|0\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) $$

$$ H|1\rangle = \frac{1}{\sqrt{2}}(|0\rangle - |1\rangle) $$

Pauli-X Gate (X)

The Pauli-X gate acts as a quantum "NOT" gate, flipping the state of a qubit.

Matrix Representation:

$$ X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} $$

Action on basis states:

$$ X|0\rangle = |1\rangle $$

$$ X|1\rangle = |0\rangle $$

Pauli-Y Gate (Y)

The Pauli-Y gate performs a bit flip and a phase shift.

Matrix Representation:

$$ Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix} $$

Action on basis states:

$$ Y|0\rangle = i|1\rangle $$

$$ Y|1\rangle = -i|0\rangle $$

Pauli-Z Gate (Z)

The Pauli-Z gate applies a phase shift of $\pi$ radians to the $|1\rangle$ state.

Matrix Representation:

$$ Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} $$

Action on basis states:

$$ Z|0\rangle = |0\rangle $$

$$ Z|1\rangle = -|1\rangle $$

Phase Shift Gate (S)

The S gate (or $\sqrt{Z}$ gate) applies a phase shift of $\pi/2$ radians.

Matrix Representation:

$$ S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix} $$

Action on basis states:

$$ S|0\rangle = |0\rangle $$

$$ S|1\rangle = i|1\rangle $$

T Gate

The T gate (or $\sqrt{S}$ gate) applies a phase shift of $\pi/4$ radians.

Matrix Representation:

$$ T = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix} $$

Action on basis states:

$$ T|0\rangle = |0\rangle $$

$$ T|1\rangle = e^{i\pi/4}|1\rangle $$

Multi-Qubit Gates

CNOT Gate (CX, Controlled-NOT)

The CNOT gate, also known as the CX gate, flips the state of the target qubit if and only if the control qubit is in the $|1\rangle$ state.

Matrix Representation:

$$ \text{CNOT} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix} $$

Action on basis states (Control Q0, Target Q1):

$$ \text{CNOT}|00\rangle = |00\rangle $$

$$ \text{CNOT}|01\rangle = |01\rangle $$

$$ \text{CNOT}|10\rangle = |11\rangle $$

$$ \text{CNOT}|11\rangle = |10\rangle $$

SWAP Gate

The SWAP gate exchanges the states of two qubits.

Matrix Representation:

$$ \text{SWAP} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix} $$

Action on basis states:

$$ \text{SWAP}|00\rangle = |00\rangle $$

$$ \text{SWAP}|01\rangle = |10\rangle $$

$$ \text{SWAP}|10\rangle = |01\rangle $$

$$ \text{SWAP}|11\rangle = |11\rangle $$

CCNOT Gate (Toffoli Gate)

The CCNOT gate, also known as the Toffoli gate, is a three-qubit gate. It flips the state of the target qubit if and only if both control qubits are in the $|1\rangle$ state. It is a universal classical gate, meaning any classical computation can be performed using only Toffoli gates.

Matrix Representation (Control qubits 1 & 2, Target qubit 3):

$$ \text{CCNOT} = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \end{pmatrix} $$

Action on basis states (Control Q0, Q1; Target Q2):

$$ \text{CCNOT}|000\rangle = |000\rangle $$

$$ \text{CCNOT}|001\rangle = |001\rangle $$

$$ \text{CCNOT}|010\rangle = |010\rangle $$

$$ \text{CCNOT}|011\rangle = |011\rangle $$

$$ \text{CCNOT}|100\rangle = |100\rangle $$

$$ \text{CCNOT}|101\rangle = |101\rangle $$

$$ \text{CCNOT}|110\rangle = |111\rangle $$

$$ \text{CCNOT}|111\rangle = |110\rangle $$

CZ Gate (Controlled-Z)

The CZ gate applies a Pauli-Z gate to the target qubit if and only if the control qubit is in the $|1\rangle$ state. It introduces a phase shift of $\pi$ to the $|11\rangle$ state.

Matrix Representation:

$$ \text{CZ} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix} $$

Action on basis states (Control Q0, Target Q1):

$$ \text{CZ}|00\rangle = |00\rangle $$

$$ \text{CZ}|01\rangle = |01\rangle $$

$$ \text{CZ}|10\rangle = |10\rangle $$

$$ \text{CZ}|11\rangle = -|11\rangle $$

Parametric Rotation Gates

X-Rotation Gate (Rx)

Rotates the state vector about the X-axis by an angle $\theta$. It introduces phase and amplitude changes through the complex number $i$.

Matrix Representation:

$$R_x(\theta) = \begin{pmatrix} \cos(\theta/2) & -i\sin(\theta/2) \\ -i\sin(\theta/2) & \cos(\theta/2) \end{pmatrix}$$

Action on basis states:

$$\begin{aligned} R_x(\theta)|0\rangle &= \cos(\theta/2)|0\rangle - i\sin(\theta/2)|1\rangle \\ R_x(\theta)|1\rangle &= -i\sin(\theta/2)|0\rangle + \cos(\theta/2)|1\rangle \end{aligned}$$

This gate creates a superposition of $|0\rangle$ and $|1\rangle$ and introduces an imaginary phase into the amplitudes.

Y-Rotation Gate (Ry)

Rotates the state vector about the Y-axis by an angle $\theta$. This is a real-valued matrix, purely affecting the probability amplitudes.

Matrix Representation:

$$R_y(\theta) = \begin{pmatrix} \cos(\theta/2) & -\sin(\theta/2) \\ \sin(\theta/2) & \cos(\theta/2) \end{pmatrix}$$

Action on basis states:

$$\begin{aligned} R_y(\theta)|0\rangle &= \cos(\theta/2)|0\rangle + \sin(\theta/2)|1\rangle \\ R_y(\theta)|1\rangle &= -\sin(\theta/2)|0\rangle + \cos(\theta/2)|1\rangle \end{aligned}$$

This gate also creates a superposition, but the amplitudes are purely real, making it easy to visualize rotation into the X-Z plane.

Z-Rotation Gate (Rz)

Rotates the state vector about the Z-axis by an angle $\theta$. This gate only modifies the relative phase of the state vector.

Matrix Representation:

$$R_z(\theta) = \begin{pmatrix} e^{-i\theta/2} & 0 \\ 0 & e^{i\theta/2} \end{pmatrix}$$

Action on basis states:

$$\begin{aligned} R_z(\theta)|0\rangle &= e^{-i\theta/2}|0\rangle \\ R_z(\theta)|1\rangle &= e^{i\theta/2}|1\rangle \end{aligned}$$

This gate only modifies the phase of the components. Crucially, the relative phase difference is $\phi = (i\theta/2) - (-i\theta/2) = i\theta$, which is what affects interference.

Bell States (Maximally Entangled States)

Bell states are a set of four specific maximally entangled two-qubit states. They form a basis for two-qubit systems and are fundamental in quantum information science, appearing in phenomena like quantum teleportation and superdense coding.

$$ |\Phi^{+}\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle) $$

$$ |\Phi^{-}\rangle = \frac{1}{\sqrt{2}}(|00\rangle - |11\rangle) $$

$$ |\Psi^{+}\rangle = \frac{1}{\sqrt{2}}(|01\rangle + |10\rangle) $$

$$ |\Psi^{-}\rangle = \frac{1}{\sqrt{2}}(|01\rangle - |10\rangle) $$

These states exhibit strong correlations, meaning the measurement of one qubit instantly influences the state of the other, regardless of their physical separation.

GHZ Algorithm (Greenberger-Horne-Zeilinger)

The GHZ algorithm (also referring to GHZ states) demonstrates a profound non-classical correlation among three or more entangled qubits, even stronger than Bell states. A GHZ state is a type of multipartite entangled state.

For three qubits:

$$ | \text{GHZ} \rangle = \frac{1}{\sqrt{2}}(|000\rangle + |111\rangle) $$

This state is created by applying a Hadamard gate to the first qubit (initially $|0\rangle$), followed by CNOT gates between the first and second, and then the first and third qubits. It is a cornerstone for illustrating the power of multipartite entanglement and has applications in quantum cryptography and quantum error correction.