1. Quantum Datasets
  2. /1/x QSVT Angles
  1. Quantum Datasets
  2. /1/x QSVT Angles

1/x QSVT Angles

1/x QSVT Angles

1/x QSVT Angles dataset visualization

This dataset contains phase angles to approximate the function 1/x1/x via Quantum Signal Processing (QSP) and Quantum Singular Value Transformation (QSVT).

Description of the dataset

QSVT and QSP are powerful quantum algorithms that implement a large class of polynomial transformations. However, many of the operators in these algorithms depend on a series of phase angles that correspond to the desired polynomial. While calculating these angles can be done efficiently in practice, it is not always straightforward. This dataset provides phase angles to implement QSVT and QSP for an approximation of 1/x1/x, making it easy to implement this polynomial without additional calculations.

More specifically, we approximate f(x)=12κxf(x) = \frac{1}{2\kappa x} with a Chebyshev polynomial, P(x)P(x). The values κ\kappa and ϵ\epsilon define the approximation:

  • Kappa is a scaling factor in f(x)f(x) and determines in which interval the function is approximated.
  • Epsilon represents the maximum error allowed in the polynomial approximation: maxxP(x)f(x)\max_{x}|P(x)-f(x)|

Additional Details

  • The Chebyshev polynomials P(x)P(x) in this dataset approximate the function f(x)=12κxf(x) = \frac{1}{2\kappa x} over the interval [1,1/κ)(1/κ,1][-1, -1/\kappa) \cup (1/\kappa, 1] with a maximum error of ϵ\epsilon.
  • κ\kappa can take values from the set {1,5,50,100,250,500,1000,1500}\{1, 5, 50, 100, 250, 500, 1000, 1500\}, and its choice depends on the specific interval where we aim to approximate the function.
  • The Chebyshev polynomial, P(x)P(x) can be accessed via dataset.poly[epsilon][kappa]. This returns an array where, for example, [1,0,2][1, 0, 2] corresponds to the polynomial 1T0(x)+0T1(x)+2T2(x)1 \cdot T_0(x) + 0 \cdot T_1(x) + 2 \cdot T_2(x), where Tn(x)T_n(x) denotes the nn-th Chebyshev polynomial.
  • Phase angles to implement these Chebyshev polynomials via QSP (or QSVT) can be accessed using dataset.angles[routine][epsilon][kappa]
  • This dataset was generated using numerical optimization techniques to find optimal phase angles that minimize the error in the polynomial approximation.

Graphical Representation

The following figure illustrates the polynomial approximation of f(x)=12κxf(x) = \frac{1}{2\kappa x} with κ=250\kappa = 250 and ϵ=0.01\epsilon = 0.01:

drawing

The blue line represents the polynomial approximation, the orange dashed line corresponds to f(x)f(x), and the red dashed lines show x=±1/κx = \pm 1/\kappa.

Example usage

The following example shows how to plot the output of the QSVT algorithm and compare to the original Chebyshev approximation.

import pennylane as qml
import numpy as np
import matplotlib.pyplot as plt

[dataset] = qml.data.load("other", name="inverse")
angles_qsvt = dataset.angles["qsvt"]["0.01"]["100"] 

outputs_qsvt = []
points = np.arange(-1, 1, 1/300)

for x in points:

    # Encode x in the top left of the matrix
    block_encoding = qml.RX(2 * np.arccos(x), wires=0)
    projectors = [qml.PCPhase(angle, dim=1, wires=0) for angle in angles_qsvt]

    @qml.qnode(qml.device("default.qubit"))
    def circuit_qsvt():
        qml.QSVT(block_encoding, projectors)
        return qml.state()

    output = qml.matrix(circuit_qsvt, wire_order=[0])()[0, 0]

    outputs_qsvt.append(output.real)

poly = np.polynomial.Chebyshev(dataset.poly['0.01']['100'])
outputs_poly = [poly(point) for point in points]

plt.plot(points, outputs_qsvt, '.')
plt.plot(points, outputs_poly)
plt.show()

Authors

Guillermo Alonso

Updated

2025-06-16

version 0.1 : initial public release



Guillermo Alonso

Guillermo Alonso

Quantum Scientist specializing in quantum algorithms