Use this file to discover all available pages before exploring further.
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 dtd∣u⟩=−A∣u⟩ on a quantum computer, where A may be non-anti-Hermitian, leading to non-unitary time evolution. It works by expressing the propagator e−At as a continuous linear combination of unitary evolutions, which is then discretized and implemented using standard Hamiltonian simulation primitives.
Input:
A matrix A=L+iH with L⪰0 (positive semidefinite) and H=H† (Hermitian).
Block-encoding oracles for H/αH and L/αL.
The evolution time t and target error ϵ.
Output: A quantum state proportional to e−At∣u0⟩, obtained via post-selection on auxiliary qubits.
Complexity: The algorithm requires O(αAtlog(1/ϵ)) queries to the block-encoding oracle for A[5], where αA≥∥A∥ is the block-encoding normalization and ϵ is the target operator-norm error ∥e−At−U~∥≤ϵ. This is optimal in all parameters, improving the O(αAtlog1+o(1)(1/ϵ)) scaling of prior work [1], [2].Keywords: Non-unitary dynamics, Linear Differential Equations, Hamiltonian Simulation, Block Encoding, GQSP, Kernel Methods, Open Quantum Systems.
We wish to solve the linear ODEdtd∣u⟩=−A∣u⟩,∣u(0)⟩=∣u0⟩,where A∈CN×N.When A is not anti-Hermitian, the solution ∣u(t)⟩=e−At∣u0⟩ is non-unitary and cannot be directly implemented as a quantum gate.We decompose A=L+iH where:
H=2i1(A−A†) is Hermitian (the conservative/oscillatory part),
L=21(A+A†) is positive semidefinite (the dissipative/damping part).
Source terms. The homogeneous equation above can be extended to the inhomogeneous case dtd∣u⟩=−A∣u⟩+∣b(t)⟩.Via Duhamel’s principle, the solution is∣u(t)⟩=e−At∣u0⟩+∫0te−A(t−s)∣b(s)⟩ds.Each term involves evaluating the non-unitary propagator e−Aτ and can therefore be handled by LCHS. In practice, the integral is discretized using a quadrature rule, and each quadrature point contributes an additional LCHS call at the corresponding time (t−s) (see [5], Sec. 1.1.2 and [2]).
The central insight of LCHS is the integral identity (Eq. 4 in [5], originally [1]):e−At=2π1∫−∞∞f^(k)e−i(kL+H)tdk,where f^(k) is the Fourier transform of a function f chosen to satisfy f(x)=e−x for x≥0.For each k∈R, the matrix H+kL is Hermitian, so the exponential e−i(kL+H)t is a unitary operator that can be implemented using standard Hamiltonian simulation techniques.In practice this integral is truncated to a finite interval [−R,R] (where R 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 f need only approximate exponential decay (rather than match it exactly), which circumvents a no-go result from prior work and enables the optimal O(αAtlog(1/ϵ)) query complexity.
Reference [5] uses the kernel function (Eq. 9, with j=2, y=1):f^2(k;γ,c)=2π21+k2ec(1−ik)e−(k2+1)/(4γ2).This is a product of a Lorentzian 1/(1+k2) and a Gaussian e−k2/(4γ2).The Lorentzian alone is the Fourier transform of exact exponential decay e−∣x∣, but its tails decay only as 1/k2, making it expensive to truncate the integral.The Gaussian envelope suppresses the tails exponentially, enabling truncation to a finite interval [−R,R] 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 R.The shift parameter c controls the normalization factor αf^2≤ec, which determines the post-selection success probability.Theorem 2 of [5] sets γ=c1c+logϵlchs1+1/(2π) and R=2cγ2 to guarantee kernel approximation error ≤ϵlchs.
The integral is discretized on a uniform grid of N=2J points with spacing h=2R/N over the interval [−R,R) ([5], Theorem 3, which proves exponential convergence of the uniform quadrature):e−At≈2πhj=−N/2∑N/2−1f^2(kj)e−i(kjL+H)t,kj=h⋅j.The stepsize h is chosen according to:h≤∥L∥⋅t/2+log(15ϵdisc64e3c/2)π,The number of grid points N=2J is then J=⌈log2(2R/h)⌉.Note that a uniform quadrature is sufficient.This sum is implemented via LCU, with the kernel values f^2(kj) as coefficients.
The full LCHS quantum circuit consists of the following components:
Kernel state preparation: Load ∣f^2(kj)∣ into an auxiliary register ∣j⟩.
Block-encoding of H+kjL: For each grid point j, block-encode the Hermitian operator (H+kjL)/α, where α=αLR+αH is the normalization.
Hamiltonian simulation: In this demo we apply the Jacobi-Anger polynomial approximation of e−i(H+kjL)αt using Generalized QSP on the walk operator derived from the block encoding.
Post-selection: Measure all auxiliary qubits in the ∣0⟩ state to extract the desired output.
We define the Hamiltonians H and L and derive all algorithm parameters — state size, block-encoding normalization, kernel shape, and error budget — from these operators and the desired precision.
H_PAULI = 0.5 * Pauli.X(0) * Pauli.X(1) + 0.5 * Pauli.Z(0) * Pauli.Z(1)L_PAULI = 0.5 * Pauli.I(0) * Pauli.I(1) + 0.5 * Pauli.Z(0) * Pauli.I(1)STATE_SIZE = H_PAULI.num_qubitsn_pauli_terms = max(len(H_PAULI.terms), len(L_PAULI.terms))BLOCK_SIZE = max(1, int(np.ceil(np.log2(n_pauli_terms))))alpha_H = sum(abs(t.coefficient) for t in H_PAULI.terms)alpha_L = sum(abs(t.coefficient) for t in L_PAULI.terms)T = 1 # evolution timeGQSP_EPS = 1e-5 # GQSP polynomial approximation errorLCHS_EPS = 1e-2 # LCHS kernel approximation error (Theorem 2 of [5])DISC_EPS = 1e-2 # discretization / quadrature error (Theorem 3 of [5])EPS = GQSP_EPS + LCHS_EPS + DISC_EPSc = 2.0 # kernel shift (trades normalization e^c vs. integration range)gamma = np.sqrt(c + np.log((1 + 1 / (2 * np.pi)) / LCHS_EPS)) / cR = 2 * c * gamma**2 # truncation radiush = np.pi / ( alpha_L * T / 2 + np.log(64 * np.exp(3 * c / 2) / (15 * DISC_EPS))) # step sizeJ_SIZE = int(np.ceil(np.log2(2 * R / h)))h = R / 2 ** (J_SIZE - 1) # actual h after rounding to power-of-2 gridalpha_tot = alpha_L * R + alpha_HGQSP_SCALE_FACTOR = 0.99print(f"Derived: gamma={gamma:.4f}, R={R:.4f}, J_SIZE={J_SIZE}")print(f"Errors: GQSP_EPS={GQSP_EPS}, LCHS_EPS={LCHS_EPS}, DISC_EPS={DISC_EPS}")print(f" EPS (total) = {EPS}")
For each grid point j, we need a block-encoding of the Hermitian operatorαH+kjL,α=αLR+αH.This is achieved by an LCU decomposition:αH+kjL=ααLR⋅Rkj⋅αLL+ααH⋅αHH.The factor kj/R is block-encoded using a linear amplitude encoding: ∣j⟩∣0⟩↦2J−1j∣j⟩∣0⟩+∣⊥⟩, which embeds the linear function of j into an amplitude.The other constants are applied as part of the LCU probabilities.The Pauli-decomposed operators H and L (defined in the parameters cell above) are each block-encoded via lcu_pauli, which implements the LCU of Pauli terms using ancilla qubits.
@qfuncdef block_encode_H(x: QNum, block: QArray): lcu_pauli(H_PAULI * (1 / alpha_H), x, block)@qfuncdef block_encode_L(x: QNum, block: QArray): lcu_pauli(L_PAULI * (1 / alpha_L), x, block)@qfuncdef linear_be(x: QNum, ind: QBit): """ Linear block-encoding: |j>|0> -> (j/2^(J-1))|j>|0> + |perp>.Encodes the linear dependence on the grid index j. """ assign_amplitude_table( amplitudes=lookup_table(lambda y: np.abs(y) / 2 ** (x.size - 1), x), index=x, indicator=ind, ) X(ind) control(x < 0, lambda: phase(pi))@qfuncdef block_encode_hamiltonians(qvar: LchsVar): """ Block-encode sum_j |j><j| (h*j*L + H) / (R*alpha_L + alpha_H) using an LCU of the linear*L and H block-encodings. """ lcu( [alpha_L * R, alpha_H], unitaries=[ lambda: ( linear_be(qvar.j, qvar.block.linear_block), block_encode_L(qvar.x, qvar.block.matrices_block), ), lambda: block_encode_H(qvar.x, qvar.block.matrices_block), ], block=qvar.block.lcu_block, )
Given the block-encoding UA of (H+kjL)/α, we construct the walk operator W=(2∣0⟩⟨0∣−I)⋅UA, whose eigenvalues are e±iarccos(λi/α) for each eigenvalue λi of (H+kjL).We then use GQSP with a Jacobi-Anger polynomial approximation to implement e−iλit as a function of cos−1(λi/α), effectively realizing the Hamiltonian simulation e−i(H+kjL)t within the block.
@qfuncdef walk_operator(block_encoding: QCallable[LchsVar], qvar: LchsVar): """Walk operator: block_encoding followed by reflect-about-zero on the block.""" block_encoding(qvar) reflect_about_zero(qvar.block)@qfuncdef lchs_hamiltonian_simulation(qvar: LchsVar, aux: QBit, t: float): """ Simulate exp(-i(H + k_j L) * t) for all j simultaneously using GQSP.The effective time is alpha * t due to the block-encoding normalization. """ t_effective = alpha_tot * t poly_degree = poly_jacobi_anger_degree(GQSP_EPS, t_effective) poly_exp_cos = GQSP_SCALE_FACTOR * poly_jacobi_anger_exp_cos( poly_degree, -t_effective ) phases = gqsp_phases(poly_exp_cos) walk = lambda: walk_operator(block_encode_hamiltonians, qvar) gqsp( u=walk, aux=aux, phases=phases, negative_power=poly_degree, )
The kernel state preparation loads the absolute values ∣f^2(kj)∣ into the ∣j⟩ register.The complex phase of the kernel, e−ikjc=e−ihcj, is applied as a separate phase gate after the Hamiltonian simulation.
def kernel_func(k): """Absolute value of the kernel for state preparation.""" return 1 / np.sqrt(1 + k**2) * np.exp(-(k**2) / (8 * gamma**2))@qfuncdef prepare_lchs_kernel(x: QNum): """Prepare |f_hat_2(k_j)| into the j register.""" amplitudes = lookup_table(lambda j: kernel_func(h * j), x) inplace_prepare_amplitudes(amplitudes, 0, x)@qfuncdef apply_kernel_phase(j: QNum): """Apply the kernel phase e^{-i*h*c*j}.""" phase(-h * c * j)
We define the main function, synthesize the circuit, and execute it using a statevector simulator. We post-select on the block register being ∣0⟩ to extract the LCHS output state.
Access model: The algorithm assumes block-encoding access to H and L separately. If only access to A=L+iH is available, one can extract H and L via H=2i1(A−A†) and L=21(A+A†), though this may double the block-encoding cost. Alternatively, as noted in [5] (Sec. 1.1.5), one can block-encode kL+H directly from a block-encoding of A using the identity kL+H=2(k−i)A+((k−i)A)†.
Time-dependent case: If H or L 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).
The LCHS framework in [5] is stated in full generality for time-dependent A(t).
Normalization and post-selection: The LCU of the kernel introduces a normalization factor αf^2=ecerfc(1/(2γ))≤ec, which is Θ(1) for constant c[5].
The final result is obtained by post-selecting on all block qubits being ∣0⟩, with success probability determined by this normalization and the GQSP scaling factor.
Scalable kernel preparation: The inplace_prepare_amplitudes function used here loads arbitrary amplitudes but does not scale efficiently. [5] (Theorem 4) provides an efficient circuit for preparing the kernel state with O(log(∥L∥+log(1/ϵ))log5/2(1/ϵ)) two-qubit gates.
[1] An, D., Liu, J.-P., & Lin, L. Linear Combination of Hamiltonian Simulation for Nonunitary Dynamics with Optimal State Preparation Cost. Physical Review Letters 131, 150603 (2023). arXiv:2303.01029[2] An, D., Childs, A. M., & Lin, L. Quantum algorithm for linear non-unitary dynamics with near-optimal dependence on all parameters. Communications in Mathematical Physics (2025). arXiv:2312.03916[3] Motlagh, D. & Wiebe, N. Generalized Quantum Signal Processing. PRX Quantum 5, 020368 (2024). arXiv:2308.01501[4]Hamiltonian Simulation with Block Encoding (Classiq Library)[5] Low, G. H. & Somma, R. D. Optimal quantum simulation of linear non-unitary dynamics. (2025). arXiv:2508.19238