1
$\begingroup$

I would like to add numbers. In this simple example a = 1 and b = 1. The circuit I created looks like this: enter image description here

We have two registers a and b. Both have a size of 3 qubits. I'm using Big Endian notation, so for example the bit array [1, 1, 0] = 6. I start with encoding both numbers by adding a X-Gate to qubit 2 and 5. After that I follow Drapper's algorithm for integer addition: QFT on a, Evolve a by b. QFT-Inverted on a.

However the result is wrong that I'm getting at the end: The state 17 (= [0, 1, 0, 0, 0, 1]) has probability 1. I would like to see state 2 with probability 1 obviously. What am I doing wrong?

$\endgroup$

2 Answers 2

2
$\begingroup$

You are misunderstanding your output. All quantum calculations must be reversible. Having two 3-bit inputs yield a six-bit output is not reversible.

The result you're actually seeing is the three-bit result $[0, 1, 0]$ corresponding to the sum and the three-bit result $[0, 0, 1]$ which is the second argument. This is reversible, and you could rederive your original $a$ and $b$.

$\endgroup$
1
  • $\begingroup$ You are absolutely right! Thank you very much! $\endgroup$
    – Oli
    Jan 26 at 20:56
0
$\begingroup$

You are just interpreting your output the wrong way. The result of the addition will only be in register a as a 3-qubit result. You are evolving b over into a. If you only look at your top 3 qubits, they are in the state [0, 1, 0] which corresponds to decimal 2, which is the correct output.

You can verify this by modifying the input values in a and b in [0, 3], but please account for the carry (in essence, since you reserved 3 qubits for a, in effect you only have 2 qubits available to specify values 0 to 3 inclusive).

For reference, I have the corresponding code here.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.