View on GitHub
Open this notebook in GitHub to run it yourself
The Linear Combination of Hamiltonian Simulation (LCHS) method [1] solves linear ODEs of the form on a quantum computer, where may be non-anti-Hermitian, leading to non-unitary time evolution. It works by expressing the propagator as a continuous linear combination of unitary evolutions, which is then discretized and implemented using standard Hamiltonian simulation primitives.Complexity: The algorithm requires queries to the block-encoding oracle for [5], where is the block-encoding normalization and is the target operator-norm error . This is optimal in all parameters, improving the scaling of prior work [1], [2].
- Input:
- A matrix with (positive semidefinite) and (Hermitian).
- Block-encoding oracles for and .
- The evolution time and target error .
- Output: A quantum state proportional to , obtained via post-selection on auxiliary qubits.
Keywords: Non-unitary dynamics, Linear Differential Equations, Hamiltonian Simulation, Block Encoding, GQSP, Kernel Methods, Open Quantum Systems.
Background
The Problem
We wish to solve the linear ODE where . When is not anti-Hermitian, the solution is non-unitary and cannot be directly implemented as a quantum gate. We decompose where:- is Hermitian (the conservative/oscillatory part),
- is positive semidefinite (the dissipative/damping part).
The LCHS Identity
The central insight of LCHS is the integral identity (Eq. 4 in [5], originally [1]): where is the Fourier transform of a function chosen to satisfy for . For each , the matrix is Hermitian, so the exponential is a unitary operator that can be implemented using standard Hamiltonian simulation techniques. In practice this integral is truncated to a finite interval (where is the truncation radius) and discretized into a finite sum that can be implemented via LCU on a quantum computer. A key innovation of [5] is the approximate LCHS: the kernel need only approximate exponential decay (rather than match it exactly), which circumvents a no-go result from prior work and enables the optimal query complexity.Kernel Function
Reference [5] uses the kernel function (Eq. 9, with , ): This is a product of a Lorentzian and a Gaussian . The Lorentzian alone is the Fourier transform of exact exponential decay , but its tails decay only as , making it expensive to truncate the integral. The Gaussian envelope suppresses the tails exponentially, enabling truncation to a finite interval with small error. The tradeoff is that the kernel now only approximates exponential decay, with the approximation quality controlled by : larger gives a wider (flatter) Gaussian and a better approximation, at the cost of a larger truncation radius . The shift parameter controls the normalization factor , which determines the post-selection success probability. Theorem 2 of [5] sets and to guarantee kernel approximation error .Discretization
The integral is discretized on a uniform grid of points with spacing over the interval ([5], Theorem 3, which proves exponential convergence of the uniform quadrature): The stepsize is chosen according to: The number of grid points is then . Note that a uniform quadrature is sufficient. This sum is implemented via LCU, with the kernel values as coefficients.Quantum Circuit Structure
The full LCHS quantum circuit consists of the following components:- Kernel state preparation: Load into an auxiliary register .
- Block-encoding of : For each grid point , block-encode the Hermitian operator , where is the normalization.
- Hamiltonian simulation: In this demo we apply the Jacobi-Anger polynomial approximation of using Generalized QSP on the walk operator derived from the block encoding.
- Post-selection: Measure all auxiliary qubits in the state to extract the desired output.
Preliminaries
Problem Definition and Parameters
We define the Hamiltonians and and derive all algorithm parameters — state size, block-encoding normalization, kernel shape, and error budget — from these operators and the desired precision.Output:
Classical Reference Simulation
Before building the quantum circuit, we implement the LCHS formula classically to verify correctness.- Exact: Direct matrix exponentiation .
- LCHS: The discretized sum using exact matrix exponentials.
Classical Verification
We verify the LCHS simulation against the exact solution using a random test problem.Output:
Quantum Implementation

- Prepare the kernel amplitudes in the register.
- Block-encode the -dependent Hamiltonian .
- Simulate the time evolution via GQSP on the walk operator.
- Post-select on auxiliary qubits being .
Data Structures
We define quantum struct types for the LCHS circuit. TheLchsBlock struct holds the auxiliary registers:
j: a signed integer register for the grid index,lcu_block: auxiliary qubit for the LCU of and ,linear_block: auxiliary qubit for the linear block-encoding of (explained below),matrices_block: auxiliary qubits for the block-encoding of and .
Block-Encoding the Hamiltonians
For each grid point , we need a block-encoding of the Hermitian operator This is achieved by an LCU decomposition: The factor is block-encoded using a linear amplitude encoding: , which embeds the linear function of into an amplitude. The other constants are applied as part of the LCU probabilities. The Pauli-decomposed operators and (defined in the parameters cell above) are each block-encoded vialcu_pauli, which implements the LCU of Pauli terms using ancilla qubits.
Walk Operator and GQSP Hamiltonian Simulation
Given the block-encoding of , we construct the walk operator , whose eigenvalues are for each eigenvalue of . We then use GQSP with a Jacobi-Anger polynomial approximation to implement as a function of , effectively realizing the Hamiltonian simulation within the block.Kernel Preparation
The kernel state preparation loads the absolute values into the register. The complex phase of the kernel, , is applied as a separate phase gate after the Hamiltonian simulation.
within_apply pattern:
Running the Quantum Circuit
We define the main function, synthesize the circuit, and execute it using a statevector simulator. We post-select on the block register being to extract the LCHS output state.Output:
Output:
| x | block | amplitude | magnitude | phase | probability | bitstring | |
|---|---|---|---|---|---|---|---|
| 58 | 0 | 0 | -0.009290+0.039227j | 0.04 | 0.57π | 0.001625 | 00000000000000 |
| 8 | 1 | 0 | -0.162077-0.048177j | 0.17 | -0.91π | 0.028590 | 00000000000001 |
| 40 | 2 | 0 | -0.016073+0.054032j | 0.06 | 0.59π | 0.003178 | 00000000000010 |
| 29 | 3 | 0 | -0.032474+0.071042j | 0.08 | 0.64π | 0.006101 | 00000000000011 |
Quantum vs.
Classical Comparison We compare the quantum LCHS output against:- Exact: Direct matrix exponentiation .
- LCHS (classical): Classical emulation of the quantum circuit (discretized LCHS with the GQSP polynomial approximation).
Output:
Technical Notes
- Access model: The algorithm assumes block-encoding access to and separately. If only access to is available, one can extract and via and , though this may double the block-encoding cost. Alternatively, as noted in [5] (Sec. 1.1.5), one can block-encode directly from a block-encoding of using the identity .
- Time-dependent case: If or are time-dependent, the inner Hamiltonian simulation becomes time-dependent and can be handled using methods such as Dyson or Magnus series (see the Time Marching notebook).
- Normalization and post-selection: The LCU of the kernel introduces a normalization factor , which is for constant [5].
- Scalable kernel preparation: The
inplace_prepare_amplitudesfunction used here loads arbitrary amplitudes but does not scale efficiently. [5] (Theorem 4) provides an efficient circuit for preparing the kernel state with two-qubit gates.