Quantum Signal Processing (QSP) is a framework for applying polynomial transformations to quantum states. By alternating a signal operator W(theta) with phase operators S(phi), you can realize any bounded real polynomial of cos(theta) on the amplitude of a single qubit. This example implements the polynomial P(x) = 2x³ − x using a 5-gate sequence.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/itsubaki/qasm-playground/llms.txt
Use this file to discover all available pages before exploring further.
Circuit
The phase sequence is W(theta) → S(π/4) → W(theta) → S(−π/4) → W(theta), where:- W(theta) is the signal operator:
Rx(−2·theta), a rotation about the X axis - S(phi) is the phase operator:
U(0, 0, −2·phi), a Z-axis phase rotation
Quantum Signal Processing
Expected results
Withtheta = pi/6, the signal value is x = cos(π/6) = √3/2. The polynomial evaluates to:
P(x) = 2·(√3/2)³ − √3/2 = √3/4 ≈ 0.433013
After running, you should see two quantum states:
| Basis | Probability | Amplitude |
|---|---|---|
| |0⟩ | ≈ 0.1875 | ≈ 0.433013 + 0i |
| |1⟩ | ≈ 0.8125 | ≈ −0.5 + 0.75i |
The probability of |0⟩ is P(x)² = (√3/4)² = 3/16 ≈ 0.1875. The amplitude itself is P(x) ≈ 0.433013, which is what QSP encodes — the polynomial value appears as the real amplitude of the |0⟩ component.
How the circuit works
Define signal and phase operators
W(theta) applies Rx(−2·theta), a rotation by −2·theta around the X axis. S(phi) applies U(0, 0, −2·phi), a phase rotation around the Z axis. These are the two primitive QSP building blocks.Build the alternating sequence
The 5-gate sequence W → S(π/4) → W → S(−π/4) → W alternates signal and phase operators. The specific phase angles (π/4, −π/4) determine the polynomial being implemented — different phase sequences yield different polynomials.
Changing the input
To evaluate the polynomial at a different point, change thetheta constant:
Modified theta