Basic Quantum Arithmetic Circuits
Overview
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.
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
Cite all versions? Use the base QCR ID to always reference the latest version of this entry.
Join the Discussion
Comments (0)
No comments yet. Be the first to share your thoughts!