Skip to content
Current section
The Quantum Computing Enthusiast’s Hub
Saved
All sections

All sections

Saved
Skip Learn navigation
Encyclopedia
Topic

Reversible arithmetic

Arithmetic implemented as an invertible transformation that preserves enough information to maintain quantum coherence.

Also called quantum arithmetic

Edition released Coverage: Overview · Technical
On this page

Definition and significance

Quantum algorithms use reversible addition, comparison and multiplication inside larger coherent computations. Ordinary arithmetic functions can lose information; their quantum embeddings retain inputs or perform modular permutations so the full mapping is one-to-one.

Mechanism and mathematical treatment

An in-place modular adder acts as |a>|b> -> |a>|a+b mod 2^n>. Its inverse subtracts a. A computation that outputs only a+b while discarding both inputs is not reversible because many pairs have the same sum. Carry registers must be restored or incorporated into the specified output.

Fully worked reference example

For two-bit registers with a=3 and b=2, modular addition gives b'=1 because 3+2=5=1 modulo 4. Subtracting a gives 1-3=-2=2 modulo 4, recovering b. The wraparound is part of the declared function, not an overflow mistake.

Limitations and common misconceptions

Ripple-carry and carry-lookahead constructions trade workspace against depth. A claim of arithmetic cost must specify bit width, ancillas, overflow behavior, gate basis and whether controlled operation is required.

Scientific relationships

Controlled addition and multiplication construct modular powers.

Toffoli supplies reversible nonlinear Boolean operations used in arithmetic.

Historical source context

Cuccaro and collaborators submitted the cited ripple-carry adder construction on 22 October 2004. It is one resource tradeoff within a larger family of reversible arithmetic constructions.

A reversible carry primitive derived from Boolean algebra

Let a, b, and c denote bits, with c an incoming carry. Apply the reversible updates b becomes b xor a; c becomes c xor a; a becomes a xor (b and c), where the last update uses the already changed b and c. The new value of a is a_original xor [(a_original xor b_original) and (a_original xor c_original)]. Evaluating or expanding this Boolean expression gives the majority bit ab xor ac xor bc, which is the outgoing carry.

Call this three-gate sequence MAJ. It uses two CNOTs and one Toffoli, and leaves the other two wires holding a_original xor b_original and a_original xor c_original. Its inverse would restore all three original bits. For addition, a related reverse sequence instead applies a becomes a xor (b and c), then c becomes c xor a, then b becomes b xor c. Call this UMA. When applied to MAJ's output, it restores a and c while replacing b by a_original xor b_original xor c_original, the sum bit.

Thus UMA is not simply the complete inverse of MAJ: it deliberately keeps the sum on the b wire. The integer identity a+b+c=sum_bit+2carry links the two outputs. Stating the update order is essential, because simultaneous assignments using old values describe a different transformation. Both sequences are exact basis permutations and consequently act coherently on arbitrary superpositions.

Fully specified three-bit addition

Use registers A and B with arithmetic bits a0 and b0 least significant, plus a clean incoming-carry wire c and a carry-output wire z. The tensor order of their stored qubits must be specified separately; the arithmetic subscript does not override the encyclopedia's q0-leftmost convention. Apply MAJ(a0,b0,c), MAJ(a1,b1,a0), and MAJ(a2,b2,a1). The carries are temporarily stored along A. Copy the final carry from a2 to z with CNOT, then apply UMA(a2,b2,a1), UMA(a1,b1,a0), and UMA(a0,b0,c).

For A=5, B=3, and c=z=0, the low-to-high input bit pairs are (1,1), (0,1), and (1,0). Their carry sequence is c0=0, c1=1, c2=1, c3=1, and their sum bits are all zero. The final state is A=5, B=0, c=0, z=1. Reading z as the high bit gives the four-bit answer 1000, or eight. The retained A and clean carry wire make the operation reversible; no input information has been erased.

The unoptimized displayed construction uses six Toffolis and thirteen CNOTs, on eight qubits including the output bit. Its completely sequential schedule has nineteen elementary gates. Those are counts for this exact construction, not an optimal-adder claim. Optimized ripple constructions can change constants, and a Toffoli's decomposition changes the native gate count and depth. Omitting the final carry-copy operation implements addition modulo eight and still restores the temporary carries.

Coherence, overflow, and comparison

If A and B are in superposition, the same sequence computes every basis sum linearly while preserving correlations. The high output z may become entangled with the low sum and retained input. Discarding z then removes coherence between branches with different overflow values. A modular adder that never exposes that output is therefore a different contract from a full adder followed by forgetting an overflow register.

A comparison operation can extract a carry or borrow into a flag and reverse the arithmetic that produced it. The retained flag is an intended output, while every temporary carry must be restored. When that flag subsequently controls a phase, uncomputing it after the phase operation returns the arithmetic workspace and preserves the predicate's phase effect. This is the same coherent compute-use-uncompute pattern expressed through concrete bit operations.

For n bits, the analogous displayed chain uses 2n Toffolis and 4n+1 CNOTs when the final carry is copied, with one carry workspace wire and one carry output. The simple sequential depth is linear in n. A lookahead construction may reduce carry dependency depth by spending more workspace and operations. Classical arithmetic remains the appropriate baseline when inputs and outputs are already classical; reversible arithmetic is useful here because larger quantum algorithms require it inside coherent branches.

Original arithmetic figure

Provide the eight-row MAJ truth table with the outgoing carry and the three restored-or-updated UMA wires. Beside it, show the full A=5, B=3 carry chain and the final zB=1000 register. Keep arithmetic significance labels distinct from tensor positions, and give separate counts for Toffolis, CNOTs, ancillas, and the stated sequential schedule.

Sources

  • Steven A. Cuccaro; Thomas G. Draper; Samuel A. Kutin; David Petrie Moulton · · Research paper · Publication status unspecified · arXiv
    Verification scope

    Recorded source check ·

    The version date comes from the arXiv submission record.

    Theoretical or mathematical source anchor; original definitions and worked instances are independent. No experimental or end-to-end performance claim inferred.

  • Peter W. Shor · · Research paper · Publication status unspecified · arXiv · DOI 10.1137/S0097539795293172
    Verification scope

    Selected source text checked ·

    Polynomial-time ideal-circuit result; new small numerical instances are original illustrations.