QSPPACK
  • Homepage
  • Examples
    • Quantum linear system problems
    • Negative power function
    • Quantum Hamiltonian simulation
    • Quantum Gaussian filter
    • Singular value threshold projector
    • Singular vector transformation
    • Uniform singular value amplification
    • Gaussian state
    • Kaiser window state
    • Gibbs state
Powered by GitBook
On this page
  • What is quantum Gaussian filter
  • The equivalent problem in function approximation
  • Set up parameters
  • Solving phase factors by running the solver
  • Verifying the solution
  • Reference
  1. Examples

Quantum Gaussian filter

PreviousQuantum Hamiltonian simulationNextSingular value threshold projector

Last updated 1 year ago

In this example, We introduce the implementation of quantum Gaussian filter.

What is quantum Gaussian filter

Gaussian filter is a function localized around the parameter μ\muμ. Interpreting this parameter as the desired energy level, the quantum Gaussian filter is an operator of the system Hamiltonian which acts as the projection onto an energy subspace near it. Given a Hamiltonian HHH, the quantum Gaussian filter is

exp⁡(−(H−μI)2/σ2).\exp(-(H-\mu I)^2/\sigma^2).exp(−(H−μI)2/σ2).

Here, μ\muμ is the parameter for location and σ2\sigma^2σ2controls the width.

Quantum Gaussian filter is used as a useful subroutine in preparing ground state and solving linear system problems. We refer the interested readers to Ref. for more details.

The equivalent problem in function approximation

Suppose the Hamiltonian is normalized and shifted so that 0≺H≺I0 \prec H \prec I0≺H≺I. The interval of interest becomes x∈(0,1)x \in (0, 1)x∈(0,1). Hence, we only need to approximate the following function accurately in the positive half interval to implement the quantum Gaussian filter f(x)∝exp⁡(−(x−μ)2/σ2)f(x) \propto \exp(- (x - \mu)^2 / \sigma^2)f(x)∝exp(−(x−μ)2/σ2). Extending this function as an even function, the target of the approximation is

f(x)∝exp⁡(−(∣x∣−μ)2/σ2).f(x) \propto \exp(-(|x|-\mu)^2 / \sigma^2).f(x)∝exp(−(∣x∣−μ)2/σ2).

Because the eigenvalue of the Hamiltonian is in x∈(0,1)x \in (0, 1)x∈(0,1), it suffices to implement the quantum Gaussian filter f(H)∝exp⁡(−(H−μI)2/σ2)f(H) \propto \exp(-(H-\mu I)^2/\sigma^2)f(H)∝exp(−(H−μI)2/σ2).

In numerical demonstration, we consider an even function f(x)=0.99∗e−(∣x∣−0.5)2/0.12f(x) = 0.99 * e^{-(|x|-0.5)^2/0.1^2}f(x)=0.99∗e−(∣x∣−0.5)2/0.12whose L∞L^{\infty}L∞ norm over [−1,1][-1,1][−1,1] is strictly bounded by 0.99≈10.99 \approx 10.99≈1, which is very close to the fully-coherent regime ∥f∥∞≈1\Vert f \Vert_\infty \approx 1∥f∥∞​≈1.

parity = 0;
targ = @(x) 0.99 * exp(-(abs(x)-0.5).^2/0.1^2);
% Compute its Chebyshev coefficients. 
d = 100;
% The second parameter of chebfun should be degree + 1.
% The function chebfun(F, N) characterizes the function F on a size-N grid
% by interpolation. Thus, the degree of the interpolated polynomial is N - 1.
f = chebfun(targ,d + 1);
coef = chebcoeffs(f);
% Only need part of Chebyshev coefficients.
coef = coef(parity+1:2:end);
visualizing polynomial approximation error
figure()
hold on
targ_value = targ(xlist);
plot(xlist,targ_value,'b-','linewidth',2)
plot(xlist,func_value,'-.')
hold off
xlabel('$x$', 'Interpreter', 'latex')
ylabel('$f(x)$', 'Interpreter', 'latex')
legend('target',  'polynomial',...
  'location','se')

figure()
plot(xlist,func_value-targ_value)
xlabel('$x$', 'Interpreter', 'latex')
ylabel('$f_\mathrm{poly}(x)-f(x)$', 'Interpreter', 'latex')

Set up parameters

opts.maxiter = 100;
opts.criteria = 1e-12;
opts.targetPre = true;
opts.method = 'Newton';
% use the real representation to speed up the computation
opts.useReal = true;

Solving phase factors by running the solver

[phi_proc,out] = QSP_solver(coef,parity,opts);

Verifying the solution

xlist = linspace(0,1,1000)';
func = @(x) ChebyCoef2Func(x, coef, parity, true);
targ_value = targ(xlist);
func_value = func(xlist);
QSP_value = QSPGetEntry(xlist, phi_proc, out);
err= norm(QSP_value-func_value,Inf);
disp('The residual error is');
disp(err);

figure()
plot(xlist,QSP_value-func_value)
xlabel('$x$', 'Interpreter', 'latex')
ylabel('$g(x,\Phi^*)-f_\mathrm{poly}(x)$', 'Interpreter', 'latex')
print(gcf,'quantum_gaussian_filter_error.png','-dpng','-r500');

Reference

  1. Lin, L., & Tong, Y. (2020). Optimal polynomial based quantum eigenstate filtering with application to solving quantum linear systems. Quantum, 4, 361.

  2. Lin, L., & Tong, Y. (2020). Near-optimal ground state preparation. Quantum, 4, 372.

  3. Dong, Y., Meng, X., Whaley, K. B., & Lin, L. (2021). Efficient phase-factor evaluation in quantum signal processing. Physical Review A, 103(4), 042419.

Output of the code
iter          err
   1  +2.0557e-01 
   2  +4.6388e-02 
   3  +8.9034e-03 
   4  +8.8606e-04 
   5  +1.3739e-05 
   6  +3.5193e-09 
Stop criteria satisfied.
The residual error is
   8.4377e-15
[1, 2]
Polynomial approximation of gaussian function
Polynomial approximation error
The point-wise error of the solved phase factors.