⚛️ Quantum Computing
Meri Complete Notes

Hinglish mein | First Principles se | Bilkul Start se
Teri apni notebook — kuch bhi yaad nahin karna, sab yahan hai 📖


🌌 Shuruat: Quantum Computing Kyun Seekhein?

Ek chhoti si kahani se shuruat karte hain...

Sochiye ek lock hai jisme 1 crore crore combinations hain. Classical computer — jo aaj ke laptops aur phones hain — ek-ek combination try karega. Lakho saal lag sakte hain.

Quantum computer? Woh ek saath sab combinations try kar sakta hai. Seconds mein kaam hoga.

Yahi quantum computing ka jaadu hai. Aur ye "jaadu" pure science aur math pe based hai. Chalo samajhte hain!

Is course mein hum seekhenge:


⚛️ Chapter 1: Classical vs Quantum — Kya Fark Hai?

Classical Bit — Binary Ki Duniya

Aaj ke har computer (laptop, phone, calculator) ka basic building block ek transistor hai. Transistor basically ek switch hai — ya ON hai ya OFF.

📝 Bit: Ek classical bit ya toh 0 hota hai ya 1. ON ya OFF. Haan ya Naa. Koi beech ki cheez nahi.
🪙 Analogy: Ek sikka (coin) table pe rakha hai — ya Heads hai ya Tails. Ek waqt mein ek hi side upar hogi.

2 bits → 4 possibilities: 00, 01, 10, 11. Lekin ek waqt mein classical computer sirf ek state mein hota hai.

Qubit — Superposition Ki Duniya

🔥 Qubit ki khasiyat: Ek qubit ek saath 0 bhi ho sakta hai aur 1 bhi! Jab tak hum use measure (dekho) na karein. Ise superposition kehte hain.
🪙 Analogy: Coin ko hawa mein uchhalo — ghoom raha hai, tab woh Heads bhi hai aur Tails bhi hai ek saath. Jab haath se pakad lete ho — tabhi decide hota hai kya aayega. Measure karna = coin pakadna hai!
Classical Bit 0 OR 1 Qubit (Superposition) 0 AND 1 simultaneously!

Classical bit: ek waqt mein sirf ek. Qubit: dono ek saath (jab tak measure na karo)!

Quantum Computing Itna Powerful Kyun?

3 qubits simultaneously 2³ = 8 states explore kar sakte hain. n qubits → 2ⁿ states!

Qubits (n)Simultaneous States (2ⁿ)Kya matlab?
122 states ek saath
101,024Hazaar states ek saath!
50~10¹⁵ (1 Quadrillion)Classical computer ki limit!
30010⁹⁰Universe mein atoms se bhi zyada!
💡 Quantum computer sab kuch "simultaneously" explore karta hai — lekin smart algorithms chahiye jo sahi answer ko amplify (bada) karein aur galat answers ko cancel karein. Yahi quantum algorithms ka kaam hai!

Qubit Physically Kya Hota Hai?

🌡️ Superconducting Qubit (IBM, Google)

Kya hai: Ek tiny electronic circuit jo superconductor se bana hai.
Temperature: -273.14°C (0.015 Kelvin) — outer space se 100x thanda!
Kyun itna thanda: Room temperature pe thermal vibrations qubit disturb kar dete. Itna thanda karo ki sab vibrations freeze ho jayein.
|0⟩ aur |1⟩: Circuit ka low energy state = |0⟩, high energy state = |1⟩.

⚡ Trapped Ion Qubit (IonQ, Quantinuum)

Kya hai: Real atoms (Ytterbium Ya+) jo electromagnetic fields se trap hote hain.
|0⟩ aur |1⟩: Atom ke do energy levels.
Advantage: Coherence time minutes tak — superconducting se 1000x longer!
Disadvantage: Gate operations slower hain.


📐 Chapter 2: Math Ki Neenv — Quantum Ki Language

Bhai, seedha keh deta hoon — Quantum Computing mein math hai. Complex numbers, matrices, vectors. Lekin darona mat — main tujhe ek ek cheez itne simple tarike se samjhaunga ki tu sochega "yaar yeh toh aasaan tha!" 😄

🔢 Complex Numbers — Quantum Ka Alphabet

Normal Numbers se Aage

Real numbers toh jaante ho: 1, 2, -5, 3.14, √2.
Problem: x² = -1 ka koi solution nahi tha real numbers mein.
Mathematicians ne ek naya symbol define kiya:

📝 i = √(-1) — imaginary unit. i² = -1.
Complex Number: z = a + bi Jahan: a = real part, b = imaginary part, i = √(-1) Example: z = 3 + 4i (real part = 3, imaginary part = 4) i ki powers — ek cycle hain: i⁰ = 1 i¹ = i i² = -1 (kyunki i × i = √(-1) × √(-1) = -1) i³ = -i (= i² × i = -1 × i) i⁴ = 1 (= i² × i² = (-1)×(-1) = 1 ← wapas shuruat!) i⁵ = i ... phir repeat
Real Imag 1 (i⁰) i (i¹) -1 (i²) -i (i³) × i = 90° rotate!

Complex numbers ek 2D plane pe hote hain. i se multiply = 90° counterclockwise rotate. Yahi quantum phase hai!

Polar Form — Phase Angle

Euler's formula (CRUCIAL): e^(iφ) = cos(φ) + i·sin(φ) Important values: e^(i·0) = 1 (phase = 0°) e^(iπ/2) = i (phase = 90°) e^(iπ) = -1 (phase = 180°) ← Euler's famous identity! e^(i3π/2) = -i (phase = 270°) General complex number in polar form: z = r·e^(iφ) r = |z| = modulus/magnitude = √(a² + b²) φ = arg(z) = phase angle

Complex Conjugate aur Modulus — Probability Nikaalne Ka Tool

Complex conjugate: z* = (a + bi)* = a - bi (imaginary part ka sign flip) Examples: (3 + 4i)* = 3 - 4i (2i)* = -2i e^(iφ)* = e^(-iφ) Modulus squared: |z|² = z × z* = (a + bi)(a - bi) = a² + b² Examples: |3 + 4i|² = 9 + 16 = 25 |i|² = 0 + 1 = 1 |e^(iφ)|² = 1 (ALWAYS! e^(iφ) ka magnitude hamesha 1 hota hai)
🔑 Quantum connection: Agar state ki amplitude α hai, toh probability = |α|². Yahi Born Rule ka core hai!

📊 Vectors aur Bra-Ket Notation

Quantum physicists ki ek special notation hai — Dirac Notation (Bra-Ket). Bahut elegant aur convenient!

Ket — Column Vector

|ψ⟩ = "ket psi" = column vector (quantum state) Two basis states: |0⟩ = [1] (ket zero) [0] |1⟩ = [0] (ket one) [1] General qubit state: |ψ⟩ = [α] = α|0⟩ + β|1⟩ [β] α, β are complex numbers called "amplitudes"

Bra — Row Vector (Conjugate Transpose)

⟨ψ| = "bra psi" = row vector = (|ψ⟩)† (conjugate transpose) If |ψ⟩ = [α] then ⟨ψ| = [α*, β*] [β] ⟨0| = [1, 0] ⟨1| = [0, 1] Bra-ket = "bracket": "Bra" + "|" + "ket" = "bracket" — Dirac ka wordplay! 😄

Inner Product — ⟨a|b⟩

⟨a|b⟩ = row × column = scalar (ek single number) ⟨0|0⟩ = [1, 0] × [1] = 1×1 + 0×0 = 1 ✓ (normalized) [0] ⟨1|1⟩ = [0, 1] × [0] = 0×0 + 1×1 = 1 ✓ (normalized) [1] ⟨0|1⟩ = [1, 0] × [0] = 1×0 + 0×1 = 0 ✓ (orthogonal — perpendicular!) [1] ⟨1|0⟩ = [0, 1] × [1] = 0×1 + 1×0 = 0 ✓ (orthogonal) [0] Conclusion: {|0⟩, |1⟩} ek orthonormal basis banaate hain — bilkul X-axis aur Y-axis jaisi!

Outer Product — |a⟩⟨b|

|a⟩⟨b| = column × row = matrix! |0⟩⟨0| = [1]×[1, 0] = [1 0] (projector onto |0⟩) [0] [0 0] |1⟩⟨1| = [0]×[0, 1] = [0 0] (projector onto |1⟩) [1] [0 1] Important identity (completeness relation): |0⟩⟨0| + |1⟩⟨1| = [1 0] + [0 0] = [1 0] = I [0 0] [0 1] [0 1] "Basis vectors span the full space" — mathematical expression!

🔮 Hermitian Matrices — Observable Quantities

📝 Hermitian Matrix: A† = A (conjugate transpose = itself)
Hermitian check on Z gate: Z = [1 0] [0 -1] Z† = (Zᵀ)* = ([1 0])* = [1* 0* ] = [1 0] = Z ✓ ([0 -1]) [0* (-1)*] [0 -1] Z is Hermitian!
🔑 3 Magical Properties of Hermitian Matrices:

1. Eigenvalues are ALWAYS REAL
Physical measurements (position, momentum, energy, spin) hamesha real numbers hote hain. Isliye har observable quantum quantity ek Hermitian operator se represent hoti hai!

2. Eigenvectors orthogonal hote hain
Alag eigenvalues ke eigenvectors automatically perpendicular hote hain.

3. Diagonalizable
A = Σᵢ λᵢ|eᵢ⟩⟨eᵢ| — spectral decomposition. Measurement = yahi hai!

Eigenvalues aur Eigenvectors — Kya Hote Hain?

Eigenvalue equation: A|v⟩ = λ|v⟩ Matlab: Matrix A ko vector |v⟩ pe lagao — result SAME DIRECTION mein aata hai, bas scale by factor λ. λ = eigenvalue (ek number) |v⟩ = eigenvector (ek vector) Example — Pauli Z: Z = [1 0] [0 -1] Z|0⟩ = [1 0] × [1] = [1] = 1×|0⟩ → eigenvalue = +1, eigenvector = |0⟩ [0 -1] [0] [0] Z|1⟩ = [1 0] × [0] = [0] = -1×|1⟩ → eigenvalue = -1, eigenvector = |1⟩ [0 -1] [1] [-1] Quantum measurement connection: Jab Z measurement karte hain → outcomes are eigenvalues (+1 or -1) State collapses to corresponding eigenvector (|0⟩ or |1⟩)!

Pauli Matrices — Quantum Ki Superstars

X = [0 1] Y = [0 -i] Z = [1 0] [1 0] [i 0] [0 -1] Sab teen Hermitian hain! (X† = X, Y† = Y, Z† = Z) Sab teen Unitary hain! (X†X = I, Y†Y = I, Z†Z = I) Sab teen self-inverse hain: X² = Y² = Z² = I Cyclic relations: XY = iZ YZ = iX ZX = iY YX = -iZ ZY = -iX XZ = -iY

🔄 Unitary Matrices — Quantum Evolution Ka Rule

📝 Unitary Matrix: U†U = UU† = I
(Inverse = Conjugate Transpose)
Sochiye qubit ki state badalte ho gate se. Baad mein measure karo.
Probabilities ka total HAMESHA 1 hona chahiye — kuch bhi "kho" nahi sakta.

Mathematically: Agar |α|² + |β|² = 1, toh gate U lagane ke baad bhi total = 1 hona chahiye.
Yeh SIRF tab possible hai jab U unitary ho! Unitary = "norm preserve" karti hai.

Isliye: Har quantum gate unitary matrix honi chahiye.
Proof that H is unitary: H = (1/√2)[1 1] [1 -1] H† = (1/√2)[1 1] = H (H is also Hermitian!) [1 -1] H†H = H × H = (1/2)[1 1][1 1] = (1/2)[1+1 1-1] = (1/2)[2 0] = [1 0] = I ✓ [1 -1][1 -1] [1-1 1+1] [0 2] [0 1] Proof complete: H is unitary!
🔑 Key distinction:
Hermitian = describes WHAT we measure (observables)
Unitary = describes HOW state EVOLVES (gates)
Measurement = NOT unitary — irreversible! State collapses.

🎯 Chapter 3: Qubit — Complete Deep Dive

Ek Qubit Ki Complete Mathematical State

General qubit state: |ψ⟩ = α|0⟩ + β|1⟩ Conditions: - α, β are COMPLEX numbers (amplitudes) - |α|² + |β|² = 1 (normalization — total probability = 1!) - P(measuring |0⟩) = |α|² - P(measuring |1⟩) = |β|²

📌 Example 1: Equal Superposition

|ψ⟩ = (1/√2)|0⟩ + (1/√2)|1⟩ = |+⟩ α = 1/√2, β = 1/√2 Normalization check: |α|² + |β|² = (1/√2)² + (1/√2)² = 1/2 + 1/2 = 1 ✓ P(0) = 1/2 = 50% P(1) = 1/2 = 50%

📌 Example 2: Complex Amplitude

|ψ⟩ = (3/5)|0⟩ + (4i/5)|1⟩ α = 3/5, β = 4i/5 Normalization: |α|² = (3/5)² = 9/25 |β|² = |4i/5|² = (4/5)² × |i|² = 16/25 × 1 = 16/25 Total = 9/25 + 16/25 = 25/25 = 1 ✓ P(0) = 9/25 = 36% P(1) = 16/25 = 64%

📌 Example 3: From Lab 8

|ψ⟩ = (1/√5)(|0⟩ + 2i|1⟩) α = 1/√5, β = 2i/√5 |α|² = 1/5 = 20% |β|² = |2i/√5|² = 4/5 = 80% Total = 1/5 + 4/5 = 1 ✓

🌍 Bloch Sphere — Qubit Ka GPS

Kisi bhi qubit state ko ek 3D sphere ke surface pe ek point se represent kar sakte hain — yeh sphere Bloch Sphere kehlati hai.

General state in Bloch sphere form: |ψ⟩ = cos(θ/2)|0⟩ + e^(iφ)·sin(θ/2)|1⟩ θ (theta) = polar angle [0 to π] (north-south position) φ (phi) = azimuthal angle [0 to 2π] (east-west position, rotation around Z axis)
|0⟩ (North Pole) |1⟩ (South Pole) |+⟩ |−⟩ θ/2 |ψ⟩ φ

Bloch Sphere — har qubit state ek point hai is sphere pe!
Gates = sphere pe rotations

StateθφLocationVector form
|0⟩0anyNorth Pole[1, 0]ᵀ
|1⟩πanySouth Pole[0, 1]ᵀ
|+⟩π/20+X axis(|0⟩+|1⟩)/√2
|−⟩π/2π-X axis(|0⟩-|1⟩)/√2
|+i⟩π/2π/2+Y axis(|0⟩+i|1⟩)/√2
|-i⟩π/23π/2-Y axis(|0⟩-i|1⟩)/√2
💡 Gates = Rotations on Bloch Sphere!
X gate = π rotation around X-axis | Y gate = π around Y | Z gate = π around Z | H gate = swaps X and Z axes

🌊 Chapter 4: Phase Ka Jaadu — Global vs Relative Phase

Yeh chapter quantum mein sabse mind-bending concepts mein se ek hai. Dhyan se padho — ek baar samajh gaye toh quantum computing ka sabse important "engine" (interference) samajh aa jayega!

Global Phase — "Invisible" Phase

📝 Global Phase: Jab poori state ko ek phase factor e^(iθ) se multiply karo.
|ψ'⟩ = e^(iθ)|ψ⟩ — yeh PHYSICALLY same state hai! Koi bhi measurement inka fark nahi bata sakta.

Proof — Step by Step

Original state: |ψ⟩ = α|0⟩ + β|1⟩ Modified state: |ψ'⟩ = e^(iθ)|ψ⟩ = e^(iθ)α|0⟩ + e^(iθ)β|1⟩ Measurement probability of |0⟩: From |ψ⟩: P(0) = |⟨0|ψ⟩|² = |α|² From |ψ'⟩: P(0) = |⟨0|ψ'⟩|² = |e^(iθ)α|² = |e^(iθ)|² × |α|² = 1 × |α|² = |α|² Exactly the same! Because |e^(iθ)|² = 1 ALWAYS. This holds for ANY gate, ANY measurement → global phase is UNDETECTABLE.

📌 Global Phase Examples

|0⟩ and -|0⟩ → SAME physical state (global phase = e^(iπ) = -1) |0⟩ and i|0⟩ → SAME physical state (global phase = e^(iπ/2) = i) (|0⟩+|1⟩)/√2 and -(|0⟩+|1⟩)/√2 → SAME state! (global phase = -1) (3|0⟩+4i|1⟩)/5 and e^(iπ/4)×(3|0⟩+4i|1⟩)/5 → SAME state!
🔑 Practical consequence: Circuit compute karte waqt agar koi global phase (-1, i, e^(iθ)) bacha reh jaata hai — use IGNORE kar sakte hain! Labs mein iska bohot use hota hai.

Relative Phase — Iska Fark Padta Hai!

📝 Relative Phase: Alag components ka phase alag hona.
α|0⟩ + β|1⟩ mein relative phase = arg(β) - arg(α)
Yeh DETECTABLE hai — aur quantum computing ka engine hai!

📌 |+⟩ vs |−⟩ — Same probabilities, DIFFERENT states!

|+⟩ = (|0⟩ + |1⟩)/√2 relative phase of |1⟩ = 0° |−⟩ = (|0⟩ - |1⟩)/√2 relative phase of |1⟩ = 180° Z-basis (normal) measurement: P(0) = P(1) = 50% for BOTH → Cannot distinguish! X-basis measurement (apply H first, then measure): H|+⟩ = |0⟩ → always get 0! H|−⟩ = |1⟩ → always get 1! So in X-basis they ARE different! Relative phase is detectable with the RIGHT measurement.

📌 Lab 3: S gate ka effect — HSH circuit

Start: |0⟩ Step 1 — Apply H: |ψ₁⟩ = H|0⟩ = (|0⟩ + |1⟩)/√2 (|+⟩ state) Step 2 — Apply S gate [S = [[1,0],[0,i]]]: S leaves |0⟩ alone, adds i phase to |1⟩: |ψ₂⟩ = S|ψ₁⟩ = (|0⟩ + i|1⟩)/√2 Relative phase now = 90° (from i = e^(iπ/2)) Step 3 — Apply H again: H(|0⟩ + i|1⟩)/√2 = (H|0⟩ + i×H|1⟩)/√2 H|0⟩ = (|0⟩+|1⟩)/√2 H|1⟩ = (|0⟩-|1⟩)/√2 H(i|1⟩) = i×(|0⟩-|1⟩)/√2 Final state = [(|0⟩+|1⟩)/√2 + i(|0⟩-|1⟩)/√2] / √2 = [(1+i)|0⟩ + (1-i)|1⟩] / 2 P(0) = |(1+i)/2|² = (1² + 1²)/4 = 2/4 = 1/2 = 50% ✓ P(1) = |(1-i)/2|² = 2/4 = 1/2 = 50% ✓ Compare: Z instead of S in same circuit (HZH): H|0⟩ = |+⟩, Z|+⟩ = |−⟩, H|−⟩ = |1⟩ → ALWAYS get 1! (100% not 50%) → HUGE difference! S gate aur Z gate ka effect bilkul alag hai even though both change relative phase.

🌊 Interference — Relative Phase Ka Jaadu

Yeh concept physics mein waves se aata hai. Light waves, water waves — jab do waves milti hain ya toh strengthen (constructive interference) karti hain ya cancel (destructive interference). Quantum mein amplitudes ke saath exactly yahi hota hai!
Constructive Interference Same phase → BIGGER amplitude! Destructive Interference Opposite phase → ZERO! Cancelled!

Constructive: amplitudes add → bigger probability. Destructive: amplitudes cancel → zero probability. Quantum algorithms exploit this!

📌 Perfect Example: H|+⟩ = |0⟩ (NOT random!)

Start: |+⟩ = (|0⟩ + |1⟩)/√2 Apply H: H|+⟩ = H(|0⟩ + |1⟩)/√2 = (H|0⟩ + H|1⟩)/√2 = ((|0⟩+|1⟩)/√2 + (|0⟩-|1⟩)/√2) / √2 = (2|0⟩/√2) / √2 = |0⟩ Let's understand WHAT HAPPENED: - Amplitude for |0⟩ from H|0⟩: +1/√2 - Amplitude for |0⟩ from H|1⟩: +1/√2 - Total |0⟩ amplitude: +1/√2 + 1/√2 = 2/√2 = √2 → normalize → 1 → CONSTRUCTIVE INTERFERENCE! P(0) = 1 = 100% - Amplitude for |1⟩ from H|0⟩: +1/√2 - Amplitude for |1⟩ from H|1⟩: -1/√2 - Total |1⟩ amplitude: 1/√2 - 1/√2 = 0 → DESTRUCTIVE INTERFERENCE! P(1) = 0 = 0% H|+⟩ = |0⟩ ALWAYS! (Not random at all — interference made it deterministic!)
🔑 Why interference matters for Quantum Algorithms:
Grover's, Shor's — sab mein yahi principle:
1. Superposition mein dalo (explore all answers)
2. Wrong answers ko destructively interfere karao (cancel them)
3. Right answer ko constructively interfere karao (amplify it)
4. Measure karo → almost certainly sahi answer milega!

⚡ Chapter 5: Quantum Gates — State Badalne Ka Tarika

Classical circuit mein NOT gate, AND gate, OR gate hote hain.
Quantum circuit mein: X, Y, Z, H, S, T, CNOT, CZ, SWAP...
Har gate ek UNITARY matrix hai. Lagao qubit pe → state change hoti hai.
Chalo ek ek gate ekdam clearly samjhte hain!

X Gate — Quantum NOT

Matrix: X = [0 1] [1 0] Actions (full calculation): X|0⟩ = [0 1]×[1] = [0×1+1×0] = [0] = |1⟩ (0 → 1 !) [1 0] [0] [1×1+0×0] [1] X|1⟩ = [0 1]×[0] = [0×0+1×1] = [1] = |0⟩ (1 → 0 !) [1 0] [1] [1×0+0×1] [0] On general state: X(α|0⟩ + β|1⟩) = α×X|0⟩ + β×X|1⟩ = α|1⟩ + β|0⟩ = β|0⟩ + α|1⟩ → Amplitudes SWAP! α goes to |1⟩ slot, β goes to |0⟩ slot. On superposition: X|+⟩ = X(|0⟩+|1⟩)/√2 = (X|0⟩+X|1⟩)/√2 = (|1⟩+|0⟩)/√2 = |+⟩ → |+⟩ is UNCHANGED! It's an eigenstate of X (eigenvalue +1) X|−⟩ = X(|0⟩-|1⟩)/√2 = (|1⟩-|0⟩)/√2 = -(|0⟩-|1⟩)/√2 = -|−⟩ → Gets global phase -1. Physically same as |−⟩. Eigenvalue = -1. Properties: X² = I | Hermitian ✓ | Unitary ✓
Circuit Symbol
──|q⟩──[X]── (Bloch sphere: π rotation around X-axis)

Y Gate — Bit Flip + Phase Flip

Matrix: Y = [0 -i] [i 0] Actions: Y|0⟩ = [0 -i]×[1] = [0×1+(-i)×0] = [ 0] = i|1⟩ (adds i phase AND flips) [i 0] [0] [i×1+ 0×0 ] [ i] Y|1⟩ = [0 -i]×[0] = [0×0+(-i)×1] = [-i] = -i|0⟩ (adds -i phase AND flips) [i 0] [1] [i×0+ 0×1 ] [ 0] On general state: Y(α|0⟩ + β|1⟩) = iα|1⟩ - iβ|0⟩ = -iβ|0⟩ + iα|1⟩ Y = iXZ (interesting decomposition) Y² = I | Hermitian ✓ | Unitary ✓ Bloch sphere: π rotation around Y-axis

Z Gate — Phase Flip

Matrix: Z = [1 0] [0 -1] Actions: Z|0⟩ = [1 0]×[1] = [1] = |0⟩ (|0⟩ UNCHANGED) [0 -1] [0] [0] Z|1⟩ = [1 0]×[0] = [ 0] = -|1⟩ (|1⟩ gets minus sign) [0 -1] [1] [-1] On general state: Z(α|0⟩ + β|1⟩) = α|0⟩ + (-β)|1⟩ = α|0⟩ - β|1⟩ On superposition: Z|+⟩ = Z(|0⟩+|1⟩)/√2 = (|0⟩-|1⟩)/√2 = |−⟩ (swaps |+⟩ ↔ |−⟩!) Z|−⟩ = (|0⟩+|1⟩)/√2 = |+⟩ Z² = I | Hermitian ✓ | Unitary ✓
🔑 Key: Z gate Z-basis mein kuch NAHI karta (probabilities same). Lekin H ke baad (X-basis mein) effect clear hota hai. Isliye "phase gate" — sirf relative phase badalta hai.

H Gate — Hadamard — THE SUPERPOSITION CREATOR

Matrix: H = (1/√2)×[1 1] = [1/√2 1/√2] [1 -1] [1/√2 -1/√2] Actions: H|0⟩ = (1/√2)(|0⟩ + |1⟩) = |+⟩ (computational basis → superposition!) H|1⟩ = (1/√2)(|0⟩ - |1⟩) = |−⟩ (1 → superposition with phase!) Reverse (very important!): H|+⟩ = |0⟩ (H undoes H!) H|−⟩ = |1⟩ H² = I (two H gates = nothing! H is its own inverse!) On general state: H(α|0⟩ + β|1⟩) = α×H|0⟩ + β×H|1⟩ = α(|0⟩+|1⟩)/√2 + β(|0⟩-|1⟩)/√2 = ((α+β)/√2)|0⟩ + ((α-β)/√2)|1⟩ Hermitian ✓ (H† = H) AND Unitary ✓ (H²= I, so H⁻¹ = H = H†)
Before H |0⟩ P(0)=100%, P(1)=0% →H→ After H (|0⟩ + |1⟩)/√2 SUPERPOSITION! P(0)=50%, P(1)=50%

Hadamard: definite state → superposition. Every quantum algorithm isse shuru karta hai!

🧠 Try It!

Q: H|+⟩ ka calculation karo step by step
|+⟩ = (|0⟩+|1⟩)/√2 H|+⟩ = H × (|0⟩+|1⟩)/√2 = (H|0⟩ + H|1⟩)/√2 = (|+⟩ + |−⟩)/√2 = ((|0⟩+|1⟩)/√2 + (|0⟩-|1⟩)/√2) / √2 = (2|0⟩/√2) / √2 = |0⟩ H|+⟩ = |0⟩ ✓ (H is its own inverse!)
Q: HXH = ? (Famous result!)
HXH = ? Method: Check action on basis states. HXH|0⟩ = HX|+⟩ = H|+⟩ = |0⟩ (since X|+⟩=|+⟩) Wait, let me reconsider: X|+⟩ = |+⟩ So HXH|0⟩ = H(X(H|0⟩)) = H(X|+⟩) = H|+⟩ = |0⟩ HXH|1⟩ = H(X(H|1⟩)) = H(X|−⟩) = H(-|−⟩) = -H|−⟩ = -|1⟩ So HXH = Z! (maps |0⟩→|0⟩, |1⟩→-|1⟩ = exactly what Z does!) Similarly: HZH = X Insight: H swaps X↔Z axes on the Bloch sphere! This is why measuring in X-basis = apply H then measure in Z-basis.

S Gate — π/2 Phase Gate

Matrix: S = [1 0] [0 i] Actions: S|0⟩ = [1 0]×[1] = [1] = |0⟩ (unchanged) [0 i] [0] [0] S|1⟩ = [1 0]×[0] = [0] = i|1⟩ (adds i = e^(iπ/2) phase to |1⟩) [0 i] [1] [i] General state: S(α|0⟩ + β|1⟩) = α|0⟩ + iβ|1⟩ S² = Z (two S = Z gate! Phase doubles: 90° × 2 = 180° = Z) Bloch sphere: π/2 rotation around Z-axis

T Gate — π/4 Phase Gate

Matrix: T = [1 0 ] [0 e^(iπ/4) ] e^(iπ/4) = cos(45°) + i×sin(45°) = (1+i)/√2 ≈ 0.707 + 0.707i Actions: T|0⟩ = |0⟩ T|1⟩ = e^(iπ/4)|1⟩ (adds 45° phase to |1⟩) T² = S (phase doubles: 45° × 2 = 90° = S) S² = Z (90° × 2 = 180° = Z) T⁴ = Z T⁸ = I The Tower: T (45°) → T²=S (90°) → S²=Z (180°) → Z²=I (360°) Universal Gate Set: {H, T} + CNOT → can approximate ANY quantum operation!
T 45° T²= S 90° S²= Z 180° Z²= I 360°

T → S → Z → I: Phase doubles har step mein. Ek complete circle!

All Gates Summary

GateMatrix|0⟩ pe|1⟩ peBloch Rotation
X[[0,1],[1,0]]|1⟩|0⟩π around X
Y[[0,-i],[i,0]]i|1⟩-i|0⟩π around Y
Z[[1,0],[0,-1]]|0⟩-|1⟩π around Z
H(1/√2)[[1,1],[1,-1]]|+⟩|−⟩π around (X+Z)/√2
S[[1,0],[0,i]]|0⟩i|1⟩π/2 around Z
T[[1,0],[0,e^(iπ/4)]]|0⟩e^(iπ/4)|1⟩π/4 around Z

🎲 Chapter 6: Born Rule — Measurement Ka Science

|ψ⟩ = α|0⟩ + β|1⟩ mein DONO 0 aur 1 hain. Jab measure karte hain — sirf ek result aata hai. Lekin kaunsa? Aur kyun?

1926 mein Max Born ne yeh rule diya. Iske liye 1954 mein Nobel Prize mila!
📝 Born Rule:
State |ψ⟩ = α|0⟩ + β|1⟩ ko measure karo:
• P(0) = |α|² = |⟨0|ψ⟩|²
• P(1) = |β|² = |⟨1|ψ⟩|²
• After measurement → state COLLAPSES to what you measured (irreversible!)
Example: |ψ⟩ = (3/5)|0⟩ + (4/5)|1⟩ Before measurement: P(0) = |3/5|² = 9/25 = 36% P(1) = |4/5|² = 16/25 = 64% Say we get result '1' (with 64% probability): After measurement → state = |1⟩ (collapsed!) Now P(0) = 0%, P(1) = 100% Measure again → ALWAYS get 1 (no more randomness) What if we got '0'? → state = |0⟩, always 0 from now on.

Why Collapse? — The Deep Question

Quantum mechanics ka sabse controversial question! Alag interpretations hain:

🌍 Copenhagen: Measurement = wavefunction collapse. Pehle koi "real state" nahi thi.
🌌 Many-Worlds: State collapse nahi hoti. Universe branch ho jaata hai — ek mein 0, doosre mein 1.
📐 Relational QM: State collapse "relative to observer" hai.

Is course mein Copenhagen interpretation use karte hain (practical purposes ke liye). Philosophy baad mein! 😄

General Born Rule

State in any basis {|e₁⟩, |e₂⟩, ..., |eₙ⟩}: |ψ⟩ = c₁|e₁⟩ + c₂|e₂⟩ + ... + cₙ|eₙ⟩ P(getting eₖ) = |⟨eₖ|ψ⟩|² = |cₖ|² After getting eₖ → state collapses to |eₖ⟩ Normalization ensures: Σₖ |cₖ|² = 1 (probabilities sum to 1 ✓)

Expectation Value — Average of Many Measurements

⟨M⟩ = ⟨ψ|M|ψ⟩ = Σₖ mₖ × P(mₖ) Example: ⟨Z⟩ for |+⟩: Z eigenvalues: +1 (for |0⟩), -1 (for |1⟩) |+⟩: P(0)=1/2, P(1)=1/2 ⟨Z⟩ = (+1)×(1/2) + (-1)×(1/2) = 0 Average Z-measurement on |+⟩ = 0 (equal mix of +1 and -1)
💡 Why 1000 shots? Each measurement = ONE random result. 1000 shots → ~50/50 distribution confirmed statistically. Error ≈ 1/√shots = 1/√1000 ≈ 3%.

🔗 Chapter 7: Multi-Qubit Systems

Tensor Product (⊗) — Qubits Ko Milane Ka Tarika

Classical mein 2 bits: simply side-by-side likhte hain "01" ya "10".
Quantum mein 2 qubits combine karne ke liye tensor product (⊗) use karte hain. Yeh mathematical operation hai jo dono qubits ki full information capture karta hai.
Two vectors ka tensor product: [a] [c] [a×c] [b] ⊗ [d] = [a×d] [b×c] [b×d] Computational basis states: |0⟩⊗|0⟩ = [1]⊗[1] = [1×1] = [1] = |00⟩ [0] [0] [1×0] [0] [0×1] [0] [0×0] [0] |0⟩⊗|1⟩ = [1]⊗[0] = [1×0] = [0] = |01⟩ [0] [1] [1×1] [1] [0×0] [0] [0×1] [0] |1⟩⊗|0⟩ = [0]⊗[1] = [0×1] = [0] = |10⟩ [1] [0] [0×0] [0] [1×1] [1] [1×0] [0] |1⟩⊗|1⟩ = [0]⊗[0] = [0] = |11⟩ [1] [1] [0] [0] [1]

📌 Lab 6: |+⟩⊗|+⟩ calculate karo

|+⟩ = [1/√2] [1/√2] |+⟩⊗|+⟩ = [1/√2 × 1/√2] [1/2] [1/√2 × 1/√2] = [1/2] = (1/2)(|00⟩+|01⟩+|10⟩+|11⟩) [1/√2 × 1/√2] [1/2] [1/√2 × 1/√2] [1/2] P(00) = P(01) = P(10) = P(11) = 1/4 = 25% Makes sense! Both qubits independent 50/50.
General 2-qubit state: |Ψ⟩ = α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩ = [α, β, γ, δ]ᵀ Normalization: |α|² + |β|² + |γ|² + |δ|² = 1 Probabilities: P(00)=|α|², P(01)=|β|², P(10)=|γ|², P(11)=|δ|² n qubits → 2ⁿ amplitudes! Classical n bits → 1 state (out of 2ⁿ possible) Quantum n qubits → ALL 2ⁿ states simultaneously!

Entanglement — Quantum Ka Sabse Bada Jaadu

Einstein ne ise "spooky action at a distance" kaha.
Usne socha yeh koi measurement bug hai — lekin 2022 Nobel Prize ne experimentally confirm kiya: Entanglement real hai!

Ek qubit measure karo → doosra qubit INSTANTLY correlated result deta hai. Chahe woh Mars pe ho!
📝 Entanglement Test:
|Ψ⟩ = α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩ ke liye:
Product state ↔ αδ = βγ
If αδ ≠ βγ → ENTANGLED!

📌 Examples

(|00⟩+|11⟩)/√2: α=1/√2, β=0, γ=0, δ=1/√2 αδ = 1/2, βγ = 0 → αδ≠βγ → ENTANGLED ✓ (|00⟩+|01⟩)/√2: α=1/√2, β=1/√2, γ=0, δ=0 αδ = 0, βγ = 0 → αδ=βγ → PRODUCT STATE ✓ → Factor: |0⟩⊗(|0⟩+|1⟩)/√2 = |0⟩⊗|+⟩ ✓ (|01⟩+|10⟩)/√2: α=0, β=1/√2, γ=1/√2, δ=0 αδ = 0, βγ = 1/2 → αδ≠βγ → ENTANGLED ✓

📌 What entanglement MEANS

|Φ+⟩ = (|00⟩+|11⟩)/√2 Measure first qubit: 50% → get 0 → state collapses to |00⟩ → second qubit is DEFINITELY 0 50% → get 1 → state collapses to |11⟩ → second qubit is DEFINITELY 1 Even if second qubit is on Mars: Measure first qubit on Earth → second qubit INSTANTLY determined! But: Cannot use for FTL communication (you can't control which result you get).

🔔 Bell States — Maximum Entanglement

4 Bell states (maximally entangled): |Φ+⟩ = (|00⟩+|11⟩)/√2 "Phi plus" |Φ-⟩ = (|00⟩-|11⟩)/√2 "Phi minus" |Ψ+⟩ = (|01⟩+|10⟩)/√2 "Psi plus" |Ψ-⟩ = (|01⟩-|10⟩)/√2 "Psi minus" Properties: - Sab mutually orthogonal (⟨Φ+|Φ-⟩ = 0, etc.) - Yeh 4 states "Bell basis" banate hain - Har ek maximally entangled - Measurement correlations: |Φ+⟩ → same result (00 or 11, each 50%) |Ψ+⟩ → opposite result (01 or 10, each 50%)

📌 Bell State Banana — H + CNOT

Start: |00⟩ Step 1: H on qubit 0: H|0⟩⊗|0⟩ = |+⟩⊗|0⟩ = (|0⟩+|1⟩)/√2 ⊗ |0⟩ = (|00⟩+|10⟩)/√2 Step 2: CNOT (control=0, target=1): CNOT|00⟩ = |00⟩ (control=0, no flip) CNOT|10⟩ = |11⟩ (control=1, flip!) CNOT × (|00⟩+|10⟩)/√2 = (|00⟩+|11⟩)/√2 = |Φ+⟩ ✓ ENTANGLEMENT CREATED!
Bell State Circuit
q0: |0⟩──[H]──●──── | q1: |0⟩────────⊕──── → |Φ+⟩ = (|00⟩+|11⟩)/√2

🚪 Chapter 8: Two-Qubit Gates — 2 Qubits Pe Operate Karo

CNOT Gate — The Most Important 2-Qubit Gate

📝 CNOT = Controlled-NOT
Rule: Agar control = |1⟩ → target flip. Agar control = |0⟩ → kuch nahi.
CNOT|a,b⟩ = |a, a⊕b⟩ (⊕ = XOR) Truth table: |00⟩ → |00⟩ (control=0, no flip) |01⟩ → |01⟩ (control=0, no flip) |10⟩ → |11⟩ (control=1, flip! 0→1) |11⟩ → |10⟩ (control=1, flip! 1→0) Matrix (rows/cols in order |00⟩,|01⟩,|10⟩,|11⟩): CNOT = [1 0 0 0] [0 1 0 0] [0 0 0 1] [0 0 1 0] CNOT² = I (self-inverse, apply twice = nothing)
CNOT on superposition → creates entanglement: Start: |+0⟩ = (|0⟩+|1⟩)/√2 ⊗ |0⟩ = (|00⟩+|10⟩)/√2 CNOT: CNOT|00⟩=|00⟩, CNOT|10⟩=|11⟩ Result: (|00⟩+|11⟩)/√2 = |Φ+⟩ (ENTANGLED!) Reverse: CNOT on entangled state → product state: CNOT|Φ+⟩ = CNOT(|00⟩+|11⟩)/√2 = (|00⟩+|10⟩)/√2 = |+⟩⊗|0⟩ (This is how Bob "decodes" in superdense coding!)

Kronecker Product of Gates

X⊗I (X on first qubit, I on second): = [0×I 1×I] = [0 0 1 0] [1×I 0×I] [0 0 0 1] [1 0 0 0] [0 1 0 0] (X⊗I)|01⟩ = X|0⟩⊗I|1⟩ = |1⟩⊗|1⟩ = |11⟩ ✓ (I⊗X)|01⟩ = I|0⟩⊗X|1⟩ = |0⟩⊗|0⟩ = |00⟩ ✓ KEY: X⊗I ≠ I⊗X (different gates!) IMPORTANT LIMITATION: Gates of form A⊗B CANNOT create entanglement from product states! Entanglement needs genuine 2-qubit gates (CNOT, CZ, SWAP).

CZ Gate — Controlled-Z

CZ rule: only |11⟩ gets a minus sign CZ|00⟩ = |00⟩ CZ|01⟩ = |01⟩ CZ|10⟩ = |10⟩ CZ|11⟩ = -|11⟩ Matrix: diag(1, 1, 1, -1) CZ = [1 0 0 0] [0 1 0 0] [0 0 1 0] [0 0 0 -1] CZ = (I⊗H)·CNOT·(I⊗H) Important: CZ is symmetric — control/target are interchangeable! (Unlike CNOT where order matters) CZ² = I

📌 Lab 7: Apply CZ to (|10⟩+|11⟩)/√2

CZ(|10⟩+|11⟩)/√2 = (CZ|10⟩ + CZ|11⟩)/√2 = (|10⟩ + (-|11⟩))/√2 = (|10⟩ - |11⟩)/√2 = |1⟩⊗(|0⟩-|1⟩)/√2 = |1⟩⊗|−⟩ Phase -1 appeared on the |11⟩ component!

SWAP Gate — Qubits Exchange Karo

SWAP|a,b⟩ = |b,a⟩ SWAP|00⟩ = |00⟩ SWAP|01⟩ = |10⟩ ← swapped! SWAP|10⟩ = |01⟩ ← swapped! SWAP|11⟩ = |11⟩ Matrix: SWAP = [1 0 0 0] [0 0 1 0] [0 1 0 0] [0 0 0 1] SWAP = CNOT(q0→q1) × CNOT(q1→q0) × CNOT(q0→q1) (3 CNOTs = 1 SWAP) Interesting: SWAP|Ψ-⟩ = -|Ψ-⟩ (|Ψ-⟩ is antisymmetric → eigenvalue -1)

Comparison Table

InputX⊗II⊗XCNOTCZSWAP
|00⟩|10⟩|01⟩|00⟩|00⟩|00⟩
|01⟩|11⟩|00⟩|01⟩|01⟩|10⟩
|10⟩|00⟩|11⟩|11⟩|10⟩|01⟩
|11⟩|01⟩|10⟩|10⟩-|11⟩|11⟩

📡 Chapter 9: Superdense Coding — 1 Qubit mein 2 Bits!

Alice ko Bob ko ek message bhejna hai — 2 classical bits (00, 01, 10, ya 11).
Normal mein 2 physical objects bhejna padega.
Superdense coding mein: Sirf 1 qubit bhejo — Bob ko 2 bits milte hain!
Yeh entanglement ki wajah se possible hai.

Protocol Step by Step

Setup

Alice aur Bob pehle ek Bell state share karte hain: |Φ+⟩ = (|00⟩+|11⟩)/√2 Alice ke paas qubit A, Bob ke paas qubit B.

Step 1: Alice encodes her 2-bit message

Message 00 → Apply I → |Φ+⟩ unchanged Message 01 → Apply X → (X⊗I)|Φ+⟩ = (|10⟩+|01⟩)/√2 = |Ψ+⟩ Message 10 → Apply Z → (Z⊗I)|Φ+⟩ = (|00⟩-|11⟩)/√2 = |Φ-⟩ Message 11 → Apply XZ → (XZ⊗I)|Φ+⟩ = -(|01⟩-|10⟩)/√2 ≈ |Ψ-⟩ (global phase)
Alice's MessageAlice AppliesBell State Created
00I (nothing)|Φ+⟩ = (|00⟩+|11⟩)/√2
01X|Ψ+⟩ = (|01⟩+|10⟩)/√2
10Z|Φ-⟩ = (|00⟩-|11⟩)/√2
11XZ (or iY)|Ψ-⟩ = (|01⟩-|10⟩)/√2

Step 2-4: Alice sends qubit, Bob decodes

Step 2: Alice sends her qubit A to Bob (only 1 qubit transmitted!) Step 3-4: Bob applies CNOT then H, then measures: |Φ+⟩ → CNOT → (|00⟩+|10⟩)/√2 = |+⟩⊗|0⟩ → H on first → |0⟩⊗|0⟩ → Measure 00 ✓ |Ψ+⟩ → CNOT → (|01⟩+|11⟩)/√2 = |+⟩⊗|1⟩ → H → |0⟩⊗|1⟩ → Measure 01 ✓ |Φ-⟩ → CNOT → (|00⟩-|10⟩)/√2 = |−⟩⊗|0⟩ → H → |1⟩⊗|0⟩ → Measure 10 ✓ |Ψ-⟩ → CNOT → (|01⟩-|11⟩)/√2 = |−⟩⊗|1⟩ → H → |1⟩⊗|1⟩ → Measure 11 ✓
Complete Superdense Coding Circuit
[Alice] [Alice sends qubit A] [Bob decodes] q0 (A): |0⟩──[H]──●── [Uₘ] ──────────────────●──[H]──[M] | | q1 (B): |0⟩────────⊕── [Bob keeps this] ───────⊕──────[M] Uₘ = I, X, Z, or XZ depending on message (00, 01, 10, 11)
💡 4 Bell states are mutually orthogonal → Bob can perfectly distinguish them → read 2 bits from 1 qubit. Pre-shared entanglement is the quantum resource!

🚀 Chapter 10: Quantum Teleportation — State Ko Teleport Karo!

Alice ke paas ek unknown state |ψ⟩ = α|0⟩ + β|1⟩ hai.
Woh ise Bob tak transfer karna chahti hai — lekin physically qubit nahi bhej sakti.
Solution: Entanglement + 2 classical bits!
Note: Original state destroy ho jaata hai (No-Cloning Theorem).

No-Cloning Theorem

Suppose cloning machine hoti: U|ψ⟩|0⟩ = |ψ⟩|ψ⟩ for all |ψ⟩ Test with |ψ⟩=|0⟩: U|0⟩|0⟩ = |0⟩|0⟩ ...(i) Test with |ψ⟩=|1⟩: U|1⟩|0⟩ = |1⟩|1⟩ ...(ii) Test with |ψ⟩=|+⟩ = (|0⟩+|1⟩)/√2: By linearity: U|+⟩|0⟩ = (U|0⟩|0⟩ + U|1⟩|0⟩)/√2 = (|00⟩+|11⟩)/√2 ...(from i,ii) But if cloning: U|+⟩|0⟩ = |+⟩|+⟩ = (|0⟩+|1⟩)⊗(|0⟩+|1⟩)/2 = (|00⟩+|01⟩+|10⟩+|11⟩)/2 ...(different!) CONTRADICTION! No cloning machine possible for arbitrary quantum states. Teleportation moves the state — it doesn't copy it.

Complete Protocol with Math

Initial State

Alice has: |ψ⟩₀ = α|0⟩ + β|1⟩ (unknown state) Shared: |Φ+⟩₁₂ = (|00⟩+|11⟩)/√2 (qubit 1 = Alice's, qubit 2 = Bob's) Total 3-qubit state: |ψ⟩₀ ⊗ |Φ+⟩₁₂ = (α|0⟩+β|1⟩) ⊗ (|00⟩+|11⟩)/√2 = (α|000⟩ + α|011⟩ + β|100⟩ + β|111⟩) / √2

Step 1: Alice applies CNOT (qubit 0 controls qubit 1)

CNOT₀₁ maps |abc⟩ → |a, a⊕b, c⟩ After CNOT: α|000⟩ → α|000⟩ α|011⟩ → α|011⟩ β|100⟩ → β|110⟩ (1⊕0=1) β|111⟩ → β|101⟩ (1⊕1=0) State = (α|000⟩ + α|011⟩ + β|110⟩ + β|101⟩) / √2

Step 2: Alice applies H on qubit 0

H|0⟩ = (|0⟩+|1⟩)/√2 H|1⟩ = (|0⟩-|1⟩)/√2 Applying H to qubit 0 in each term: α|0⟩₀|00⟩₁₂/√2 → α(|0⟩+|1⟩)/√2 ⊗|00⟩/√2 → α(|000⟩+|100⟩)/2 ... (similarly for all terms) After collecting terms by Alice's 2-qubit state: |Ψ⟩ = (1/2)[|00⟩(α|0⟩+β|1⟩) + |01⟩(α|1⟩+β|0⟩) + |10⟩(α|0⟩-β|1⟩) + |11⟩(α|1⟩-β|0⟩)] = (1/2)[|00⟩|ψ⟩ + |01⟩X|ψ⟩ + |10⟩Z|ψ⟩ + |11⟩XZ|ψ⟩]

Step 3-4: Alice measures, sends result, Bob corrects

Alice measures qubits 0,1 → gets one of {00, 01, 10, 11} Based on result: Measures 00 → Bob has |ψ⟩ → Bob applies I → gets |ψ⟩ ✓ Measures 01 → Bob has X|ψ⟩ → Bob applies X → gets |ψ⟩ ✓ Measures 10 → Bob has Z|ψ⟩ → Bob applies Z → gets |ψ⟩ ✓ Measures 11 → Bob has XZ|ψ⟩ → Bob applies ZX → gets |ψ⟩ ✓ Alice sends 2 classical bits (e.g., via phone) to Bob. Bob applies correction gate. Bob now has |ψ⟩ = α|0⟩ + β|1⟩! 🎉
Quantum Teleportation Circuit
Alice: |ψ⟩──────────●──[H]──[M₀]──→ (classical bit to Bob) | Alice: |0⟩──[H]──●──⊕──────[M₁]──→ (classical bit to Bob) shared| Bob: |0⟩────────⊕──────────────[X if M₁=1]──[Z if M₀=1]──→ |ψ⟩!

Lab 8 — Actual Problems with Solutions

📌 Problem 1: Eve Listens

|ψ⟩ = (|0⟩ + 2i|1⟩)/√5, Alice measures m₀m₁ = 10 Formula: outcome 10 → Bob has Z|ψ⟩ Z|ψ⟩ = Z(|0⟩ + 2i|1⟩)/√5 = (Z|0⟩ + 2i×Z|1⟩)/√5 = (|0⟩ + 2i×(-|1⟩))/√5 = (|0⟩ - 2i|1⟩)/√5 Bob applies Z: Z(Z|ψ⟩) = Z²|ψ⟩ = |ψ⟩ ✓ Does Eve learn α, β? Eve sees "10" (classical bits). This tells her WHICH correction Bob needs. But it does NOT tell her α=1/√5 or β=2i/√5 (the actual quantum information). Classical bits reveal the correction operation, not the unknown state!

📌 Problem 2: Eve Modifies the Message

|ψ⟩ = (3|0⟩+2i|1⟩)/√13, Alice gets result 11, Eve changes to 10. For actual result 11: Bob has XZ|ψ⟩ Correct correction: Apply ZX → ZX(XZ|ψ⟩) = Z(X²)Z|ψ⟩ = Z²|ψ⟩ = |ψ⟩ But Eve changed 11→10, so Bob applies Z (correction for result 10): Bob gets: Z×(XZ|ψ⟩) = ZXZ|ψ⟩ Compute ZXZ|ψ⟩: Z|ψ⟩ = (3|0⟩-2i|1⟩)/√13 X(Z|ψ⟩) = (-2i|0⟩+3|1⟩)/√13 Z(X(Z|ψ⟩)) = (-2i|0⟩-3|1⟩)/√13 = -(2i|0⟩+3|1⟩)/√13 Global phase -1 → physically same as (2i|0⟩+3|1⟩)/√13 Fidelity with original |ψ⟩ = (3|0⟩+2i|1⟩)/√13: F = |⟨ψ|corrupted⟩|² = |(3×2i + (-2i)×3)/(√13×√13)|² = |0/13|² = 0 FIDELITY = 0! Eve completely corrupted the state! Bob gets wrong state, and cannot detect attack (can't compare with unknown original).

📌 Problem 3: Charlie Changes Bell State

Alice thinks they share |Φ+⟩, but Charlie gives |Ψ+⟩ instead. For |Ψ+⟩ = (|01⟩+|10⟩)/√2, the teleportation formula is: |Ψ⟩₀₁₂ = (1/2)[|00⟩(X|ψ⟩) + |01⟩(|ψ⟩) + |10⟩(XZ|ψ⟩) + |11⟩(Z|ψ⟩)] For outcome 01: Bob has |ψ⟩ (no correction needed!) But Bob (assuming |Φ+⟩) applies X for outcome 01: Bob gets X|ψ⟩ → wrong! Correction mapping comparison: Result | For |Φ+⟩ | For |Ψ+⟩ 00 | I | X 01 | X | I ← swapped! 10 | Z | XZ 11 | XZ | Z If Bob knows it's |Ψ+⟩, he applies I for result 01 → gets |ψ⟩ ✓ Eve observes classical bits → still doesn't learn α, β (same as before)
ComparisonSuperdense CodingQuantum Teleportation
GoalSend classical bitsTransfer quantum state
Transmitted1 qubit2 classical bits
ResultBob reads 2 bitsBob gets |ψ⟩
EntanglementRequired (pre-shared)Required (pre-shared)
Original stateN/ADESTROYED at Alice
Does Eve learn state?N/ANO — bits reveal correction, not state

💻 Chapter 11: Real Quantum Hardware — Asli Machines!

🌡️ Superconducting Qubits (IBM, Google)

  • What: Josephson junction — do superconductors ke beech thin insulator
  • Temp: ~15 millikelvin (outer space se 100x thanda!)
  • |0⟩/|1⟩: Ground/excited energy state
  • T1, T2: ~50-200 microseconds
  • Gate fidelity: ~99.5% single-qubit, ~99% two-qubit
  • Current: IBM Condor = 1121 qubits (2023)

⚡ Trapped Ion Qubits (IonQ, Quantinuum)

  • What: Individual ions (Yb+, Ca+) trapped by EM fields + laser cooled
  • T1, T2: Minutes! (1000x longer than superconducting)
  • Fidelity: ~99.9% (very high!)
  • Disadvantage: Gates take microseconds (1000x slower)

Noise Sources — Kyun Real Hardware Imperfect Hai?

  1. Decoherence: Qubit environment se interact karta hai. Time ke saath state disturb hoti hai.
  2. Gate errors: Microwave/laser pulse perfect nahi. ~0.1-1% error per gate.
  3. Measurement errors: |0⟩ ko |1⟩ read karo ya vice versa.
  4. Crosstalk: Nearby qubits ek dusre ko affect karte hain.
  5. Leakage: Qubit |0⟩/|1⟩ ke alawa kisi energy level mein jump kar jaata hai.

📌 Bell State on Real Hardware vs Simulator (Lab 5)

Circuit: |00⟩ → H⊗I → CNOT → Measure Simulator (ideal): {'00': 512, '11': 512} ← perfect 50/50 Real IBM hardware: {'00': 480, '11': 494, '01': 18, '10': 14} ← noise visible! The '01' and '10' are ERRORS from: - Gate imperfections (H, CNOT not perfect) - Decoherence during execution - Measurement errors How to reduce: 1. Error mitigation (post-processing) 2. Error correction codes 3. Shorter circuits 4. Better hardware (ongoing research)
T1 = Energy relaxation time (|1⟩ → |0⟩ decay time) T2 ≤ 2T1 = Dephasing/coherence time Typical IBM values: T1 ≈ 100 µs T2 ≈ 100 µs Single gate time ≈ 50 ns → ~2000 gates before significant decoherence! NISQ era: 50-1000+ qubits, but noisy. Goal: Fault-tolerant QC (millions of error-corrected qubits).

🐍 Chapter 12: Qiskit Code Examples

Setup

!pip install qiskit qiskit-aer

from qiskit import QuantumCircuit, transpile
from qiskit.quantum_info import Statevector
from qiskit_aer import AerSimulator
from qiskit.visualization import plot_histogram

First Circuit — H Gate (Lab 2)

qc = QuantumCircuit(1, 1)   # 1 qubit, 1 classical bit
qc.h(0)                      # Hadamard on qubit 0
qc.measure(0, 0)             # Measure → classical bit

sim = AerSimulator()
result = sim.run(transpile(qc, sim), shots=1000).result()
counts = result.get_counts()
print(counts)  # {'0': ~500, '1': ~500}

Three Gates: X, Y, H (Lab 2)

qc2 = QuantumCircuit(1, 1)
qc2.x(0)  # |0⟩ → |1⟩
qc2.y(0)  # |1⟩ → -i|0⟩  (Y|1⟩ = -i|0⟩)
qc2.h(0)  # -i|0⟩ → -i|+⟩ (global phase -i, same as |+⟩)
qc2.measure(0, 0)
# Result: ~50/50 (global phase doesn't affect measurement!)

Bell State (Labs 4, 5, 7)

qc = QuantumCircuit(2, 2)
qc.h(0)         # H on qubit 0: |0⟩ → |+⟩
qc.cx(0, 1)    # CNOT: creates entanglement!
qc.measure([0,1], [0,1])

# Expected: {'00': ~500, '11': ~500}
# Real hardware: also some '01' and '10' (noise!)

Running on Real IBM Hardware (Lab 5)

from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler

service = QiskitRuntimeService(channel="ibm_quantum", token="YOUR_API_TOKEN")
backend = service.least_busy(operational=True, simulator=False)
print(f"Using: {backend.name}")  # e.g., "ibm_brisbane"

qc_t = transpile(qc, backend, optimization_level=1)
sampler = Sampler(backend)
job = sampler.run([qc_t], shots=1024)
result = job.result()
counts = result[0].data.c.get_counts()
print(counts)  # Noisy results!

Teleportation Circuit (Lab 8)

from qiskit import QuantumCircuit

qc = QuantumCircuit(3, 2)

# Create Bell pair (qubits 1 and 2)
qc.h(1)
qc.cx(1, 2)

# State to teleport: put qubit 0 in some state
qc.h(0)  # Teleport |+⟩ state

qc.barrier()

# Teleportation protocol
qc.cx(0, 1)   # CNOT: q0 controls q1
qc.h(0)        # H on q0

qc.barrier()

# Measure q0 and q1 (Alice's measurement)
qc.measure(0, 0)
qc.measure(1, 1)

qc.barrier()

# Bob's corrections (classical control)
qc.x(2).c_if(qc.clbits[1], 1)   # X if classical bit 1 = 1
qc.z(2).c_if(qc.clbits[0], 1)   # Z if classical bit 0 = 1

# Now qubit 2 should have the original |+⟩ state!
GateQiskitWhat it does
Xqc.x(q)Pauli X (NOT gate)
Yqc.y(q)Pauli Y
Zqc.z(q)Pauli Z (phase flip)
Hqc.h(q)Hadamard
Sqc.s(q)S gate (π/2 phase)
Tqc.t(q)T gate (π/4 phase)
CNOTqc.cx(c,t)Controlled-NOT
CZqc.cz(q0,q1)Controlled-Z
SWAPqc.swap(q0,q1)Swap two qubits
Measureqc.measure(q,c)Measure qubit

📝 Chapter 13: Practice Problems — Saare Actual Problems

A: Tensor Products (Lab 6)

🧮 Tensor Product Problems

Q1: |1⟩⊗|0⟩ ka column vector
|1⟩⊗|0⟩ = [0]⊗[1] = [0×1,0×0,1×1,1×0]ᵀ = [0,0,1,0]ᵀ = |10⟩ ✓
Q2: [1,2]ᵀ ⊗ [3,4]ᵀ
[1]⊗[3] = [1×3] = [3] [2] [4] [1×4] [4] [2×3] [6] [2×4] [8]
Q3: |+⟩⊗|+⟩ in computational basis
|+⟩ = [1/√2,1/√2]ᵀ |+⟩⊗|+⟩ = [1/2,1/2,1/2,1/2]ᵀ = (|00⟩+|01⟩+|10⟩+|11⟩)/2 P(each outcome) = 1/4 = 25%
Q4: |0⟩⊗|+⟩⊗|1⟩ in computational basis
|0⟩⊗|+⟩ = (|00⟩+|01⟩)/√2 [(|00⟩+|01⟩)/√2]⊗|1⟩ = (|001⟩+|011⟩)/√2 P(001) = P(011) = 1/2 = 50%

B: Measurement Probabilities

🎲 Probability Problems

Q5: |ψ⟩=(3|0⟩+4i|1⟩)/5 ke P(0) aur P(1)
P(0) = |3/5|² = 9/25 = 36% P(1) = |4i/5|² = 16/25 = 64% Check: 9+16=25 ✓
Q6: |ψ⟩=(2|0⟩+3i|1⟩)/c ke liye c find karo
|2/c|² + |3i/c|² = 1 (4+9)/c² = 1 c² = 13 c = √13 ✓
Q7: 3-qubit state |ψ⟩=(|000⟩+|001⟩+|100⟩+|101⟩)/2 — probabilities aur is it entangled?
P(000) = P(001) = P(100) = P(101) = 1/4 = 25% Factor: = (|0⟩+|1⟩)/√2 ⊗ |0⟩ ⊗ (|0⟩+|1⟩)/√2 = |+⟩⊗|0⟩⊗|+⟩ → PRODUCT STATE (not entangled!)

C: Gate Calculations

⚡ Gate Application Problems

Q8: X|+⟩ = ? Explain why
X|+⟩ = X(|0⟩+|1⟩)/√2 = (X|0⟩+X|1⟩)/√2 = (|1⟩+|0⟩)/√2 = |+⟩ |+⟩ is eigenstate of X (eigenvalue +1)! Amplitudes swap but they're equal so it looks same.
Q9: Z|−⟩ = ?
Z|−⟩ = Z(|0⟩-|1⟩)/√2 = (Z|0⟩-Z|1⟩)/√2 = (|0⟩-(-|1⟩))/√2 = (|0⟩+|1⟩)/√2 = |+⟩ Z swaps |+⟩↔|−⟩!
Q10: T²=S verify karo
T = [[1,0],[0,e^(iπ/4)]] T² = [[1,0],[0,e^(iπ/4)]] × [[1,0],[0,e^(iπ/4)]] = [[1,0],[0,e^(iπ/2)]] = [[1,0],[0,i]] = S ✓
Q11: HXH = ? (classic result)
HXH|0⟩ = H(X(H|0⟩)) = H(X|+⟩) = H|+⟩ = |0⟩ [since X|+⟩=|+⟩] HXH|1⟩ = H(X(H|1⟩)) = H(X|−⟩) = H(-|−⟩) = -|1⟩ [global phase] So HXH = Z ! (maps |0⟩→|0⟩, |1⟩→-|1⟩ = exactly Z) Similarly: HZH = X (swap X↔Z axes!)

D: Entanglement Tests

🔗 Entanglement Problems

Q12: (|00⟩+|01⟩+|10⟩-|11⟩)/2 — entangled?
α=1/2, β=1/2, γ=1/2, δ=-1/2 αδ = (1/2)(-1/2) = -1/4 βγ = (1/2)(1/2) = +1/4 αδ ≠ βγ → ENTANGLED ✓
Q13: (|00⟩+|10⟩)/√2 — entangled?
α=1/√2, β=0, γ=1/√2, δ=0 αδ = 0 = βγ → PRODUCT STATE ✓ Factor: = (|0⟩+|1⟩)/√2 ⊗ |0⟩ = |+⟩⊗|0⟩
Q14: Bonus Lab 7 — Can you create entanglement using only H, X, Z, T? (No CNOT)
NO! Single-qubit gates of form A⊗B: (A⊗B)(|ψ₁⟩⊗|ψ₂⟩) = (A|ψ₁⟩)⊗(B|ψ₂⟩) — still product state! Any sequence of single-qubit gates applied to product state → still product state. Entanglement requires genuine 2-qubit interaction (CNOT, CZ, SWAP).

E: Phase Problems

🌊 Phase Practice

Q15: e^(iπ/3)|+⟩ aur |+⟩ — same physical state?
e^(iπ/3) is a GLOBAL phase (multiplying entire state). |e^(iπ/3)|² = 1, so all probabilities unchanged. YES — same physical state! ✓
Q16: (|0⟩+i|1⟩)/√2 aur (|0⟩-i|1⟩)/√2 — same?
Relative phases: arg(i) = π/2 vs arg(-i) = -π/2 → DIFFERENT relative phases. No global phase relates them (would require e^(iθ)×i = -i → e^(iθ) = -1 AND e^(iθ)×1 = 1 → contradiction). NO — different states! |+i⟩ vs |-i⟩ (+Y and -Y eigenstates on Bloch sphere).

F: 2-Qubit Gate Problems (Lab 7)

🚪 2-Qubit Gate Practice

Q17: CNOT|+0⟩ = ?
|+0⟩ = (|00⟩+|10⟩)/√2 CNOT: |00⟩→|00⟩, |10⟩→|11⟩ CNOT|+0⟩ = (|00⟩+|11⟩)/√2 = |Φ+⟩ (Bell state — entangled!)
Q18: Lab 7 Circuit: |00⟩ → H⊗I → CNOT → S⊗X → H⊗H → CZ → T⊗I → CNOT → SWAP → H⊗I
Step by step: |00⟩ → H⊗I: (|0⟩+|1⟩)/√2 ⊗ |0⟩ = (|00⟩+|10⟩)/√2 → CNOT: (|00⟩+|11⟩)/√2 (Bell state!) → S⊗X: (S|0⟩⊗X|0⟩ + S|1⟩⊗X|1⟩)/√2 = (|0⟩⊗|1⟩ + i|1⟩⊗|0⟩)/√2 = (|01⟩+i|10⟩)/√2 → H⊗H: Apply H to both qubits... H|0⟩=(|0⟩+|1⟩)/√2, H|1⟩=(|0⟩-|1⟩)/√2 State → complex expansion... [full calculation on simulator for lab!] In practice: Run on AerSimulator for complete result. Main lesson: Complex multi-gate circuits need systematic computation or simulation.

G: Superdense Coding Problems

📡 Superdense Practice

Q19: Alice wants to send "10". Kaunsa gate? Konsa Bell state?
Message 10 → Alice applies Z (Z⊗I)|Φ+⟩ = (Z|0⟩⊗|0⟩ + Z|1⟩⊗|1⟩)/√2 = (|00⟩-|11⟩)/√2 = |Φ-⟩ Bob decodes: CNOT|Φ-⟩ = |−⟩⊗|0⟩, then H: |1⟩⊗|0⟩ = |10⟩. Measures 10 ✓
Q20: Bob receives |Ψ-⟩. Alice's message?
Table: |Ψ-⟩ corresponds to message 11. Bob: CNOT|Ψ-⟩ → |−⟩⊗|1⟩ → H: |1⟩⊗|1⟩ → Measures 11 ✓

🌟 Bonus: Jo Lectures Mein Nahi Tha — Connected Topics

Grover's Algorithm

N items mein ek item dhundna. Classical: average N/2. Quantum Grover's: √N!
Example: 1 million items → Classical: 500,000 avg. Quantum: 1000!
Algorithm: 1. H⊗ⁿ|0⟩ⁿ = equal superposition of all N states 2. Repeat √N times: a. Oracle: marks correct answer with phase flip |x⟩ → -|x⟩ (if x = answer) b. Diffusion: inversion about mean — amplifies marked state 3. Measure → correct answer with high probability! Why √N? Each iteration amplifies correct amplitude by ~2/√N. After √N iterations, amplitude ≈ 1 → measure correctly!

Shor's Algorithm — RSA Ka Khatma

RSA encryption (HTTPS, banking) iss assumption pe based: large numbers factor karna bohot hard hai.
Shor's algorithm (1994): Quantum computer polynomial time mein factor kar sakta hai!
Core idea: Period finding using Quantum Fourier Transform To factor N: 1. Choose random a < N 2. Find period r of f(x) = aˣ mod N using QFT 3. gcd(a^(r/2)-1, N) aur gcd(a^(r/2)+1, N) → factors! Impact: A large fault-tolerant QC could break RSA-2048 in hours. That's why post-quantum cryptography is being developed now!

Quantum Error Correction

Problem: Noise causes errors. Can't copy qubits (no-cloning). Solution: Encode info in entanglement (redundancy without copying) Shor Code: 1 logical qubit → 9 physical qubits - Protects against bit flip AND phase flip errors Surface Code (current best): - 2D grid of qubits - ~1000 physical qubits per logical qubit (at current error rates) - Error threshold ~1% per gate

Quantum Computing Applications

ApplicationQuantum AdvantageStatus
Drug DiscoveryExact molecular simulationEarly NISQ experiments
OptimizationQAOA, quantum annealingActive research
Cryptography (Shor's)Exponential speedupNeed fault-tolerant QC
Search (Grover's)√N speedupDemonstrated
Quantum SensingHeisenberg precision limitAlready deployed (atomic clocks)

🎓 Padh liya? Mazaa aaya?

Naye lectures aayein toh update hote rahenge!

Content: Lectures 1-9 | Labs 2-8 | Born Rule | Hermitian/Unitary Matrices
Superdense Coding | Quantum Teleportation | Weekend in Quantum World | Math225