Iterative Quantum Amplitude Estimation#
- IQAE(qargs, state_function, eps, alpha, mes_kwargs={})[source]#
Accelerated Quantum Amplitude Estimation (IQAE). This function performs QAE with a fraction of the quantum resources of the well-known QAE algorithm. See Accelerated Quantum Amplitude Estimation without QFT.
The problem of iterative quantum amplitude estimation is described as follows:
Given a unitary operator \(\mathcal{A}\), let \(\ket{\Psi}=\mathcal{A}\ket{0}\ket{\text{False}}\).
Write \(\ket{\Psi}=\sqrt{a}\ket{\Psi_1}\ket{\text{True}}+\sqrt{1-a}\ket{\Psi_0}\ket{\text{False}}\) as a superposition of the orthogonal good and bad components of \(\ket{\Psi}\).
Find an estimate for \(a\), the probability that a measurement of \(\ket{\Psi}\) yields a good state.
- Parameters:
- qargslist[QuantumVariable]
The list of QuantumVariables which represent the state, the quantum amplitude estimation is performed on. The last variable in the list must be of type QuantumBool.
- state_functionfunction
A Python function preparing the state \(\ket{\Psi}\). This function will receive the variables in the list
qargs
as arguments in the course of this algorithm.- epsfloat
Accuracy \(\epsilon>0\) of the algorithm.
- alphafloat
Confidence level \(\alpha\in (0,1)\) of the algorithm.
- mes_kwargsdict, optional
The keyword arguments for the measurement function. Default is an empty dictionary.
- Returns:
- afloat
An estimate \(\hat{a}\) of \(a\) such that
\[\mathbb P\{|\hat{a}-a|<\epsilon\}\geq 1-\alpha\]
Examples
We show the same Numerical integration example which can also be found in the QAE documentation.
We wish to evaluate
\[A=\int_0^1f(x)\mathrm dx.\]For this, we set up the corresponding
state_function
acting on the variables ininput_list
:from qrisp import QuantumFloat, QuantumBool, control, z, h, ry, IQAE import numpy as np n = 6 inp = QuantumFloat(n,-n) tar = QuantumBool() input_list = [inp, tar]
For example, if \(f(x)=\sin^2(x)\), the
state_function
can be implemented as follows:def state_function(inp, tar): h(inp) N = 2**inp.size for k in range(inp.size): with control(inp[k]): ry(2**(k+1)/N,tar)
Finally, we apply IQAE and obtain an estimate \(a\) for the value of the integral \(A=0.27268\).
a = IQAE(input_list, state_function, eps=0.01, alpha=0.01)
>>> a 0.26782038552705856