View on GitHub
Open this notebook in GitHub to run it yourself
Simulating physical and chemical systems was among the original motivations for quantum computing, as first envisioned by Richard Feynman in 1982, and remains one of its most impactful applications. Time-independent Hamiltonian simulation refers to the task of approximately implementing the unitary evolution operator for a Hermitian matrix . When access to the Hamiltonian is provided via block-encoding, this can be realized by applying an appropriate polynomial transformation within a desired precision . Generalized Quantum Signal Processing (GQSP) [1] achieves this by applying a Laurent polynomial to the walk operator of the block-encoded Hamiltonian. The polynomial coefficients are derived from the Jacobi–Anger expansion (Eq. (1): ). GQSP requires only one auxiliary qubit and eliminates the need for amplitude amplification.A block-encoded Hamiltonian refers to its embedding within a larger unitary matrix. Definition: A -encoding of a matrix refers to completing it into a unitary matrix : with functional error . Here is a scaling factor that ensures the overall operator is unitary, is the number of auxiliary (block) qubits, and is the encoding error. This notebook assumes basic knowledge of Linear Combination of Unitaries (LCU); see the LCU tutorial for background. The GQSP approach implements polynomials on unitary operators. For Hamiltonian evolution, given an exact -encoding of the Hamiltonian (denoting ), we define the Szegedy quantum walk operator [2] , where reflects about the state of the block variable. The walk operator is unitary, with eigenvalues , where are the Hamiltonian eigenvalues. By the Jacobi–Anger expansion (Eq. (1)), the polynomial approximating as a Laurent series in gives on the eigenvalue (since ) — the desired time-evolution phase. Applying via GQSP therefore gives approximately in the block. GQSP computes a set of single-qubit rotation angles such that the resulting circuit block-encodes the desired polynomial: (In practice, our prefactor is slightly different, with which ensures numerical stability of the classical angle computation). Compared the the QSVT approach for Hamiltonian simulation, the GQSP method uses only one extra block qubit, and requires no amplitude amplification. However, it includes controlled operations on the block-encoding unitary.Complexity: calls to the block-encoding, using one auxiliary qubit and a classical preprocessing step to compute the GQSP rotation angles.
- Input: A Hermitian operator given through a block-encoding unitary with scaling factor , evolution time , and target error .
- Output: A unitary approximating , with .
Keywords: Hamiltonian Simulation, Block Encoding, Generalized Quantum Signal Processing, GQSP, Walk Operator, Oracle/Query complexity.
This notebook demonstrates Hamiltonian simulation using the GQSP method.For the other approaches, see the companion notebooks on QSVT and Qubitization.For a side-by-side comparison of all three methods, see the table at the end of this notebook.
Preliminaries
Setting a Specific Hamiltonian to Evolve
We set some specific hyperparameters for our problem. We use a simple Hamiltonian given as a sum of Pauli strings, and thelcu_pauli function to block-encode it via the Linear Combination of Unitaries (LCU) technique:
To treat different problems with the same algorithm, simply change theses hyperparameters.
Output:
Output:
Setting Up a Statevector Simulator
Working with block-encoding typically requires post-selection of the block variable being at state . The success of this process can be amplified via Oblivious Amplitude Amplification. In this notebook, instead, we use a statevector simulator and project the result. We import two utility functions fromhamiltonian_simulation_utils:
get_projected_state_vector: extracts the post-selected statevector from the execution results.compare_quantum_classical_states: aligns the global phase and computes the overlap with the classically computed reference.
The Jacobi–Anger Expansion
The polynomial approximation of the time evolution relies on the Jacobi–Anger expansion. For GQSP, we use the complex exponential form , implemented viapoly_jacobi_anger_exp_cos. We then compute the GQSP rotation angles from this polynomial using gqsp_phases.
Output:
The Walk Operator
Note: The current implementation assumes that the block-encoding unitary is also Hermitian. For the non-Hermitian generalization, see the Technical Notes.Given the block-encoding , we define the Szegedy quantum walk operator [2]: where is a reflection about the state of the block variable. As mentioned above, it has the key property that its spectrum is directly tied to the Hamiltonian’s eigenvalues: where is an eigenstate of with eigenvalue .
Verifying the Block-Encoding
As a sanity check before the main algorithm, we verify the Hamiltonian block-encoding: we apply on the initial state and check that the post-selected result matches as expected.Output:

Output:
Implementation
We define a Quantum Struct for the GQSP block-encoding. The GQSP method adds one block qubit (block_gqsp) to the Hamiltonian block variable (block_ham).
The data variable follows that of the Hamiltonian encoding.
Applying GQSP requires a negative power of the walk operator, since the approximating polynomial is a Laurent polynomial that includes negative powers of (corresponding to ).
This is handled by the negative_power parameter.
gqsp_hamiltonian_evolution function on the randomly prepared vector, synthesizes it, executes the resulting quantum program, and verifies the results.
Output:

Output:
References
[1]: Motlagh, D., and Wiebe, N. Generalized quantum signal processing. PRX Quantum 5, 020368 (2024). [2]: Szegedy, M. Quantum speed-up of Markov chain based algorithms. In 45th Annual IEEE Symposium on Foundations of Computer Science, pp. 32–41 (2004). [3]: Lin, L. Lecture notes on quantum algorithms for scientific computation. arXiv:2201.08309 [quant-ph] (2022).Technical Notes
Generalizing to Non-Hermitian Block-Encoding Unitaries
The current implementation assumes that the block-encoding unitary is also Hermitian. This assumption underlies the walk operator’s spectral properties. For a non-Hermitian block-encoding unitary, an analogous walk operator can be defined as , which satisfies equivalent spectral properties. See Section 7.4 in Ref. [3] for details.Comparison with Other Methods
| Method | extra block qubits | Controlled ? | Amplitude amplification? | Classical preprocessing |
|---|---|---|---|---|
| GQSP | 1 | Yes | No | Angle computation |
| QSVT | 2 | No | Yes (for a factor of 2) | Angle computation |
| Qubitization | Yes | Yes (for the sum of Cheb. coefficients) | None |