Odorless foods and drinks are allowed in class due to proximity to lunch time
Items
Proportions
Midterm
35%
Final
35%
Assignments
20%
Attendance
10%
TOTAL
100%
My Forthcoming Book
"Quantum Computing: A Gentle Introduction for AI Engineers" (Boonkwan, 2026)
Quantum Topics You Really Need to Know
image-2
A rough dependency map/flowchart of topics — start from Quantum Phenomena, move through complex numbers/vectors, unitary operators, eigen-decomposition, gates, measurement, and eventually branch into two "tracks": (1) algorithms like Grover's, Shor's, Fourier transform/phase estimation, and (2) quantum machine learning (variational circuits, QNNs, VQE, QAOA). Think of it like a skill tree in a video game — you need earlier nodes unlocked before later ones make sense.
Quantum phenomena (1.3): Superposition, entanglement, and interference
Complex numbers (2.3): Polar form and trigonometry
Complex vectors (2.4): Wave multiplex, Hilbert space, and distance measurement
Unitary operators (3.4): The core mechanism of all quantum logic gates
Eigen-decomposition (3.5): Eigen-states (hidden axes) and their energies
Quantum logic gates (4): Qubits, quantum operators, universal rotations, tensor product, and entangled states
Clifford gates (5.2, 5.4, 5.5): All basic quantum gates
Non-Clifford gates (6.2, 6.3): More flexible quantum gates
State measurement (7.2): Probability amplitudes, state expectation, and variance
Solution extraction (8.1): Oracle separation, phase kickback, and oracle extraction
Communication (8.4): Quantum key distribution as a secure communication protocol
Noisy channel (9.1): Decoherence, density matrix, purification, and fidelity
Grover's search (10.1): Amplitude amplification and mean shifting by diffusion
Fourier transform (10.2): Quantum Fourier transform and its inverse
Phase estimation (10.3): Uniform angular rotation and phase estimation by rotation
Shor's algorithm (11.3): Factorization by quantum phase estimation and RSA hacking
Hamiltonian (12.2): Energy form of unitary operator, trotterization, and qubitization
Parameterized quantum circuits (13.1): Quantum embedding, ansatz, and entangler layers
Hearsay: "Quantum computer is immensely faster than classical computer!"
Shor's algorithm for factoring an integer n in O((logn)3) time complexity, making RSA code decryption feasible in polynomial time
Quantum supremacy vs. quantum advantage
Quantum computers
Perform computation by manipulating state superposition and entanglement in-memory with quantum-mechanical phenomena
Are susceptible to noise due to quantum interference
Can solve some polynomial-time and non-polynomial-time problems with bounded error
The notion of classical computer refers to modern-day computers that rely on binary data
Classical Computer
Data: Stored as binary numbers and manipulated by electronic circuits
Processing: Logical and arithmetic operations, data transfer, and type conversion
Representation: Only one item out of a vast realm of all possible configurations!
Limit: We cannot intrinsically process multiple input items in parallel
Figure 2: von Neumann architecture of classical computers
Think of a classical computer like reading one page of a book at a time — you can only be on one page (one state) at once, even if you flip through pages very fast.
Bitstring
Binary number is a number expressed in the base-2 numeral system: 0 and 1
Bitstring (or binary representation) of integer N is denoted by BL(N), where L is the length of such bitstring, e.g.
B8(33)=001000012
We can convert a bitstring to a decimal number by multiplying each k-th digit (from the right) with its decimal equivalent 2k−1 and summing these multiplicants, e.g.
001000012=1×25+1×20=3310
We can also convert an integer to a bitstring by continued division as follows:
Find the closest exponent 2k to N
Subtract 2k from N
Repeat until the subtraction becomes zero
Example: We convert 3010 to 111102 by
30=1×24+1×23+1×22+1×21+0×20
30
14
6
2
0
subtract
−16
−8
−4
−2
power
24
23
22
21
Table 1: Conversion from 3010 to 111102
Logical Operations
AND returns 1 iff both operands are 1 0011∧0101=0001
OR returns 1 iff at least one operand is 1 0011∨0101=0111
NOT returns the opposite value 01=10
XOR returns 1 iff only one operand is 1 0011⊕0101=0110
These abstract logical operations lay the foundation of data processing in classical computing, where conditional branching, jumping, and looping are predominant
In quantum computing, these operations will be emulated by linear transformation
Classical computing is linearly scalable, due to sequential logical processing of discrete states
Parallelism in classical computing accelerates sequential processing with multiple computing cores
import multiprocessing as mpdef factorial(x): result = 1 for i in range(2, x+1): result *= i return resultitems = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]pool = mp.Pool(processes=4)results = pool.map(factorial, items)print(results)
Classical parallelism struggles on looping with exponential iterations, resulting in O(2N) time complexity
In quantum computing, multiple discrete values are represented as a superposition of bitstrings
{0000,0001,…,1111}⇒∣0⟩,…,∣15⟩
Then the quantum operations are done on this state superposition
The quantum data processing is based on complex algebra (i.e. complex vectors, complex matrices, and measurement)
Classical parallelism is like hiring more workers to do more tasks at the same time — but if the task itself branches exponentially (like trying every password combination), even many workers can't keep up. Quantum superposition instead lets one "worker" explore all combinations at once, in a sense.
Modern-Day AI
High demand of parallel computation with graphical processing units (GPUs)
Limitations of high performance computing
Power wall: Performance gain of transistor-based CPUs are limited by thermal ceiling
Memory wall: High bandwidth memory still lags behind when compared to the CPUs
Network bottleneck: Data synchronization between computing units are relatively very slow
Quantum tunneling: Electrons start to leak through insulation across transistors causing errors & heat #MidtermExam
Electron อาจจะกระโดดไปอีกเส้นนึง (to the next wire)
Qubit: Each bit of information is stored as the momentum spin of a particle
Information processing is to manipulate these qubits via physical interaction, e.g. laser beam (trapped ions) or light interference (photons)
Figure 6: A classical bitstring represents the system's current state (e.g. 0 1 0 0 1 1 0 1)
Dipole = up and down
Upward: 0
Downward: 1
State Measurement
Momentum spins are destroyed when we read the system's current state
Figure 7: State measurement — measurement by a strong laser beam or spectral projection; we obtain the system's current state but all spins collapse (e.g. 0 1 0 0 1 1 0 1)
This is like peeking at a spinning coin mid-air: the moment you look, it "chooses" heads or tails and stops spinning. You can't un-look and get the superposition back.
Phenomenon 1: Superposition
A quantum system can exist in multiple states (with probabilities) in parallel
Figure 8: Quantum superposition — spins collapsing to probability distributions; example bitstrings 00001001 (0.375), 00001101 (0.125), 01001001 (0.375), 01001101 (0.125)
Imagine a spinning top that is simultaneously "leaning" toward multiple directions until it stops: while spinning, it doesn't have one fixed direction, only probabilities of where it will land.
Probability distribution (การแจกแจงความน่าจะเป็น) คือการแสดงค่าความน่าจะเป็นของทุกผลลัพธ์หรือทุก State ที่เป็นไปได้ทั้งหมดของตัวแปรสุ่ม
ถ้าดู bit 2 กับ 6 อันนี้มันถูกแจกแจงความน่าจะเป็นถูกป้ะ พร้อมกับมีบอกแล้วว่า Probability เท่าไหร่ เราสามารถคำนวณหา joint probability ได้เหมือนกัน ว่ามันเป็นอะไรได้บ้าง!
ในโลกของ quantum เรียกว่า Probability density
P(q1,q2)=P(q1)×P(q2)
Quantum State and Probability Amplitudes
เวลามัน spin ไม่ใช่ขึ้นลงซ้ายขวานะ แต่มันเป็น 3D จ้าา ดังนั้นเขาก็จะเอาการอธิบายโดยการใช้ Complex number เข้ามาละ - representation of one qubit
Quantum state: the system's configuration of momentum spins for each qubit
Three dipoles (0/1, +/−, and +i/−i) represent the 3D momentum spin of one qubit
∣ψ⟩=a∣0⟩+b∣1⟩
where complex numbers a and b are probability amplitudes of ∣ψ⟩ collapsing to 0 and 1
Probability density of ∣ψ⟩ collapsing to 0 or 1: P(0∣ψ)=∣a∣2P(1∣ψ)=∣b∣2
Dirac's notation: ∣ψ⟩ reads 'ket'-psi
Figure 9: Bloch sphere — showing Z-axis (Bit |0⟩ / Bit |1⟩), X-axis (pos real |+⟩ / neg real |−⟩), Y-axis (pos img |+i⟩ / neg img |−i⟩)
The Bloch sphere is like a globe where the North Pole is "definitely 0" and the South Pole is "definitely 1" — any point on the surface is some blend of both, and the angles tell you the probability and phase.
Multi-Qubit System
Tensor product of quantum states (a1∣0⟩+b1∣1⟩)⊗(a2∣0⟩+b2∣1⟩)=a1a2∣00⟩+a1b2∣01⟩+b1a2∣10⟩+b1b2∣11⟩
where ⊗ denotes concatenation
Tensor product is like combining independent dice — if two dice are unrelated (unentangled), you can describe their combined outcomes just by multiplying each die's individual probabilities. Factorization is un-mixing a joint description back into separate, independent pieces — but this is only possible if the qubits aren't entangled.
Dirac's Notation
Single-qubit ket = 2-dim column vector ∣0⟩=[10]∣1⟩=[01]a∣0⟩+b∣1⟩=[ab]
ket = column vector
ket 0 = put one in index 0
ket 1 = put one in index 1
ket 7 = put one in index 7
L-qubit ket = 2L-dim column vector ∣k⟩=0⋮010⋮0k=0∑2L−1ak∣k⟩=a0⋮a2L−1
∣k⟩ is a 1-hot vector at the k-th position
Single-qubit bra = 2-dim row vector (a∣0⟩+b∣1⟩)∗=aˉ⟨0∣+bˉ⟨1∣=[aˉbˉ]
bra = row vector
bra 0 = put one in index 0
Adjoint
You flip the row vector to column vector (vice versa) and flip the sign of the complex number (just that!!)
[a+bic+di]∗=[a−bic−di]
L-qubit bra = 2L-dim row vector k=0∑2L−1ak⟨k∣=[a0…a2L−1]
Bra-ket product = vector similarity
What if you multiply column vector with row vector????? ⟨k∣k⟩=1⟨j∣k⟩=0 where j=k
⟨0∣∣1⟩
อ่านว่า bra zero, ket 1
=[10][01]=0
Bra-ket product is essentially a dot product measuring "overlap" or similarity between two quantum states — 1 means identical, 0 means completely distinguishable (orthogonal).
Phenomenon 2: Entanglement
Multiple particles may become inextricably linked to each other, i.e. they are entangled
Entangled states are multi-qubit states that cannot be factorized further, e.g. Bell states
∣Φ+⟩=2∣00⟩+∣11⟩∣Φ−⟩=2∣00⟩−∣11⟩
If one of them collapses, the rest of the pack also collapse instantaneously: P(00∣Φ+)=21P(11∣Φ+)=21 Figure showing photon splitting via BBO crystal into two entangled particles A and B, each measuring 0 or 1, with correlated outcomes 0→0, 1→1
Entanglement is like a pair of magic dice — no matter how far apart you take them, if one lands on 6, the other instantly lands on 6 too, even though before you looked, neither had a fixed value. This correlation isn't communication — it's built into how they were "made" together.
Useful for cryptography: quantum teleportation (information can be shared using entanglement state)
Phenomenon 3: Quantum Interference
If we manipulate the probability amplitude of a qubit, this change ripples to the others
Probability amplitude can be manipulated in two ways:
Amplification: increasing the probability amplitude
Dampening: decreasing the probability amplitude
Quantum interference is the key mechanism of quantum gate design
Figure 10: Quantum interference — (a) equal probability amplitudes shown as a flat square/diamond in 3D and top view; (b) after interference, amplitudes are either amplified (green) or dampened (orange)
Think of interference like sound waves — two waves can add up (constructive, louder) or cancel out (destructive, quieter). Quantum gates are designed to make "wrong answers" cancel out and "right answers" reinforce each other.
\mathbf{X}\begin{bmatrix} a \\ b \end{bmatrix} &= \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\begin{bmatrix} a \\ b \end{bmatrix} \\[8pt]
&= \begin{bmatrix} 0a + 1b \\ 1a + 0b \end{bmatrix} \\[8pt]
&= \begin{bmatrix} b \\ a \end{bmatrix}
\end{aligned}$$
- Compared with state mapping:
$$ \begin{aligned}
\mathbf{X}(a|0\rangle + b|1\rangle) &= a(\mathbf{X}|0\rangle) + b(\mathbf{X}|1\rangle) \\[6pt]
&= a|1\rangle + b|0\rangle \\[6pt]
&= b|0\rangle + a|1\rangle
\end{aligned} $$
> Think of a quantum operator as a recipe that says "whatever amount of ingredient A you had, put that amount into the output B slot instead" — it's a substitution rule expressed as a matrix.
## NOT Gate: X
- **X gate** flips the qubit between $|0\rangle$ and $|1\rangle$
- State mapping: $|0\rangle \mapsto |1\rangle \qquad |1\rangle \mapsto |0\rangle$
- It imitates logical NOT in classical computing
![[Screenshot 2026-09-10 at 11.00.59 AM.png|center|300]]
_Figure 11: X gate — |0⟩ → X → |1⟩, |1⟩ → X → |0⟩_
- **Quantum algorithm** is a circuit of quantum logic gates
![[Screenshot 2026-09-10 at 11.01.47 AM.png|center|500]]
_Circuit diagram showing three qubits initialized at |0⟩, with X gates applied sequentially: |ψ⁽⁰⁾⟩=|000⟩ → |ψ⁽¹⁾⟩=|100⟩ → |ψ⁽²⁾⟩=|110⟩ → |ψ⁽³⁾⟩=|111⟩ → |ψ⁽⁴⁾⟩=|011⟩_
## Hadamard Gate: H
- **H gate** flips between pure states and superpositions
- State mapping:
$$ |0\rangle \mapsto \underbrace{\frac{|0\rangle + |1\rangle}{\sqrt{2}}}_{|+\rangle} \qquad |1\rangle \mapsto \underbrace{\frac{|0\rangle - |1\rangle}{\sqrt{2}}}_{|-\rangle} $$
- Used for parallel processing
![[Screenshot 2026-09-10 at 11.07.32 AM.png|center|300]]
_Figure 12: Hadamard gate — |0⟩ → H → |+⟩, |1⟩ → H → |−⟩_
- Preparing a superposition of all possible $2^L$ inputs
![[Screenshot 2026-09-10 at 11.08.09 AM.png|center|500]]
_Circuit: three qubits |0⟩ each pass through H gates: |ψ⁽⁰⁾⟩=|000⟩ → |ψ⁽¹⁾⟩=|±00⟩ → |ψ⁽²⁾⟩=|++0⟩ → |ψ⁽³⁾⟩=|+++⟩ (approximate, using ± for superposition states)_
>The meaning of
>$$
\begin{aligned}
|{+++}\rangle &= |+\rangle \otimes |+\rangle \otimes |+\rangle \\[8pt]
&= \frac{|0\rangle + |1\rangle}{\sqrt{2}} \otimes \frac{|0\rangle + |1\rangle}{\sqrt{2}} \otimes \frac{|0\rangle + |1\rangle}{\sqrt{2}} \\[8pt]
&= \frac{1}{\sqrt{2^3}} \left[ |000\rangle + |001\rangle + \ldots + |111\rangle \right]
\end{aligned}
>$$
>this is where parallel computing happen! (we’d get all the combination right away after we apply hadamard gate)
> The Hadamard gate is like flipping a fair coin — from a "certain" state (heads only) it creates a perfect 50/50 blend of possibilities. Apply it to every qubit and you instantly get a superposition covering every possible combination of bits.
## Controlled NOT Gate: CNOT
- **CNOT gate** imitates an if-clause and creates entanglement
- State mapping:
$$ |0x\rangle \mapsto |0x\rangle \qquad |1x\rangle \mapsto |1\bar{x}\rangle $$
where $x$ is either 0 or 1
- Last qubit is the output, equivalent to classical XOR gate
![[Screenshot 2026-09-10 at 11.11.53 AM.png|center|300]]
_Figure 13: Controlled NOT gate — |x⟩ control stays |x⟩, |y⟩ target becomes |x ⊕ y⟩_
- Preparing an entangled state with H and CNOT gates:
![[Screenshot 2026-09-10 at 11.12.39 AM.png|center|500]]
>Not that difficult #MidtermExam for sure!!
$$ |\psi^{(0)}\rangle = |000\rangle \xrightarrow{H} |\psi^{(1)}\rangle = |\pm 00\rangle = \frac{|0\rangle+|1\rangle}{\sqrt{2}} \otimes |00\rangle = \frac{|000\rangle + |100\rangle}{\sqrt{2}} $$
$$ \xrightarrow{CNOT} |\psi^{(2)}\rangle = \frac{|00\underline{0}\rangle + |11\underline{0}\rangle}{\sqrt{2}} \xrightarrow{CNOT} |\psi^{(3)}\rangle = \frac{|000\rangle + |111\rangle}{\sqrt{2}} $$
> CNOT is like a rule: "if the control switch is ON, flip the target; if OFF, leave it alone." Combined with Hadamard's coin-flip, it links two qubits together so their fates become intertwined (entangled) — the classic Bell state.
## Phase Shift Gate: S
- **S gate** flips between real and complex numbers on $|1\rangle$
- State mapping:
$$ |0\rangle \mapsto |0\rangle \qquad |1\rangle \mapsto i|1\rangle $$
- Imaginary number $i = \sqrt{-1}$ is used as a soft feature in quantum machine learning
![[Screenshot 2026-09-10 at 11.17.11 AM.png|center|300]]
_Figure 14: Phase shift gate — |0⟩ → S → |0⟩, |1⟩ → S → i|1⟩_
- Preparing an entangled state with complex probability amplitudes (using H, CNOT, then S on third qubit):
![[Screenshot 2026-09-10 at 11.18.08 AM.png|center|600]]
$$ |\psi^{(4)}\rangle = \frac{|000\rangle + i|111\rangle}{\sqrt{2}} $$
## Toffoli Gate: CCNOT
- **CCNOT gate** imitates an if-clause with two control qubits
- State mapping:
$$ \text{Both controls: } |11x\rangle \mapsto |11\bar{x}\rangle \qquad \text{Otherwise: } |xyz\rangle \mapsto |xyz\rangle $$
where $x$ and $y$ are binary flags
![[Screenshot 2026-09-10 at 11.18.46 AM.png|center|300]]
_Figure 15: Toffoli gate — |x⟩→|x⟩, |y⟩→|y⟩, |z⟩→|(x∧y)⊕z⟩_
- CCNOT gate imitates all classical logic gates, allowing massive parallelism on classical programs
![[Screenshot 2026-09-10 at 11.19.08 AM.png|center|600]]
_Diagrams showing how CCNOT (with fixed ancilla qubits set to |1⟩ or |0⟩) can emulate NOT, AND, OR, and XOR gates_
> The Toffoli gate is the "universal building block" of classical logic inside a quantum circuit — since it can simulate AND, OR, NOT, and XOR, any classical computation can, in principle, be run reversibly on a quantum computer.
## Rotation Gates: RX, RY, and RZ
- Rotation gates rotate a qubit around the specified eigenbases
- Rotation alters the probability densities used in quantum machine learning
- X-rotation $\mathbf{RX}(\theta)$, Y-rotation $\mathbf{RY}(\theta)$, and Z-rotation $\mathbf{RZ}(\theta)$, where $\theta$ is a model parameter
![[Screenshot 2026-09-10 at 11.20.42 AM.png|center|400]]
![[Screenshot 2026-09-10 at 11.20.27 AM.png|center|400]]
![[Screenshot 2026-09-10 at 11.21.07 AM.png|center|400]]
_Bloch sphere diagrams showing rotation around X-axis, Y-axis, and Z-axis respectively for RX(θ), RY(θ), RZ(θ)_
> Rotation gates are like turning a dial by angle θ on the Bloch sphere — instead of a hard flip (like X), you get a smooth, tunable adjustment. This tunability is exactly what makes these gates useful as "trainable parameters" in quantum machine learning.
## Controlled Gate: $\mathbf{C}^{|k\rangle}\mathbf{U}$
- Extension of CNOT, where control qubits are $|k\rangle$
- State mapping of $\mathbf{C}^{|k\rangle}\mathbf{U}$:
- If controls $|x_1, \ldots, x_L\rangle = |k\rangle$:
$$ |x_1, \ldots, x_L, y\rangle \mapsto |x_1, \ldots, x_L\rangle \otimes \mathbf{U}|y\rangle $$
- Otherwise:
$$ |x_1, \ldots, x_L, y\rangle \mapsto |x_1, \ldots, x_L, y\rangle $$
- This is frequently used in Fourier transform and phase estimation
![[Pasted image 20260910112235.png|center|500]]
_Circuit with notation: open circle = c=0, filled circle = c=1. Three H gates on control qubits followed by a series of controlled gates C|000⟩, C|001⟩, C|010⟩, ..., C|111⟩ each conditionally applying RX(θ₀) through RX(θ₇) to the target qubit_
$$ |\psi^{(9)}\rangle = \frac{1}{\sqrt{8}}\sum_{k=0}^{7}\left(|k\rangle \otimes \mathbf{RX}(\theta_k)|0\rangle\right) $$
$$ |\psi^{(1)}\rangle = |{+}{+}{+}0\rangle \qquad |\psi^{(0)}\rangle = |0000\rangle $$
> This is like a lookup table encoded in quantum form — depending on what number the control qubits represent, a different rotation angle gets applied to the target, all done simultaneously across the superposition.
## State Measurement
- **Probability density**: We destructively measure the probability distribution of each pure state by projection (i.e. the quantum state collapses)
![[Screenshot 2026-09-10 at 11.24.27 AM.png|center|300]]
_Bar chart: probability density for 00001001 (0.375), 00001101 (0.125), 01001001 (0.375), 01001101 (0.125)_
- **Expectation** (แปลว่า average): We non-destructively measure if each $k$-th qubit leans towards one side of the particular dipoles $\mathbf{U} \in {\mathbf{X}, \mathbf{Y}, \mathbf{Z}}$
$$ \boxed{\langle \mathbf{U}^{(\psi)} \rangle = \langle \psi | \mathbf{U} | \psi \rangle} $$
|Expectations|Positive (+1)|Negative (−1)|
|---|---|---|
|$\langle \mathbf{Z}^{(k)} \rangle$ or $Z_k$|Bit 0|Bit 1|
|$\langle \mathbf{X}^{(k)} \rangle$ or $X_k$|Pos real|Neg real|
|$\langle \mathbf{Y}^{(k)} \rangle$ or $Y_k$|Pos img|Neg img|
> Probability density measurement is like flipping the coin and looking (destroys the superposition, gives you one concrete outcome). Expectation measurement is more like repeatedly weighing a loaded die many times without ever fully "reading" a single roll — you learn the average tendency (bias) without collapsing any individual instance permanently in the same destructive sense.
---
# 5. Quantum Algorithms
> [!info] Related
> - [[CSS454 - Computer and Communication Security/Chapter 8 - Post-Quantum Cryptography (PQC)#Quantum Algorithms That Break Crypto|Quantum Algorithms That Break Crypto — CSS454 Ch8]]
## Oracle Extraction
- **Bernstein-Vazirani algorithm**
- Extracting an oracle $\mathbf{s}$ from a black-box function $f_s$ by converting it to $\mathbf{U}_{f_s}$
- **Phase kickback technique**
- State mapping of $\mathbf{U}_{f_s}$:
$$ \text{Oracle: } |s_{1:N}, y\rangle \mapsto |s_{1:N}, y \operatorname{cis}\theta\rangle \qquad \text{Otw.: } |x_{1:N}, y\rangle \mapsto |x_{1:N}, y\rangle $$
- Kickback property:
$$ \boxed{\mathbf{U}_{f_s}\left(|+\rangle^{\otimes N} \otimes |-\rangle\right) = \left(\bigotimes_{k=1}^{N} \frac{|0\rangle + (\operatorname{cis}\theta)^{f_{s_k}(2^{k-1})}|1\rangle}{\sqrt{2}}\right) \otimes |-\rangle} $$
- The last qubit interferes with the others
![[Pasted image 20260910112905.png|center|500]]
_Circuit: N control qubits in superposition via H⊗N, ancilla qubit |1⟩ via H, passed through oracle Ufs, then H⊗N again and measured — the pure state s will have the highest probability density; also shows internal oracle circuit structure with CNOTs conditioned on s bits_
> Phase kickback is a clever trick: instead of writing the answer directly into the output qubit, the oracle "kicks back" a phase onto the input qubits. It's like asking a fortune teller a question where the answer subtly changes the way the question itself echoes back to you, rather than being spoken aloud.
## Quantum Teleportation
- Secure communication based on quantum mechanics
- We want to transmit state $|x\rangle = a|0\rangle + b|1\rangle$ with entangled state $\Phi^+ = \frac{|00\rangle + |11\rangle}{\sqrt{2}}$
- How it works:
1. The sender and receiver have $|\Phi_A^+\rangle$ and $|\Phi_B^+\rangle$, respectively
2. The sender runs the quantum teleportation algorithm on the input qubit $|x\rangle$
3. The sender measures $p$ and $q$ and sends them over classical communication
4. The receiver uses them to translate $|\Phi_B^+\rangle$ to $|x\rangle$
>Quantum teleporation = Transmiting one bit over quantum phenomenon
![[Screenshot 2026-09-10 at 11.30.02 AM.png]]_Circuit diagram: SENDER holds |x⟩ and |Φ_A^+⟩, applies CNOT and H, measures p and q; RECEIVER holds |Φ_B^+⟩, applies X (conditioned on q) and Z (conditioned on p) to recover |y⟩_
| $p$ | $q$ | State $|y\rangle$|
|---|---|---|
| 0 | 0 | $a|0\rangle + b|1\rangle$|
| 0 | 1 | $b|0\rangle + a|1\rangle$|
| 1 | 0 | $a|0\rangle - b|1\rangle$|
| 1 | 1 | $-b|0\rangle + a|1\rangle$ |
> Quantum teleportation doesn't move matter — it's more like faxing a document: the original state on the sender's side is destroyed (measured) in the process, while an identical copy is reconstructed on the receiver's side using the entangled link plus two classical bits of correction info. No faster-than-light info is transmitted, since the classical bits still need to travel normally.
## Quantum Key Distribution
> [!info] Related
> - [[Chapter 2 - Symmetric Encryption#One-Time Pad|One-Time Pad — CSS454 Ch2]]
- Secure communication without actual key transmission, such as **BB84**
![[Screenshot 2026-09-10 at 11.31.24 AM.png]]
_Figure 16: BB84 Protocol — Alice picks a key of bases (+/×), generates a random bitstring, encodes it as a qubit string, sends it to Bob who measures with his own random basis choices (getting some correct, some noisy "?" results), they compare/correct bases over a classical channel, and arrive at a shared corrected key_
> BB84 works like sending a locked box where the "type of lock" (basis) is randomly chosen each time. If an eavesdropper tries to peek, they must guess the lock type, and guessing wrong noticeably disturbs the box's contents — this disturbance is what lets Alice and Bob detect eavesdropping.
## Grover's Search Algorithm
- We can search for 1 of $N$ items w.r.t. the oracle function $f$ with
$$ \boxed{k^* = \left\lfloor \frac{\pi}{4}\sqrt{N} \right\rfloor \text{ iterations}} $$
![[Screenshot 2026-09-10 at 11.37.10 AM.png]]
_Figure 17: Overview of Grover's algorithm — four-step cycle: (1) Setup: solution and mean vector, (2) Oracle: the solution is temporarily sign-flipped, (3) Grover: recompute the mean vector, (4) Grover: amplify the probability amplitudes around the new mean vector_
![[Screenshot 2026-09-10 at 11.37.34 AM.png]] _Figure 18: Grover's algorithm circuit — H gates on all qubits, then a loop "for i = 1 to int(π·√(2^L)/4)" applying oracle Uf followed by the Grover operator (H, controlled-Z-like structure, H), ending in measurement_
> Grover's algorithm is like a "reverse magic trick": each round, it flips the sign of the amplitude on the correct answer (marking it), then reflects all amplitudes around their average. This repeated flip-and-reflect steadily nudges the probability mass toward the correct answer, giving a quadratic speedup over classical brute-force search ($\sqrt{N}$ instead of $N$ steps).
## Quantum Fourier Transform
- Translates a time series of $N$ items to a frequency domain, and vice versa, with $O((\log N)^2)$ time complexity
![[Screenshot 2026-09-10 at 11.38.21 AM.png]]_Left: time-domain waveform and its corresponding frequency-domain spectrum (odd harmonics at 1, 1/3, 1/5, 1/7, 1/9, 1/11, 1/13). Right: QFT circuit converting TIME basis |x₁...x_L⟩ to FREQ basis |ω₁...ω_L⟩, and QFT_(inverse) converting back, where L = log N*
> QFT is the quantum analog of the classical Fast Fourier Transform — it re-expresses a "signal" (a superposition over positions) in terms of its underlying periodicities (frequencies). It's a key subroutine used inside Shor's algorithm to detect hidden periodic patterns exponentially faster than any classical method.
## Quantum Phase Estimation
- We can extract a phase $2\pi\theta$ of a black-box algorithm $\mathbf{U}$ by rotating it in different frequencies and observing the resonance frequency
![[Screenshot 2026-09-10 at 11.38.58 AM.png]] _Top: four-panel diagram showing a clock-like rotation of angle 2πθ being repeated at increasing "speeds" (powers of U), until the accumulated rotations create an interference pattern that reveals the phase. Bottom: QPE circuit — N ancilla qubits via H gates, each controlling successive powers of U (U¹, U², U⁴, U⁸, ..., U^(2^(L-1))) applied to input state |ψ⟩, followed by inverse QFT (QFT_) and measurement*
$$ \text{Measure for } k^* = \text{pure state with max prob} \quad\Rightarrow\quad \boxed{\theta = k^*/2^N} $$
> Think of QPE like tuning a radio dial by testing many multiples of a frequency at once and looking for where they all constructively interfere ("resonate") — that resonance point tells you the hidden phase/frequency of the black box, similar to finding a hidden periodicity.
---
# 6. Quantum-Suitable Problems
> [!info] Related
> - [[Chapter 2 - Search#2.1 Solving Problems by Searching|2.1 Solving Problems by Searching — CSS324 Ch2]]
## Shor's Algorithm
- **RSA cryptosystem**
- Public and two private keys $(n, e, d)$
- Encryption: $c = (m^e)%n$
- Decryption: $m = (c^d)%n$
![[Screenshot 2026-09-10 at 11.39.33 AM.png]]_Left: RSA key generation and encrypt/decrypt flow between Sender A and Receiver B. Right: Shor's algorithm flowchart_
- **Attack with QPE**
- Modulo $\mathbf{U}_{\text{mod } n}(a)$ is equivalent to rotation
- QPE is used to guess the phase
- Time complexity $O(L^2 \log L)$
Flowchart steps:
- Guess factor $a$ of $n$ → if $a$ divides $n$? → Yes: factorize $a$ and $n/a$ (recursive) / No: continue
- Compute order $r = \phi(n)$ using quantum phase estimation
- Is $r$ odd? → Yes: back to guessing / No: continue
- Does $a^{r/2}+1$ divide $n$? → Yes: back to guessing / No: compute GCD $g = \gcd(n, a^{r/2}+1)$ → factorize $g$ and $n/g$ (recursive)
> Shor's algorithm exploits the fact that finding the "period" of modular exponentiation is exponentially hard classically but can be done efficiently with quantum phase estimation — this period then lets you factor large numbers quickly, which is precisely what breaks RSA encryption's security assumption.
## Simulation with Trotterization
- **Hamiltonian** $\hat{\mathbf{H}}_{\mathbf{U}}$ is the energy form of quantum circuit $\mathbf{U}$ of $L$ qubits
$$ \boxed{\mathbf{U} = \operatorname{cis}(-\hat{\mathbf{H}}_{\mathbf{U}})} $$
- We can compute $\hat{\mathbf{H}}_{\mathbf{U}}$ by
$$ \hat{\mathbf{H}}_{\mathbf{U}} = \sum_{\mathbf{P} \in {\mathbf{I},\mathbf{X},\mathbf{Y},\mathbf{Z}}^{\otimes L}} \left[\mathbf{P} \times \operatorname{trace}(\mathbf{UP})\right] $$
where $\mathbf{I}, \mathbf{X}, \mathbf{Y}, \mathbf{Z}$ are Pauli matrices:
$$ \mathbf{I} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \quad \mathbf{X} = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \quad \mathbf{Y} = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix} \quad \mathbf{Z} = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} $$
- **Trotter-Suzuki decomposition**: We can simulate $N$ iterations of $\mathbf{U}$ by approximation:
$$ \boxed{\mathbf{U}^N \approx \lim_{n \to \infty}\left[\operatorname{cis}\left(-\frac{N}{n}\hat{\mathbf{H}}_{\mathbf{U}}\right)\right]^n} $$
![[Screenshot 2026-09-10 at 11.41.09 AM.png|center|400]]
_Diagram showing repeated application of U_a1, U_a2, U_a3, ..., U_aN transforming |q⁽⁰⁾⟩ into |q⁽ᴺ⁾⟩ through many small interconnected steps_
> A Hamiltonian is like the "energy blueprint" that dictates how a system evolves over time. Since simulating one giant jump of evolution is hard, Trotterization breaks it into many tiny time-slices (like frames of a movie) and chains them together — an approximation that gets more accurate as the slices get thinner.
## Quantum Machine Learning
- **Variational quantum algorithm**
- Quantum circuit with rotation gates $\mathbf{RX}(\theta)$, $\mathbf{RY}(\theta)$, and $\mathbf{RZ}(\theta)$
- Basic entangler layer (**BEL**)
![[Screenshot 2026-09-10 at 11.41.30 AM.png|center|400]]
_Figure 19: Basic entangler layer — four qubits each go through RX(θ₁)...RX(θ₄), then are chained together with CNOTs in a cyclic pattern_
- Quantum embedding $\Lambda(\Theta)$
- **Angle embedding**: params for $\mathbf{RX}(\theta_k)$
- **Amplitude embedding**: params for each pure state
- Hybrid classical-quantum computing
![[Screenshot 2026-09-10 at 11.41.58 AM.png]] _Figure 20: Hybrid system — Classical data → Quantum state |ψ⟩ → Parameterized quantum circuit Ψ(Θ) → Measurement → Loss function L (compared against Gold standard) → feeds back into Parameter Optimization → adjusts Θ_
> This mirrors classical machine learning almost exactly: you have trainable parameters (rotation angles here, instead of neural network weights), a forward pass through a circuit, a loss comparing to ground truth, and an optimization loop that nudges parameters to reduce that loss.
## Quantum Neural Networks
![[Screenshot 2026-09-10 at 11.43.55 AM.png]]
- **Quantum perceptron**
![[image-37]] _Diagram: inputs |x₁⟩, |x₂⟩, |x₃⟩ each pass through RX(θ₁), RX(θ₂), RX(θ₃) then combine (⊗) into output |y₁,y₂,y₃⟩; "Rotations = nonlinear activation functions"_
- **Quantum multilayer perceptrons**
![[image-38]] _Diagram: Training dataset (x₁,...,x_N) → feed-forward (FF) → parameter θ_k → quantum embedding Λ(θ) + Basic Entangler Layer (BEL) circuit on qubits |0⟩ → measured expectations ⟨Z⁽¹⁾⟩...⟨Z⁽ᴸ⁾⟩ (each between -1 and 1) → FF → prediction ŷ_k_
- **Quantum deep NNs**
![[image-39]] _"HYBRID" diagram: Input layer (features, green circles) → Hidden 1 through Hidden n (orange circles labeled θ) → Output layer (red circles)_
- **Backpropagation**
![[image-40]] _Diagram: a multi-layer network (Input → Hidden 1,2,3 → Output) producing outputs 0.25 and 0.75, compared against gold-standard labels 0 and 1, computing Loss (MSE) = [(0.25-0)² + (0.75-1)²]/2, with an arrow showing weights being adjusted backward through the network to minimize loss_
$$ \text{Loss (MSE)} = \frac{(0.25-0)^2 + (0.75-1)^2}{2} $$
> A "quantum perceptron" swaps the classical neuron's nonlinear activation function (like sigmoid or ReLU) for a rotation gate — the rotation angle acts similarly to a weight, and applying it introduces the nonlinearity needed for learning complex patterns.
## Variational Quantum Eigensolver (VQE)
- We want to minimize a loss Hamiltonian defined on qubit expectations
$$ L(\Theta) = f\left(\langle \mathbf{Z}^{(\psi_1)}\rangle, \ldots, \langle \mathbf{Z}^{(\psi_L)}\rangle\right) $$
- **Parameter shift rule**: Computing gradient for SGD by shifting $\Theta$ by $\pi/2$
$$ \boxed{\frac{\partial}{\partial \Theta}L(\Theta) = \frac{1}{2}\left(L\left(\Theta + \frac{\pi}{2}\right) - L\left(\Theta - \frac{\pi}{2}\right)\right)} $$
![[Screenshot 2026-09-10 at 11.44.15 AM.png]] _Diagram: Classical data → Quantum state |ψ⟩ → Parameterized Hamiltonian Ĥ(Θ) → Measurement → Ground energy E₀ (lowest eigenvalue) → compared with Gold standard → Parameter Optimization loop feeding back into the quantum part_
- **NFT Algorithm**: Gradually re-estimating each parameter at timestep $t$
$$ \theta_j^{(t+1)} = -\frac{\pi}{2} - \arctan\frac{y_j^{(t)} - z_j^{(t)}}{2x_j^{(t)} - y_j^{(t)} - z_j^{(t)}} $$
where
$$ x_j^{(t)} = L(\Theta^{(t)}|\theta_j = \theta_j^{(t)}) \qquad y_j^{(t)} = L\left(\Theta^{(t)}\Big|\theta_j = \theta_j^{(t)} + \frac{\pi}{2}\right) \qquad z_j^{(t)} = L\left(\Theta^{(t)}\Big|\theta_j = \theta_j^{(t)} - \frac{\pi}{2}\right) $$
- Both methods converge very fast
> The parameter-shift rule is a clever quantum-specific trick for computing gradients — instead of the classical calculus approach (infinitesimally small steps), it evaluates the loss at exactly two points shifted by 90° and takes their difference, which happens to give an _exact_ gradient for these rotation-based circuits (not just an approximation).
## Quantum Approximate Optimization Algorithm (QAOA)
- **Quantum annealing** consists of two steps:
- **Mixer**: explore the transverse field to improve coverage
- **Loss**: identify the globally optimal point in the explored transverse field
![[image-42]] _Graph showing energy E vs. transverse field S — an oscillating orange curve trending downward as it explores various energy levels, converging toward the dotted global-minimum line_
- Objective function = $N$ layers of mixer Hamiltonian $\hat{\mathbf{H}}_M$ + loss Hamiltonian $\hat{\mathbf{H}}_L$
![[image-43]] _Circuit: qubits start at |+⟩, alternate through N layers of [loss: cis(−p₁Ĥ_L), mixer: cis(−m₁Ĥ_M)] ... [loss: cis(−p_NĤ_L), mixer: cis(−m_NĤ_M)], ending in measurement of ground energy ⟨E₀⟩; parameters (p, m, Θ) optimized in a feedback loop_
> Think of QAOA like alternating between "exploring" (the mixer, which spreads possibilities around, like shaking a snow globe) and "settling" (the loss step, which nudges toward good solutions, like gravity pulling snow down). Repeating this alternation, tuned by optimized parameters, approximates quantum annealing without needing continuous-time evolution hardware.
## QAOA: Quadratic Unbounded Binary Optimization (QUBO)
- Each edge $(i,j)$ becomes a model parameter $\theta_{ij}$
- Loss function:
$$ \boxed{L = \sum_{(i,i) \in E} \frac{\theta_{ii}}{2}Z_i + \sum_{(i,j) \in E} \frac{\theta_{ij}}{2}Z_iZ_j} $$
![[image-44]] _Left: a small graph with 6 nodes (1-6) and labeled edges θ₁₁, θ₁₂, θ₂₃, θ₃₃, θ₆₁, θ₃₆, θ₅₁, θ₆₅, θ₄₆, θ₃₄. Right: corresponding circuit on 6 qubits (all starting at |+⟩) with ZZ(θ) two-qubit Ising gates for each edge and RZ(θ) single-qubit gates for self-loops, ending in measured expectations Z₁ through Z₆_
- **Ising gates** rotate both input qubits with the same phase $\theta$ — types: XX(θ), YY(θ), ZZ(θ), XY(θ)
> QUBO is a way of encoding "which items to pick from a set" optimization problems as a graph, where each edge's weight represents how compatible/incompatible two choices are. QAOA then searches for the qubit configuration (0s and 1s) that minimizes this weighted energy — effectively solving a combinatorial optimization problem using interference and rotation.
## QAOA: Max-Cut as a QUBO Problem
- Graph-coloring problem where the number of edges between two colors is maximum
![[image-45]] _Five small graphs (nodes 1-5) showing progressively better cuts: 00000 (Cut=0), 00001 (Cut=1), 00010 (Cut=2), 01000 (Cut=3), 01010 (Cut=4) — colored nodes (green) vs. uncolored (orange), with cut edges highlighted in blue_
- **Mixer Hamiltonian**: X-mixer applies bit-flipping between 0 and 1 on each qubit
$$ \hat{\mathbf{H}}_M = \sum_{j=1}^{N} X_j $$
- **Loss Hamiltonian**: The more adjacent nodes of different colors, the less loss
$$ \hat{\mathbf{H}}_L = \sum_{i,j \in E} Z_iZ_j $$
> Max-Cut asks: "split the nodes of a graph into two groups so that the number of edges crossing between the groups is maximized." Each bitstring is a way to 2-color the nodes; QAOA searches for the coloring that maximizes the cut using quantum interference instead of brute-force enumeration.
---
# 7. Conclusion
## What Problems are Suitable for Quantum Computers?
![[image-46]] _Figure 21: Quantum-suitable problems — a collage of icons/diagrams representing: Extreme parallelization (bitstrings 00000000 through 11111111), Information search, Phase estimation, Deep learning with adaptive activation functions (fruit classifier → "Lime 85%"), Graph-based optimization, Parallelizable simulation (finite state machine for a vending machine), Secure communication and cryptography, Error correction (grid of surface-code-like qubit patterns with X/Z stabilizers), Spectral analysis (spectrogram)_
- Superposition allows quantum computers to perform independent tasks at the same time
- Entanglement fortifies the security of data communication
- The output will be a probability distribution of possible outputs
- **Warning**: Quantum computers work on complex matrices and eigen-decomposition
> In short: quantum computers aren't simply "faster classical computers" — they're a fundamentally different computational paradigm suited to specific problem shapes (search, optimization, simulation of quantum systems, cryptography-related number theory). The trade-off is that outputs are inherently probabilistic, and harnessing the speedup requires careful algorithm design (oracle construction, interference engineering) rather than just "running your existing code on quantum hardware."