Algorithm guide · transform
Draper QFT adder
Add a into b with Fourier-basis phase rotations. The n-bit result wraps modulo 2^n without a carry wire.
Circuit size: 2–6 qubits (two 1–3-qubit registers)
Binary addition · QFT and inverse QFT · Controlled phase gates
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
Add an n-bit register a into another register b, keeping a unchanged and storing only n result bits. The result is (a+b) modulo 2ⁿ, so this circuit deliberately discards overflow.
2. How it works
In the Fourier basis, adding a number becomes applying a predictable set of phase rotations. Instead of propagating carry bits, use a’s wires to control those rotations on b, then transform back.
Prepare operands
X gates encode the chosen binary values into a and b.
Fourier encode b
Apply QFT to the target register.
Add with phase
Controlled phase rotations multiply Fourier component y by exp(2πiay/2ⁿ).
Decode
Inverse QFT returns b to the ordinary sum representation; measure the registers.
3. The mathematics, one idea at a time
N=2ⁿ. The number b is encoded in relative phases between Fourier components.
Phase angles add, so inverse QFT produces the modular sum.
Work this through by hand
4. One-bit addition: 1+1 wraps to 0
n=1 per register: two qubits, the supported minimum. QFT on a one-bit target is just H.
Set a=1 and b=1. A one-bit target can hold only 0 or 1.
| Stage | Calculation or state | What it means |
|---|---|---|
| Initial target | |b⟩=|1⟩ | a remains 1 throughout. |
| H, then controlled phase | |1⟩ → |−⟩ → |+⟩ | When a=1, the π phase changes the sign of the target’s |1⟩ component. |
| Inverse H | |+⟩ → |0⟩ | The stored value is 2 mod 2 = 0; overflow is discarded. |
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 |
|---|---|---|
| 01 | 100% ideal | c1c0 = updated b followed by unchanged a: 0|1. |
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.
- Bits per register (n)
- 1
- Addend a
- 1
- Target b
- 1
- 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
Do not read the whole histogram label as the sum: its rightmost n bits preserve a.
For this example sum=0 is correct modular arithmetic, not an addition error. Use a carry-preserving adder to keep the extra bit.
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 card has no carry-out ancilla.
- The QFT’s intermediate probability bars alone do not show the number being added; the information is in phase.
8. Check your understanding
With n=2, a=11 and b=01, what is the target result?
Reveal the reasoning
3+1=4≡0 mod 4, so b becomes 00 and a remains 11.
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
Set the two input registers, then open the QFT, controlled-phase addition, and inverse QFT in Composer.
These are the gallery defaults. The worked example above may override them. Configure the card to change the inputs before loading its editable circuit.
- Bits per register (n)
- Default: 3 · Whole number from 1 to 3.
- Addend a
- Default: 011 · 3 bits (0 or 1); leftmost character is the highest-numbered qubit.
- Target b
- Default: 010 · 3 bits (0 or 1); leftmost character is the highest-numbered qubit.
Implementation notes
This fixed-width Draper adder leaves a unchanged and writes (a + b) mod 2^n into b. Any carry beyond n bits is discarded: with n=3, 7 + 1 becomes 000. No carry ancilla is used. The classical histogram reads the result b above the original a (c5…c0 for n=3). Unlike a ripple-carry adder, the sum is applied as controlled phases between QFT and inverse QFT. Based on Draper, arXiv:quant-ph/0008033.
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.
- Result mod 8
- 101 (5)
- Overflow
- None
- Controlled phases
- 6
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.