Hello Everyone,
I am trying to perform Hamiltonian simulation by building a circuit using linear combinations of cos(Ht)
and -isin(Ht)
similar to the attached pic.
I was able to find phase factors for cos(Ht)
using pyqsp and QSPPACK packages. However, I can’t seem to approximate -isin(Ht)
as a polynomial (because its complex) and calculate phase factors using above packages.
I would like to know if there is any other alternative way to build -isin(Ht)
by first approximating -sin(Ht)
and multiply using a quantum gate to obtain -isin(Ht)
.
Or, is there any other way to approximate -isin(Ht)
using these packages.
Thanks a lot for the assistance!
P.S: This is my code for calculating phase factors using pyqsp package.
# Import relevant modules and methods.
import matplotlib.pyplot as plt
import numpy as np
from pyqsp import angle_sequence, response
from pyqsp.poly import PolyTaylorSeries
# Specify definite-parity target function for QSP.
func = lambda x: np.sin(3 * x)
polydeg = 3 # Desired QSP protocol length.
max_scale = 0.5 # Maximum norm (<1) for rescaling.
true_func = lambda x: max_scale * func(x) # For error, include scale.
"""
With PolyTaylorSeries class, compute Chebyshev interpolant to degree
'polydeg' (using twice as many Chebyshev nodes to prevent aliasing).
"""
poly = PolyTaylorSeries().taylor_series(
func=func,
degree=polydeg,
max_scale=max_scale,
chebyshev_basis=True,
cheb_samples=2 * polydeg,
)
# Compute full phases (and reduced phases, parity) using symmetric QSP.
(phiset, red_phiset, parity) = angle_sequence.QuantumSignalProcessingPhases(
poly, method="sym_qsp", chebyshev_basis=True
)
"""
Plot response according to full phases.
Note that `pcoefs` are coefficients of the approximating polynomial,
while `target` is the true function (rescaled) being approximated.
"""
response.PlotQSPResponse(
phiset, pcoefs=poly, target=true_func, sym_qsp=True, simul_error_plot=True
)