WEEK 5
How to sum two numbers using a quantum processor
The structure of Quantum algorithms. How different are they from classical ones?
How to sum two numbers using a quantum processor
The above is a picture of the classical adder circuit. We would like to reproduce this on a quantum processor. We'll be using the QISKit library. https://qiskit.org. Before we start, we have 3 questions to answer. 1. How do we store the input bits? 2. What quantum gates can we use here? 3. How can we measure the results?
How do we store the input bits?
Qubits are normally in the |0> default state and we can use the X gate to change it to the |1> state. We can assign one qubit to represent a classical bit. We'll need two sets of these qubits. One each for the first and second number.
Supposing we make a superposition of each bit, then we can store multiple bits at one!
What quantum gates can we use here?
We need to use universal reversible gates to construct more complex gates like the XOR and AND classical gates. We will use the CNOT and CCNOT gates to build them. We will perform a little algebra to find the carry bit and sum.
How can we measure the results?
We'll use the measurement operator in the QISKit library and will store the results in the register of the second number.
You can find the full code here. https://quantum-computing.ibm.com/jupyter/user/Sum%20of%20binary%20numbers.ipynb