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 A, let |Ψ=A|0|False.

  • Write |Ψ=a|Ψ1|True+1a|Ψ0|False as a superposition of the orthogonal good and bad components of |Ψ.

  • Find an estimate for a, the probability that a measurement of |Ψ 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 |Ψ. This function will receive the variables in the list qargs as arguments in the course of this algorithm.

epsfloat

Accuracy ϵ>0 of the algorithm.

alphafloat

Confidence level α(0,1) of the algorithm.

mes_kwargsdict, optional

The keyword arguments for the measurement function. Default is an empty dictionary.

Returns:
afloat

An estimate a^ of a such that

P{|a^a|<ϵ}1α

Examples

We show the same Numerical integration example which can also be found in the QAE documentation.

We wish to evaluate

A=01f(x)dx.

For this, we set up the corresponding state_function acting on the variables in input_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)=sin2(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