This dataset contains phase angles to approximate the function cos(x)cos(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 cos(x)cos(x), making it easy to implement this polynomial without additional calculations.
More specifically, we approximate f(x)=cos(2k2πx)f(x)=cos(2k2πx) with a Chebyshev polynomial, P(x)P(x). The values kk and ϵϵ define the approximation:
Additional Details
dataset.poly[epsilon][k]
. This returns an array where, for example, [1,0,2][1,0,2] corresponds to the polynomial 1⋅T0(x)+0⋅T1(x)+2⋅T2(x)1⋅T0(x)+0⋅T1(x)+2⋅T2(x), where Tn(x)Tn(x) denotes the nn-th Chebyshev polynomial.dataset.angles[routine][epsilon][k]
Graphical Representation
The following figure illustrates the polynomial approximation of f(x)=cos(2k2πx)f(x)=cos(2k2πx) with k=1k=1 and ϵ=0.1ϵ=0.1:
The blue line represents the polynomial approximation and the orange dashed line corresponds to f(x)f(x).
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="cosine")
angles_qsvt = dataset.angles["qsvt"]["0.1"]["1"]
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.1']['1'])
outputs_poly = [poly(point) for point in points]
plt.plot(points, outputs_qsvt, '.')
plt.plot(points, outputs_poly)
plt.show()
Guillermo Alonso
version 0.1 : initial public release
Guillermo Alonso
Quantum Scientist specializing in quantum algorithms