qsvt_phases
qsvt_phases(
poly_coeffs: np.ndarray,
cheb_basis: bool = True
) -> np.ndarray
Get QSVT phases that will generate the given Chebyshev polynomial.
The phases are ready to be used in qsvt and qsvt_lcu functions in the classiq library. The convention
is the reflection signal operator, and the measurement basis is the hadamard basis (see https://arxiv.org/abs/2105.02859
APPENDIX A.).
The current implementation is using the nlft-qsp package.
Parameters:
qsp_approximate
qsp_approximate(
f_target: Callable[[float], complex],
degree: int,
parity: int | None = None,
interval: tuple[float, float] = (-1, 1),
bound: float = 0.99,
num_grid_points: int | None = None,
plot: bool = False
) -> tuple[np.ndarray, float]
Approximate the target function on the given (sub-)interval of [-1,1], using QSP-compatible chebyshev polynomials.
The approximating polynomial is enforced to |P(x)| <= bound on all of [-1,1].
Note: scaling f_target by a factor < 1 might help the convergence and also a later qsp phase factor finiding.
Parameters:
Returns:
- Type:
tuple[np.ndarray, float] - Array of Chebyshev coefficients. In case of definite parity, still a full coefficients array is returned.
- (Approximated) maximum error between the target function and the approximating polynomial within the interval.
gqsp_phases
gqsp_phases(
poly_coeffs: np.ndarray,
cheb_basis: bool = False
) -> list[tuple[float, float, float]]
Compute GQSP phases for a polynomial in the monomial (power) basis.
The returned phases are compatible with Classiq’s gqsp function and use the Wz signal
operator convention.
The current implementation is using the nlft-qsp package, based on techniques in https://arxiv.org/abs/2503.03026.
Notes:
- The polynomial must be bounded on the unit circle: <= 1 for all theta in .
- Laurent polynomials are supported by degree shifting. If degree-shifted polynomial (so the minimal degree is zero).
- The phase finiding works in the monomial basis. If a Chebyshev basis polynomial is provided, it will be converted to the monomial basis (and introduce an additional overhead).
Returns:
- Type:
list[tuple[float, float, float]] - list of (theta, phi, lambda) tuples of length d+1, ready to use with
gqsp.
poly_jacobi_anger_cos
poly_jacobi_anger_cos(
degree: int,
t: float
) -> np.ndarray
Gets the Chebyshev polynomial coefficients approximating cos(t*x) using the Jacobi-Anger expansion.
Parameters:
poly_jacobi_anger_sin
poly_jacobi_anger_sin(
degree: int,
t: float
) -> np.ndarray
Gets the Chebyshev polynomial coefficients approximating sin(t*x) using the Jacobi-Anger expansion.
Parameters:
poly_jacobi_anger_exp_sin
poly_jacobi_anger_exp_sin(
degree: int,
t: float
) -> np.ndarray
Gets the Chebyshev polynomial coefficients approximating exp(itsin(x)) using the Jacobi-Anger expansion:
Parameters:
poly_jacobi_anger_exp_cos
poly_jacobi_anger_exp_cos(
degree: int,
t: float
) -> np.ndarray
Gets the Chebyshev polynomial coefficients approximating exp(itcos(x)) using the Jacobi-Anger expansion:
Parameters:
poly_inversion
poly_inversion(
degree: int,
kappa: float,
error_type: str | ErrorType = ErrorType.RELATIVE
) -> tuple[np.ndarray, float]
Gets the Chebyshev odd polynomial p(x) coefficients approximating 1/x on [1/kappa, 1].
Based on the papers: https://dl.acm.org/doi/pdf/10.1145/3649320 - for optimal polynomial that minimizes the relative error |xp(x)-1| for
x in [1/kappa,1]; and https://arxiv.org/pdf/2507.15537- for optimal polynomial that minimizes the uniform error |p(x)-1/x| for x in [1/kappa,1].
The relative error refers to |xp(x)-1|, whereas the uniform error refers to |p(x)-1/x|, both for x in [1/kappa,1].
Parameters:
Returns:
- Type:
tuple[np.ndarray, float] - The Chebyshev polynomial coefficients approximating 1/x on [1/kappa, 1] using the optimal polynomial of given degree.
- An upper bound on the maximum absolute value of the polynomial on [-1, 1]. The value can be used to scale down the polynomial for the usage within QSVT.