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
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.
Choose whole rounds
Select k so the target starting good probability p′ does not exceed p.
Tune ancilla
Prepare ancilla P(0)=p′/p using RY.
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
After k rounds, (2k+1)arcsin√p′=π/2, so ideal good probability becomes one.
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.
| Stage | Calculation or state | What it means |
|---|---|---|
| Prepare | p′/p=1; ancilla stays |0⟩ | No reduction is needed in this special case. |
| One round | sin²(3·π/6)=1 | All probability lands on the marked data state. |
| Useful extension | For n=3 with 3 marks: p=3/8, p′=1/4, P_ancilla(0)=2/3 | Now 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 event | Ideal probability | Interpretation |
|---|---|---|
| 11 | 100% ideal for the two-bit example | A 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
- Save any current circuit you want to keep, then open the worked example. Loading it does not execute a paid hardware job.
- Trace the preparation, main operations and measurements against the worked table. Check the gate editor for controls, targets and angles.
- Start with an ideal noiseless simulator compatible with the circuit. Mid-circuit measurement, reset and feed-forward require support from the chosen backend.
- 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.
- 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.