Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

QuantumPlaybook

Guides

  • QuantumPlaybook

Tech Notes

  • Addition of Numbers
  • Baker-Hausdorff Lemma
  • Chiral Fermion Random Circuit
  • Clifford Operators: How to Test
  • Commutation Relations for Qubits
  • Entanglement Distillation
  • Generalized Pauli Operators: Implementation
  • Hatano-Nelson-Kitaev Model: Monte Carlo Simulation
  • Hatano-Nelson Model: Monte Carlo Simulation
  • Kitaev Chain
  • Kitaev Random Circuit
  • Λ-Matter in a Cavity
  • Measurement of Total Pauli Z
  • Non-Unitary Dynamics of Quantum States
  • Partial Trace: Physical Meaning
  • Quantum Dot Systems
  • A Quantum Playbook
  • Magnetic Exchange Coupling
  • Solovay-Kitaev Algorithm
  • Spin Code
  • Symmetry Effects On Quantum Master Equations
  • Transmon: Quantum Phase Model
  • Transposition as a Supermap
  • Variational Quantum Classifier: Iris
  • Variational Quantum Classifier: Parity
  • Variational Quantum Eigensolver: Transverse-Field Ising Model

Symbols

  • BlochEnergy
  • BlochFunction
  • QuantumPlaybookCheckUpdate
  • QuantumPlaybookEdition
  • QuantumPlaybookUpdate
  • TransmonEnergy
  • TransmonExponent
  • TransmonFunction
  • TransmonHamiltonian
Addition of Numbers
Here, we introduce a quantum circuit implementation of addition.
Make sure that Q3 is loaded.
In[32]:=
Needs["QuantumMob`Q3`"]
The two numbers to add are initially stored in quantum registers A and B, respectively. Temporary register T is to store the carrier bits.
In[33]:=
Let[Qubit,A,B,T]
Suppose that we added two numbers each represented by n binary digits. Note that we need one more bit in the temporary register T.
In[34]:=
$n=3;​​kk=Range[$n];​​AA=A[kk,$];​​BB=B[kk,$];​​TT=T[Range[$n+1],$];
The result is stored in the register B. Note, however, that the last carrier bit is still stored in T only.
In[39]:=
elm=Flatten@Table[​​{CNOT[{A[k],B[k]},T[k+1]],​​CNOT[A[k],B[k]],​​CNOT[{B[k],T[k]},T[k+1]],​​CNOT[T[k],B[k]]},​​{k,$n}];
In[40]:=
qc=QuantumCircuit[Sequence@@elm,​​"Invisible"{A[$n+1/2],B[$n+1/2]}​​]
Out[40]=
In[41]:=
bs=Basis[AA,BB];
In[42]:=
EchoTiming[out=qc**bs;]
⌚
2.34428
In[43]:=
ab={FromDigits[Reverse[#@AA],2],FromDigits[Reverse[#@BB],2]}&/@bs;​​cc=FromDigits[Reverse@Join[#@BB,#@T@{$n+1}],2]&/@out;​​Thread[abcc]//TableForm
Out[45]//TableForm=
{0,0}0
{0,4}4
{0,2}2
{0,6}6
{0,1}1
{0,5}5
{0,3}3
{0,7}7
{4,0}4
{4,4}8
{4,2}6
{4,6}10
{4,1}5
{4,5}9
{4,3}7
{4,7}11
{2,0}2
{2,4}6
{2,2}4
{2,6}8
{2,1}3
{2,5}7
{2,3}5
{2,7}9
{6,0}6
{6,4}10
{6,2}8
{6,6}12
{6,1}7
{6,5}11
{6,3}9
{6,7}13
{1,0}1
{1,4}5
{1,2}3
{1,6}7
{1,1}2
{1,5}6
{1,3}4
{1,7}8
{5,0}5
{5,4}9
{5,2}7
{5,6}11
{5,1}6
{5,5}10
{5,3}8
{5,7}12
{3,0}3
{3,4}7
{3,2}5
{3,6}9
{3,1}4
{3,5}8
{3,3}6
{3,7}10
{7,0}7
{7,4}11
{7,2}9
{7,6}13
{7,1}8
{7,5}12
{7,3}10
{7,7}14
In fact, one can store the result spread over registers B and T. Then, one can remove some quantum circuit elements.
In[46]:=
elm=Flatten@Table[​​{CNOT[{A[k],B[k]},T[k+1]],​​CNOT[A[k],B[k]],​​CNOT[{B[k],T[k]},T[k+1]]},​​{k,$n}];
In[47]:=
qc=QuantumCircuit[Sequence@@elm,​​"Invisible"{A[$n+1/2],B[$n+1/2]}​​]
Out[47]=
To extract the sum, you need to consider both registers B and T.

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com