I am new and I don't understand where I should give the input and where I should get the output. Please explain with an example of a circuit run on the Quirk simulator. How to add two numbers?
- 3$\begingroup$ Related: How do I add 1+1 using a quantum computer? $\endgroup$Sanchayan Dutta– Sanchayan Dutta2019-03-09 16:18:39 +00:00Commented Mar 9, 2019 at 16:18
- 1$\begingroup$ Check out this video tutorial by Craig Gidney: How to use Quirk - Toy Quantum Circuit Simulator. $\endgroup$Sanchayan Dutta– Sanchayan Dutta2019-03-09 16:20:36 +00:00Commented Mar 9, 2019 at 16:20
1 Answer
Directly implementing the circuits for a full-adder described in the answers to the question linked in the comments in Quirk and swapping the third qubit with the fourth qubit for later convenience, we have the following full adder:
Quirk allows for up to $16$ qubits. Thus calling this full adder gate "FA", we can daisy-chain up to four such full adders as below, being careful to let the carry register shift over:
As above, we add the two $4$-qubit registers $|a\rangle=|a_3a_2a_1a_0\rangle$ and $|b\rangle=|b_3b_2b_1b_0\rangle$ into a $4$-qubit register $|d\rangle=|d_3d_2d_1d_0\rangle$; the third carry register $|c\rangle=|c_3c_2c_1c_0\rangle$ follows through the end.
I think the above example successfully adds $|a\rangle=|0001\rangle$ and $|b\rangle=|1101\rangle$ to get $|d\rangle=|1110\rangle$.

