Skip to documentation
← Algorithm guides

Algorithm guide · oracle

Deterministic Grover search

Use a prepared ancilla to make Grover's integer search rounds land exactly on a marked state in an ideal circuit.

Circuit size: n = 2..5 search qubits + 1 ancilla

Before you begin

Ordinary Grover rotations · RY preparation · A known marked fraction

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

Ordinary Grover’s best integer number of rounds can miss the target angle. When the marked fraction p=M/N is known, adjust the initial good probability so a whole number of rounds lands exactly on the marked subspace in an ideal circuit.

2. How it works

An extra qubit acts as an adjustable weight. A state is marked only when both the data is a target and this ancilla is 0. Tuning that joint starting weight lets the Grover rotation land at its peak.

  1. Choose whole rounds

    Select k so the target starting good probability p′ does not exceed p.

  2. Tune ancilla

    Prepare ancilla P(0)=p′/p using RY.

  3. Joint amplification

    Use an oracle conditional on ancilla 0 and reflect about the entire prepared data-plus-ancilla state. Measure the data answer.

3. The mathematics, one idea at a time

p′=sin²[π/(4k+2)] ≤ p; P_ancilla(0)=p′/p

After k rounds, (2k+1)arcsin√p′=π/2, so ideal good probability becomes one.

RY(β)|0⟩ = cos(β/2)|0⟩+sin(β/2)|1⟩; β=2 arccos√(p′/p)

This is how the extra wire reduces the joint marked fraction without changing which data strings count as answers.

Work this through by hand

4. Smallest search register: one mark 11

Two search qubits plus one ancilla. Start here; a three-mark extension exposes the adjustment more clearly.

Set n=2 and marks=11. Here p=1/4, k=1 and p′=1/4, so the ancilla angle is zero.

StageCalculation or stateWhat it means
Preparep′/p=1; ancilla stays |0⟩No reduction is needed in this special case.
One roundsin²(3·π/6)=1All probability lands on the marked data state.
Useful extensionFor n=3 with 3 marks: p=3/8, p′=1/4, P_ancilla(0)=2/3Now the extra RY is nontrivial: β≈1.23096 radians.

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
11100% ideal for the two-bit exampleA marked data state; the ancilla is not an extra answer bit.

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 space qubits (n)
2
Marked states
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

Read the data-only Classical bits register.

For several marks, each shot returns one marked state. Exact ideal success does not guarantee a noiseless hardware experiment.

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

  • This method uses the exact marked fraction. It is not the unknown-fraction guarantee of fixed-point search.
  • Reflecting only the search wires would not implement the required joint prepared-state reflection.

8. Check your understanding

In the extension with p=3/8, why is p′ smaller than p?

Reveal the reasoning

One round peaks at starting probability 1/4. The ancilla weights the good component by (1/4)/(3/8)=2/3.

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

Choose the marked states. Composer will prepare the extra ancilla, then show the editable oracle and joint-state diffuser.

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 space qubits (n)
Default: 3 · Whole number from 2 to 5.
Marked states
Default: 101,110,111 · Comma-separated 3-character marks (up to 32). Use 0 and 1 only. The rightmost character is q0.

The number of selected states determines the known starting success probability M/2^n. The default is the paper's 3-of-8 example.

Implementation notes

Standard Grover stops at the best whole number of rounds, which can leave probability on unmarked states. This paper's method uses the known marked fraction to set an ancilla RY angle, marks targets only when the ancilla is |0⟩, and reflects about the joint prepared state. Ideal measurements then return one marked state per run; it does not reveal all marks in one run or guarantee an error-free hardware result. Based on Mishra et al., arXiv:2505.15512v2.

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
1
Initial marked fraction
3/8
Adjusted start
25%
Ancilla RY
1.2310 rad
Standard Grover success
84.375%

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.