This repository documents my journey learning quantum computing from the ground up. I'm building practical understanding of quantum algorithms and circuit design through coding and mathematical exploration.
Quantum states are represented using the Dirac Notation, a shorthand for vector and matrix algebra.
A Ket is a column vector representing the state of a qubit.
A Bra is a row vector, specifically the conjugate transpose of a Ket.
Combining a Bra and a Ket produces a scalar value representing the overlap between two states:
$\displaystyle \langle 0 | 0 \rangle = 1$ $\displaystyle \langle 0 | 1 \rangle = 0$
The X-Gate is the quantum equivalent of the classical NOT gate. It performs a
Matrix:
Logic:
The X-Gate flips the state of the qubit:
$X\ket{0} \rightarrow \ket{1}$ $X\ket{1} \rightarrow \ket{0}$
The Y-Gate performs a
Matrix:
Logic:
The Y-Gate flips the state and applies a phase:
$Y\ket{0} \rightarrow i\ket{1}$ $Y\ket{1} \rightarrow -i\ket{0}$
The Z-Gate performs a
Matrix:
Logic:
The Z-Gate preserves the state but flips the phase if it is
$Z\ket{0} \rightarrow \ket{0}$ $Z\ket{1} \rightarrow -\ket{1}$
The H-Gate is one of the most fundamental tools in quantum computing. It acts as a bridge between the computational basis (
Matrix:
Logic:
The H-Gate places a qubit into an equal superposition:
$H\ket{0} \rightarrow \frac{1}{\sqrt{2}} (\ket{0} + \ket{1}) = \ket{+}$ $H\ket{1} \rightarrow \frac{1}{\sqrt{2}} (\ket{0} - \ket{1}) = \ket{-}$
The S-Gate performs a
Matrix:
Logic:
The S-Gate shifts the phase:
$S\ket{0} \rightarrow \ket{0}$ $S\ket{1} \rightarrow i\ket{1}$
The T-Gate performs a
Matrix:
Logic:
The T-Gate shifts the phase:
$T\ket{0} \rightarrow \ket{0}$ $T\ket{1} \rightarrow e^{\frac{i\pi}{4}}\ket{1}$
In quantum computing, a qubit's state is represented by amplitudes.
Given a state:
The probability (
-
Probability of
$\ket{0}$ :$\displaystyle P(0) = |\alpha|^2$ -
Probability of
$\ket{1}$ :$\displaystyle P(1) = |\beta|^2$
Example:
After applying a Hadamard gate to
The Math:
To represent multiple qubits at once, we use the Tensor Product. This operation combines individual qubit vectors into a larger vector representing the entire system.
For two qubits
Using the tensor product, we define the four possible states for a two-qubit system:
Goal: Search for
Initialization
Mark Target
Diffusion Operator
-
$\frac{1}{2}\Big(\overset{\color{green}{1}}{\ket{00}} +\overset{\color{green}{1}}{\ket{01}} + \overset{\color{green}{1}}{\ket{10}} + \overset{\color{green}{1}}{\ket{11}}\Big)$ -
$\frac{1}{2}\Big(-\overset{\color{red}{-1}}{\ket{00}} +\overset{\color{green}{1}}{\ket{01}} -\overset{\color{red}{-1}}{\ket{10}} +\overset{\color{green}{1}}{\ket{11}}\Big)$ -
$\frac{1}{2}\Big(\overset{\color{green}{1}}{\ket{00}} +\overset{\color{green}{1}}{\ket{01}} -\overset{\color{red}{-1}}{\ket{10}} -\overset{\color{red}{-1}}{\ket{11}}\Big)$ -
$\frac{1}{2}\Big(\overset{\color{green}{1}}{\ket{00}} -\overset{\color{red}{-1}}{\ket{01}} -\overset{\color{red}{-1}}{\ket{10}} +\overset{\color{green}{1}}{\ket{11}}\Big)$
-
$\ket{00} = \frac{1}{2} - \frac{1}{2} + \frac{1}{2} + \frac{1}{2} = 1$ -
$\ket{01} = \frac{1}{2} + \frac{1}{2} + \frac{1}{2} - \frac{1}{2} = 1$ -
$\ket{10} = \frac{1}{2} - \frac{1}{2} - \frac{1}{2} - \frac{1}{2} = -1$ -
$\ket{11} = \frac{1}{2} + \frac{1}{2} - \frac{1}{2} + \frac{1}{2} = 1$
-
$\frac{1}{2}\Big(-\overset{\color{red}{-1}}{\ket{00}} -\overset{\color{red}{-1}}{\ket{01}} -\overset{\color{red}{-1}}{\ket{10}} -\overset{\color{red}{-1}}{\ket{11}}\Big)$ -
$\frac{1}{2}\Big(\overset{\color{green}{1}}{\ket{00}} -\overset{\color{red}{-1}}{\ket{01}} +\overset{\color{green}{1}}{\ket{10}} -\overset{\color{red}{-1}}{\ket{11}}\Big)$ -
$\frac{1}{2}\Big(-,\overset{\color{red}{-1}}{\ket{00}} -\overset{\color{red}{-1}}{\ket{01}} +\overset{\color{green}{1}}{\ket{10}} +\overset{\color{green}{1}}{\ket{11}}\Big)$ -
$\frac{1}{2}\Big(\overset{\color{green}{1}}{\ket{00}} -\overset{\color{red}{-1}}{\ket{01}} -\overset{\color{red}{-1}}{\ket{10}} +\overset{\color{green}{1}}{\ket{11}}\Big)$
-
$\ket{00} = - \frac{1}{2} + \frac{1}{2} - \frac{1}{2} + \frac{1}{2} = 0$ -
$\ket{01} = -\frac{1}{2} - \frac{1}{2} - \frac{1}{2} - \frac{1}{2} = -2$ -
$\ket{10} = -\frac{1}{2} - \frac{1}{2} + \frac{1}{2} + \frac{1}{2} = 0$ -
$\ket{11} = \frac{1}{2} - \frac{1}{2} - \frac{1}{2} + \frac{1}{2} = 0$



