# Qiskit: Get number of iterations for Iterative Amplitude Estimation

Trying to count the number of uses of my circuit $$A$$ in Grover iterate circuit $$Q= -AS_0A^{\dagger}S_x$$.

However, Qiskit's amplitude estimation algorithms such as IAE or FAE accept only precision arguments like e.g. confidence of solution, error. I run them like this:

from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem, FasterAmplitudeEstimation

problem = EstimationProblem(state_operation=myqc, objective_qubits=)
algorithm = IterativeAmplitudeEstimation(**kwargs)
result = algorithm.estimate(problem)
amplitude = result.estimation


How can I get the number of total iterations along with the result or at least get the circuit? Do I need to create my own implementations of the algorithms?

For the number of iterations, you can do

for i,j in enumerate(result_delta._estimate_intervals):
print(i,np.mean(j))


For the circuit result, you can try to do result.circuit_results, it might return a Statevector or counts dictionary.
and algorithm.construct_circuit(problem) to check the problem circuit.

#recommend way to view the problem gate
from qiskit import transpile
transpile(ae_delta.construct_circuit(problem),basis_gates = ['ry', 'cx','ccx','x']).draw()


For any more related coding questions, you can just do something like dir(result) to see its attribute, then check sources code or docs about these attributes for the explanation.

hope it is something you are looking for

• accept answer will help a lot thank you
– poig
Jun 23, 2022 at 4:06
• Thanks a lot for your advice!. Could you elaborate a bit further about the estimate_intervals attribute? How is it supposed to help? And why not use num_oracle_queries? Jul 5, 2022 at 11:39
• I think you can simply look at the docs and sources code to understand that, num_oracle_queries Return the number of Grover oracle queries. and estimate_intervals Return the confidence intervals for the estimate in each iteration.
– poig
Jul 5, 2022 at 15:07
• Docs helped indeed, but you confused me a bit since I was asking for iterations/queries and you said about estimate_intervals. Nevertheless, you helped a lot so I can give you this answer. Jul 6, 2022 at 7:36