Project 1: The Linear Algebra “Engine” (Classical Simulation)
Build a small linear algebra engine that simulates single- and two-qubit states.
Project Overview
| Attribute | Value |
|---|---|
| Difficulty | Level 2: Intermediate |
| Time Estimate | Weekend |
| Main Language | Python |
| Alternative Languages | Julia, C++ |
| Knowledge Area | Linear algebra |
| Tools | CLI or notebook |
| Main Book | “Quantum Computation and Quantum Information” by Nielsen & Chuang |
What you’ll build: A simulator that applies basic gates to state vectors and computes measurement probabilities.
Why it teaches quantum: Quantum computing is linear algebra. This project makes states and gates concrete.
Core challenges you’ll face:
- Implementing complex vectors and matrices
- Maintaining normalization
- Modeling measurement collapse
Real World Outcome
You will apply gates to a qubit and verify probabilities match theory.
Example Output:
$ python sim.py --gate H --measure
State: [0.707+0j, 0.707+0j]
Measured 0: 0.50, 1: 0.50
Verification steps:
- Check normalization after each gate
- Verify Bell states for two qubits
The Core Question You’re Answering
“How do quantum states evolve under linear transformations?”
This is the mathematical core of quantum algorithms.
Concepts You Must Understand First
Stop and research these before coding:
- State vectors
- Why do amplitudes squared sum to 1?
- Book Reference: Nielsen & Chuang, Ch. 2
- Unitary gates
- Why must quantum gates be unitary?
- Book Reference: Nielsen & Chuang, Ch. 2
- Measurement
- How does measurement collapse the state?
- Book Reference: Nielsen & Chuang, Ch. 2
Questions to Guide Your Design
- State representation
- Will you use column vectors and matrix multiplication?
- How will you represent multi-qubit tensor products?
- Measurement
- Will you sample outcomes or compute probabilities only?
- How will you handle partial measurement?
Thinking Exercise
Hadamard Test
| Apply a Hadamard gate to | 0>. What are the resulting amplitudes and probabilities? |
Questions while working:
- Why is the probability split evenly?
- What happens if you apply H twice?
The Interview Questions They’ll Ask
Prepare to answer these:
- “What is a quantum state vector?”
- “Why are quantum gates unitary?”
- “How do you simulate measurement?”
- “What is a tensor product and why is it needed?”
- “How do you represent a two-qubit state?”
Hints in Layers
Hint 1: Starting Point Implement single-qubit vectors and gates.
Hint 2: Next Level Add tensor products to build two-qubit states.
Hint 3: Technical Details Use complex numbers and normalize after operations.
Hint 4: Tools/Debugging Add checks that gate matrices are unitary.
Books That Will Help
| Topic | Book | Chapter |
|---|---|---|
| State vectors | Nielsen & Chuang | Ch. 2 |
| Unitary gates | Nielsen & Chuang | Ch. 2 |
| Measurement | Nielsen & Chuang | Ch. 2 |
Implementation Hints
- Keep gates in a dictionary for reuse.
- Validate normalization after each step.
- Start with deterministic test circuits.
Learning Milestones
- First milestone: You can apply single-qubit gates correctly.
- Second milestone: You can model two-qubit states.
- Final milestone: You can explain measurement outcomes quantitatively.