Skip to documentation
← Algorithm guides

Algorithm guide · oracle

Amplitude estimation

Estimate the chance of a marked outcome after a configurable state preparation.

Circuit size: 2–4 search + 2–4 counting qubits

Before you begin

Quantum counting · State preparation · Independent event probabilities

Review quantum fundamentals →
Notation used in this lesson
|ψ⟩ and ⟨ψ|
A state vector (ket) and its conjugate transpose (bra). ⟨a|b⟩ is their inner product.
α, β and i
α and β are complex amplitudes; i²=−1. A probability is the squared magnitude |α|².
XOR, · and ⊗
XOR adds bits modulo two. In s·x, multiply corresponding bits and XOR them. ⊗ combines registers or operations on different wires.
U†, Σ and Tr
U† is the adjoint (inverse for a unitary). Σ sums terms. Tr is the matrix trace, the sum of diagonal entries.
Probability, shots and angles
Ideal probabilities describe the model; measured shot frequencies fluctuate. Angles inside trigonometric expressions are in radians unless explicitly labeled turns.

1. The problem

Estimate the probability a that a prepared state lies in a marked success subspace. Counting is the special case of uniform preparation; here biased input preparation makes different basis strings have different weights.

2. How it works

Replace Grover’s uniform starting state with A|0…0⟩. The iterate reflects about that prepared state and the marked subspace. Its phase encodes success probability, even when counting the number of marked strings would give the wrong answer.

  1. Prepare A

    Each search qubit receives a rotation with P(1)=p.

  2. Build amplification iterate

    Combine the success oracle with a reflection using A and A inverse.

  3. Estimate its phase

    Use controlled powers and inverse QFT on the counting register.

  4. Decode probability

    Map measured y to sin²(πy/2ᵗ).

3. The mathematics, one idea at a time

P(x)=p^w (1−p)^(n−w); a=Σ_(marked x) P(x)

w is the number of 1 bits in x. Probabilities multiply because this preparation is a product across wires.

a_est=sin²(πy/2ᵗ)

There is no extra factor N: the result is a probability, not a count.

Work this through by hand

4. A smallest exact phase example

Two search and two counting qubits are the supported minima.

Set preparation P(1)=0.5 and successful states 00 and 11.

StageCalculation or stateWhat it means
Prepared weightsEach of 00,01,10,11 has probability 1/4The two marked states together have a=1/2.
Phase estimationθ=π/4 ⇒ y=1 or 3 on a four-bin rulerBoth phases fit exactly.
Probability decodesin²(π/4)=sin²(3π/4)=1/2Each peak means a 50% prepared success probability.

Expected outcomes for this example

These are ideal predictions for the stated configuration, not a result already measured by your browser. Rows describing alternative modes or combined events are labeled explicitly.

Outcome or eventIdeal probabilityInterpretation
0150% idealEstimated a=0.5.
1150% idealAlso estimated a=0.5.

5. Load the worked example in Composer

The worked example can use smaller or simpler inputs than the gallery defaults. The button below loads the exact circuit used in this lesson.

Search qubits (n)
2
Counting qubits (t)
2
Preparation P(1) per search qubit
0.5
Successful states
00,11
  1. Save any current circuit you want to keep, then open the worked example. Loading it does not execute a paid hardware job.
  2. Trace the preparation, main operations and measurements against the worked table. Check the gate editor for controls, targets and angles.
  3. Start with an ideal noiseless simulator compatible with the circuit. Mid-circuit measurement, reset and feed-forward require support from the chosen backend.
  4. Inspect the live preview. For a recorded experiment, open Execute, set the available backend options and shots, and Run. Sign in when prompted to retain it in My Jobs.
  5. Read the output as described below before changing one setting and repeating. The guide describes the original example; edits can change the answer.

6. Read the output correctly

The histogram is over counting bits, not direct success/failure samples.

This card’s marked-state input uses q0 first, unlike ordinary Grover’s MSB-first field. The symmetric marks here avoid ambiguity. With p=0.25 and mark 10, the prepared probability is 0.25×0.75=0.1875, not 1/4.

A bit label is a register value; its bar height is a probability or count. For S shots and observed count k, the sampled frequency is k/S. A typical sampling scale for probability p is √[p(1−p)/S]; this is not a strict error bound. Finite samples do not have to match the ideal percentages exactly.

7. Common mistakes & limits

  • Counting marked strings is insufficient when preparation is biased.
  • A finite t-bit phase ruler does not promise an exact estimate for every a. Extra shots reduce sampling noise, not the finite-grid approximation itself.

8. Check your understanding

For n=2, p=0.25 and success 11, what probability is being estimated?

Reveal the reasoning

a=p²=1/16=0.0625. Both search wires must be 1.

9. Further study

The lesson’s register mappings, supported inputs and loadable example follow Quantket’s implemented circuit. A reference may use different wire names, bit order or resource conventions.

Gallery reference: defaults, definitions & implementation notes

Inputs & default settings

These are the gallery defaults. The worked example above may override them. Configure the card to change the inputs before loading its editable circuit.

Search qubits (n)
Default: 2 · Whole number from 2 to 4.
Counting qubits (t)
Default: 3 · Whole number from 2 to 4.

Uses 2^t phase bins and 2^t − 1 controlled Grover iterations. Higher precision makes a deeper circuit.

Preparation P(1) per search qubit
Default: 0.25 · A probability from 0 to 1 inclusive.

A applies RY(2 asin √p) on each search qubit. p=0.5 reproduces uniform quantum counting; other values prepare nonuniform probabilities.

Successful states
Default: 10 · Comma-separated 2-character marks (up to 16). _ means either bit. The leftmost character is q0.

One or more disjoint bitstrings. _ accepts either bit. The estimated value is the total prepared probability of these states.

Implementation notes

This example uses the gallery's default configuration. Check Run details for the settings used in your execution.

A prepares each search qubit q0–q1 with P(1)=p. Marked strings read q0 first. Counting wires q2–q4 measure into c0–c2. Read the Classical bits histogram as c2…c0; paired phase outcomes give the same success-probability estimate. Finite phase precision and shots make individual estimates approximate.

Default example: predictions & circuit facts

These values describe the unedited default setup. They are predictions and circuit properties, not measured results from your saved execution.

Oracle queries
7
Phase bins
8
Prepared success P
18.75%

Read your saved result

Check the submitted circuit, measured register and execution settings in Run details. Exact results give computed probabilities; sampled results show frequencies from the recorded shots. Edited circuits and noise can change the expected outcome. The algorithm label records the circuit's origin; it does not certify an edited circuit or a measured result.