# Amplitude Estimation¶

The amplitude estimation function creates a segment that estimates the probability of the "good" states of a quantum state [1]. A quantum state can be decomposed into "good" and "bad" states. The amplitude estimation algorithm takes a state preparation circuit and uses it with Grover's operator to assess the probability of the good states. The algorithm ends with an inverse QFT applied to the evaluation qubits, which can be measured to obtain the required probability.

## Syntax¶

Function: AmplitudeEstimation

Parameters:

• grover_operator: GroverOperator. The Grover operator used in the algorithm, composed of the oracle and the state preparation operator.
• estimation_register_size: PositiveInt. The number of qubits used to estimate the amplitude. A bigger register provides a better estimate of the good states' amplitude.

## Example¶

{
"constraints": {"optimization_parameter": "width"},
"logic_flow": [
{
"function": "AmplitudeEstimation",
"function_params": {
"grover_operator": {
"oracle": {
"expression": "a == b",
"definitions": {
"a": {
"size": 2,
"name": "a"
},
"b": {
"size": 1,
"name": "b"
}
}
},
"state_preparation": {
"probabilities": [0.15, 0.19, 0.11, 0.05, 0, 0.23, 0, 0.27],
"error_metric": {"KL": {"upper_bound": 0}}
}
},
"estimation_register_size": 2
}
}
]
}

from classiq import Model
from classiq.model import Constraints, OptimizationParameter
from classiq.builtin_functions import (
ArithmeticOracle,
GroverOperator,
StatePreparation,
AmplitudeEstimation,
)

oracle_params = ArithmeticOracle(
expression="a == b",
definitions=dict(a=dict(size=2), b=dict(size=1)),
)
state_preparation_params = StatePreparation(
probabilities=[0.15, 0.19, 0.11, 0.05, 0, 0.23, 0, 0.27],
error_metric={"KL": {"upper_bound": 0}},
)
grover_operator_params = GroverOperator(
oracle=oracle_params, state_preparation=state_preparation_params
)
qae_params = AmplitudeEstimation(
grover_operator=grover_operator_params,
estimation_register_size=3,
)

model = Model()
model.AmplitudeEstimation(params=qae_params)
constraints = Constraints(optimization_parameter=OptimizationParameter.WIDTH)
circuit = model.synthesize(constraints=constraints)
circuit.show_interactive()


The example above shows a circuit that implements amplitude estimation. The good basis states are defined (in the SDK code) through oracle_params of grover_operator_params.

The quantum circuit for preparing the state to be estimated is defined by state_preparation, that can load different probabilities for different states.

estimation_register_size is the number of evaluation qubits used in the inverse QFT, in addition to the qubits from the state preparation. A higher parameter leads to a more accurate result.

The output of the inverse QFT block is used to calculate the estimated probability for the good states.

## References¶

[1] G. Brassard, P. Hoyer, M. Mosca, and A. Tapp, “Quantum Amplitude Amplification and Estimation,” arXiv:quant-ph/0005055, vol. 305, pp. 53–74, 2002, doi: 10.1090/conm/305/05215. https://arxiv.org/abs/quant-ph/0005055