Quantum algorithms lab

Quantum Algorithms Lab

Deutsch, Deutsch–Jozsa, Bernstein–Vazirani, Simon, Grover, QFT, phase estimation, Shor (small examples), teleportation, superdense coding and more.

Loading the simulator…

Algorithms

Beginner Deutsch's Algorithm Deutsch's Algorithm Deutsch's algorithm decides whether a one-bit function is constant or balanced with a single oracle query instead of two. Intermediate Deutsch–Jozsa Algorithm Deutsch–Jozsa Algorithm Deutsch–Jozsa decides with one query whether an n-bit function promised to be constant or balanced is which, versus 2^n−1+1 queries for an exact classical algorithm. Intermediate Bernstein–Vazirani Algorithm Bernstein–Vazirani Algorithm Bernstein–Vazirani recovers the hidden string s of f(x) = s·x mod 2 with one query, whereas any classical method needs n queries. Advanced Simon's Algorithm Simon's Algorithm Simon's algorithm finds the hidden period s of a two-to-one function with O(n) queries, whereas classical randomized algorithms need Ω(2^n/2). Intermediate Grover's Search Algorithm Grover's Search Algorithm Grover's algorithm finds a marked item among N with about (π/4)√(N/M) oracle queries instead of O(N/M): a provably optimal quadratic speed-up. Advanced Quantum Fourier Transform (QFT) Quantum Fourier Transform (QFT) The QFT applies the discrete Fourier transform to the amplitudes of an n-qubit state with O(n²) gates; a key subroutine of phase estimation and Shor's algorithm. Advanced Quantum Phase Estimation (QPE) Quantum Phase Estimation (QPE) QPE estimates the phase φ in U|u⟩ = e^2πiφ|u⟩ to t bits using t counting qubits, controlled-U^2^j and an inverse QFT. Advanced Shor's Factoring Algorithm Shor's Factoring Algorithm Shor's algorithm factors N in time polynomial in log N via quantum order finding, but needs a large fault-tolerant quantum computer that does not yet exist. Intermediate Quantum Teleportation Quantum Teleportation Teleportation transfers an unknown qubit state using a shared Bell pair and two classical bits; it moves no matter and cannot exceed light speed. Intermediate Superdense Coding Superdense Coding Superdense coding sends two classical bits by transmitting one qubit, given a pre-shared entangled pair; the logical dual of teleportation. Advanced Variational Quantum Eigensolver (VQE) Variational Quantum Eigensolver (VQE) VQE is a hybrid quantum–classical heuristic that approximates the ground energy of a Hamiltonian by minimizing ⟨ψ(θ)|H|ψ(θ)⟩ over a parameterized circuit. Advanced Quantum Approximate Optimization Algorithm (QAOA) Quantum Approximate Optimization Algorithm (QAOA) QAOA is a variational algorithm for combinatorial optimization such as Max-Cut, alternating cost layers e^−iγH_C and mixer layers e^−iβΣX with classically optimized angl… Intermediate Swap Test Swap Test The swap test estimates |⟨ψ|φ⟩|² between two states using an ancilla and a Fredkin gate: P(0) = (1 + |⟨ψ|φ⟩|²)/2. Intermediate Hadamard Test Hadamard Test The Hadamard test estimates Re⟨ψ|U|ψ⟩ (or the imaginary part) with an ancilla and a controlled-U: P(0) = (1 + Re⟨ψ|U|ψ⟩)/2. Intermediate BB84 Quantum Key Distribution BB84 Quantum Key Distribution BB84 distributes a secret key by sending qubits encoded in two random bases; eavesdropping introduces detectable errors (≈25% QBER for intercept–resend).

Experiments in this module

Beginner Deutsch Algorithm: Balanced Function Deutsch Algorithm: Balanced Function With one oracle query Deutsch's algorithm decides that f(x)=x is balanced: q0 reads 1 with certainty. Intermediate Deutsch–Jozsa with Three Qubits Deutsch–Jozsa with Three Qubits For the balanced f(x)=s·x with s=101 the circuit outputs 101 with certainty and never 000; a constant f always gives 000. Intermediate Bernstein–Vazirani: Recovering a 4-bit Secret Bernstein–Vazirani: Recovering a 4-bit Secret One query to f(x)=s·x mod 2 recovers the full secret s = 1011 with certainty. Advanced Simon's Algorithm with s = 110 Simon's Algorithm with s = 110 Every outcome y satisfies y·s = 0 mod 2; for s = 110 only 000, 001, 110, 111 appear (1/4 each), and s follows by Gaussian elimination. Intermediate Grover Search over 8 Items Grover Search over 8 Items With N = 8 and one marked item (|101⟩), the optimal number of iterations is 2 and the success probability is sin²(5θ) ≈ 0.945. Advanced Quantum Fourier Transform of |5⟩ Quantum Fourier Transform of |5⟩ A 3-qubit QFT maps |5⟩ to a uniform superposition with amplitudes e^2πi·5y/8/√8: all probabilities are 1/8 and the information is in the phases. Advanced Phase Estimation with 4 Counting Qubits Phase Estimation with 4 Counting Qubits For P(2πφ) with φ = 5/16 and 4 counting qubits, QPE returns 0101 with certainty, i.e. φ = 5/16 exactly. Advanced Shor: Order Finding for a = 7, N = 15 Shor: Order Finding for a = 7, N = 15 For N = 15, a = 7, t = 8 counting qubits, peaks appear at m ∈ 0, 64, 128, 192 with probability 1/4 each; order r = 4 and factors 3 × 5. Intermediate Teleportation Protocol with Classical Feed-forward Teleportation Protocol with Classical Feed-forward Alice's two-bit outcome is uniformly random (1/4 each); after Bob applies X^m1 Z^m0, the teleported state has fidelity 1 in every shot. Intermediate Superdense Coding of the Message 10 Superdense Coding of the Message 10 Sending one qubit of a pre-shared Bell pair conveys two classical bits; the message 10 is decoded with certainty. Intermediate BB84 Key Distribution without an Eavesdropper BB84 Key Distribution without an Eavesdropper Without Eve, Alice's and Bob's bits agree wherever they chose the same basis: QBER is zero. Intermediate BB84 with an Intercept–Resend Eavesdropper BB84 with an Intercept–Resend Eavesdropper An intercept–resend attacker measuring in random bases raises the sifted-key error rate to 25% on average, revealing her presence. Advanced Swap Test for State Overlap Swap Test for State Overlap In the swap test P(0) = (1 + |⟨a|b⟩|²)/2 on the ancilla; for the chosen states |⟨a|b⟩|² ≈ 0.418.

Module quiz

The quiz needs JavaScript.

All results in this lab come from an exact classical statevector simulation running in your browser, not from execution on a real quantum computer. The required memory doubles with every qubit ($2^n$ amplitudes), so the number of qubits is limited by default to 16.