Quantum Linear Systems
The HHL algorithm (Harrow-Hassidim-Lloyd, 2009) solves linear systems on a quantum computer:
- Encode as a quantum state
- Use quantum phase estimation to find eigenvalues of
- Apply controlled rotations to encode
- Uncompute to obtain
Complexity: where is the condition number and is the precision.
This provides exponential speedup over classical for sparse systems.
Quantum Phase Estimation for Eigenvalues
Quantum phase estimation (QPE) extracts eigenvalues of a unitary :
- Prepare eigenstate with eigenvalue
- Apply controlled- operations
- Inverse QFT to extract
The eigenvalue is encoded in the ancilla register with precision using ancilla qubits.
HHL Algorithm Detail
The HHL algorithm steps:
- Encode in QPE register
- QPE extracts eigenvalues into ancilla register
- Controlled rotation:
- Uncompute QPE to disentangle ancilla
- Measure ancilla: if , remaining register is
The algorithm requires qubits and gates for sparse .
Limitations of HHL
HHL limitations:
- Input encoding: preparing may be as hard as solving
- Output encoding: result is in quantum state, not classical vector
- Sparsity requirement: must be efficiently implementable as Hamiltonian
- Condition number: runtime scales as
- Non-sparse matrices: not applicable for dense matrices
These limitations mean HHL is not a universal speedup for linear systems.
Variational Quantum Linear Solver
Variational quantum linear solver (VQLS) addresses HHL limitations:
- Prepare ansatz
- Minimize
- Use hybrid quantum-classical optimization
Advantages: no input encoding requirement, NISQ-compatible, no phase estimation needed.
Quantum Algorithms for Differential Equations
Quantum algorithms for ODEs/PDEs:
- Hamiltonian simulation: evolve
- Linear systems: solve for differential operators
- Variational methods: parameterized circuits for PDE solutions
The Schrodinger equation is naturally quantum, giving exponential speedup for quantum simulations.
Python: HHL Simulation
import numpy as np
def hhl_simulation(A, b):
# Simplified HHL algorithm simulation.
# Classical simulation of HHL
# 1. Diagonalize A
eigenvalues, eigenvectors = np.linalg.eigh(A)
# 2. Express b in eigenbasis
b_eig = eigenvectors.conj().T @ b
# 3. Invert eigenvalues (with regularization)
epsilon = 1e-10
inv_eigenvalues = np.where(np.abs(eigenvalues) > epsilon, 1/eigenvalues, 0)
# 4. Compute x in eigenbasis
x_eig = inv_eigenvalues * b_eig
# 5. Transform back
x = eigenvectors @ x_eig
return x
# Test: solve Ax = b
A = np.array([[2, 1], [1, 3]], dtype=complex)
b = np.array([1, 0], dtype=complex)
x = hhl_simulation(A, b)
print(f"Ax = {A @ x}")
print(f"b = {b}")
print(f"Error: {np.linalg.norm(A @ x - b):.2e}")
HHL Algorithm Analysis
The HHL algorithm solves in time:
- Encode in QPE register
- QPE extracts eigenvalues of
- Controlled rotation:
- Uncompute QPE
- Measure: obtain
Variational Quantum Linear Solver
VQLS addresses HHL limitations:
- Prepare ansatz
- Minimize
- Use parameter-shift rule for gradients
- Classical optimization updates
Advantages: no input encoding, NISQ-compatible, no phase estimation needed.