Code
qcr:2606.28197.1

Basic Quantum Arithmetic Circuits

Arithmetic is a fundamental building block of many quantum algorithms, from Shor's factoring routine to amplitude estimation and quantum machine learning, all of which need to add, multiply, or otherwise transform numbers stored in quantum registers. This Cirq example constructs and simulates several basic reversible arithmetic circuits, showing how classical operations like addition are translated into the unitary, reversible form that quantum computation requires. Because quantum gates must be reversible, arithmetic on a quantum computer cannot simply overwrite a result the way a classical adder does; instead it uses ancilla qubits and controlled operations to compute outputs while preserving the information needed to run the computation backwards. The example walks through building these circuits gate by gate, encoding integer inputs into computational-basis states, applying the arithmetic transformation, and simulating the circuit to read back the result, illustrating both how reversible arithmetic works and why it is a prerequisite for the larger algorithms that depend on it. It is a useful reference for anyone implementing the modular arithmetic subroutines that appear throughout quantum algorithm design.
Qubit
Circuit-based
Uploaded 4 days ago
8
Views
GitHub4990
Citing this entry? Use this QCR ID
Uploaded by
QL
QCR Librarian

Overview

quantumlib/Cirq
49901228
README.md

Basic Quantum Arithmetic Circuits

Arithmetic is a fundamental building block of many quantum algorithms, from Shor's factoring routine to amplitude estimation and quantum machine learning, all of which need to add, multiply, or otherwise transform numbers stored in quantum registers. This Cirq example constructs and simulates several basic reversible arithmetic circuits, showing how classical operations like addition are translated into the unitary, reversible form that quantum computation requires. Because quantum gates must be reversible, arithmetic on a quantum computer cannot simply overwrite a result the way a classical adder does; instead it uses ancilla qubits and controlled operations to compute outputs while preserving the information needed to run the computation backwards. The example walks through building these circuits gate by gate, encoding integer inputs into computational-basis states, applying the arithmetic transformation, and simulating the circuit to read back the result, illustrating both how reversible arithmetic works and why it is a prerequisite for the larger algorithms that depend on it. It is a useful reference for anyone implementing the modular arithmetic subroutines that appear throughout quantum algorithm design.

Run it

pip install -r requirements.txt
python basic_arithmetic.py

Source and license

Imported from examples/basic_arithmetic.py in quantumlib/Cirq at v1.6.1, under the Apache License 2.0. Original authors: The Cirq Developers. The upstream LICENSE is included alongside this example.

Join the Discussion

Comments (0)

No comments yet. Be the first to share your thoughts!

Indexed by QCR Librarian

This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.

Versions

v1 Latest
Jun 15, 2026
qcr:2606.28197.1

Cite all versions? Use the base QCR ID to always reference the latest version of this entry.

Tools used

Cirq

Keywords

arithmetic
reversible-circuits
adders
building-blocks
ancilla

You may also like5