# Implementation of quantum adder

I'm looking at this paper and try to implement the Quantum adders they define myself.

Suppose we have a number $b=b_{n-1}\dots b_1b_0$ and they want to add a constant number $a=a_{n-1}\dots a_1a_0$.

They define $$A_j = \Pi_{k=1}^{j+1} R_k^{a_{j+1-k}}, \quad R_k = \begin{pmatrix}1&0\\0&e^{i2\pi/2^k}\end{pmatrix}$$

The result can be obtained by first applying a QFT on all qubits, then apply $A_j$ on qubit $j$ and then apply an inverse QFT.

However, if I try to work this out for the simple case where $b=0$ and $a=1$, I end up with a quantum state $$0.5\left|01\right> + (0.5+0.5i)\left|10\right> - 0.5i \left|11\right>.$$ Note in this case, $A_0 = Z$ and $A_1 = S$.

Is there an error in my calculation, or is the definition in the article not correct?

• I think that both times you only apply the QFT or its inverse to the register b, not to a. – DaftWullie Jun 29 '18 at 12:09
• We only have a register $b$, as $a$ is a constant number and hence just an input. – nippon Jun 29 '18 at 13:08
• Ah, sorry, so you're meaning $b=00$ and $a=01$? – DaftWullie Jun 29 '18 at 13:10
• Yes. The $a$ is constant and is not related to the QFT – nippon Jun 29 '18 at 13:53
• Here is the circuit in a simulator. Is that helpful? – Craig Gidney Jun 29 '18 at 18:13

## 1 Answer

I'm assuming an initial state of the form $|a\rangle|b\rangle = |1\rangle|0\rangle$ for your simple case. You first perform a QFT on the right qubit, obtaining $|1\rangle(\frac{|0\rangle+|1\rangle}{\sqrt{2}})$. Next, you apply $A_0 = R_1$ to the right qubit to obtain $|1\rangle(\frac{|0\rangle-|1\rangle}{\sqrt{2}})$. Finally, you apply an IQFT to the right qubit and obtain $|1\rangle|1\rangle$, thereby demonstrating that $1+0=1$. As @DaftWullie noted, all the action happens on the "$b$" qubit; the $a$ qubit (or cbit in this case) acts only as a control.

• This is not what I wanted to do. See the comments. Interchanging the gates did solve it. – nippon Jul 1 '18 at 18:52