9.4 Arithmetic
In section 2.5
I’m going to keep to a straightforward approach to help bridge the gap between classical and quantum approaches. The gates we use are simple, and we replace bits with qubits. That is, instead of 0 and 1 we use |0⟩ and |1⟩, respectively. The data input qubits are called |x⟩ and |y⟩, and each are in the state |0⟩ or |1⟩ at any given time. We are essentially mimicking what we would do in the classical case.
If we do not worry about carry-in and carry-out qubits, our circuit looks like
where ‘‘⊕’’ is addition modulo 2. This is implemented as a CNOT gate acting as an xor. We use q1 to store this output as well as the |y⟩ input.
To include a carry-out state |cout⟩ we employ a Toffoli CCNOT gate and use a third qubit, q2, to hold the value.
Question 9.4.1