Iterative Quantum Phase Estimation#

IQPE(args, U, precision, iter_spec=False, ctrl_method=None, kwargs={})[source]#

Evaluates the iterative quantum phase estimation algorithm.

The unitary to estimate is expected to be given as Python function, which is called on args.

Parameters:
argslist

A list of arguments (could be QuantumVariables) which represent the state, the quantum phase estimation is performed on.

Ufunction

A Python function, which will receive the list args as arguments in the course of this algorithm.

precisionint

The precision of the estimation.

iter_specbool, optional

If set to True, U will be called with the additional keyword iter = i where i is the amount of iterations to perform (instead of simply calling U for i times). The default is False.

ctrl_methodstring, optional

Allows to specify which method should be used to generate the controlled U circuit. For more information check .control. The default is None.

kwargsdict, optional

A dictionary of keyword arguments to pass to U. The default is {}.

Returns:
thetafloat

The estimated phase as a fraction of \(2 \pi\).

Examples

We define a function that applies two rotations onto its input and estimate the applied phase.

from qrisp import IQPE, h, run, x, rx, QuantumFloat
from qrisp.jasp import make_jaspr
import numpy as np

def f():
    def U(qv):
        x = 1/2**3
        y = 1/2**2

        rx(x*2*np.pi, qv[0])
        rx(y*2*np.pi, qv[1])

    qv = QuantumFloat(2)

    x(qv)
    h(qv)

    return IQPE(qv, U, precision = 4)
jaspr = make_jaspr(f)()
>>> jaspr()
Array(0.375, dtype=float64)