2
$\begingroup$

enter image description here

As per this schematic of qubits, how this explanation is correct --"If you look again at the four possible sums, you’ll notice that there is only one case for which this is 1 instead of 0: 1+1=10. It happens only when both the bits we are adding are 1.

enter image description here

The above attached snapshot is what I got after implementing the same. Kindly someone enlighten, whether I am implementing incorrectly, or the given explanation is incorrect.

$\endgroup$
2
  • $\begingroup$ Hi and welcome to Quantum Computing SE. Your explanation is correct. But just one question: what is a purpose of fourth qubit? It seems not to be used. $\endgroup$ Sep 9, 2023 at 7:05
  • 1
    $\begingroup$ Thanks for pointing out. Actually I just copied the qubit schematic demonstrated in qiskit tutorial and re-drawn in qiskit composer. As @** Egretta.Thula's ** explanation has made sense, so now I will use the 4th qubit to do AND operation for displaying carry. $\endgroup$ Sep 11, 2023 at 4:38

1 Answer 1

2
$\begingroup$

Half adder circuit provides two outputs, sum and carry. The circuit in your question computes the sum, while the text talks about the carry!

This statement:

If you look again at the four possible sums, you’ll notice that there is only one case for which this is 1 instead of 0: 1+1=10. It happens only when both the bits we are adding are 1.

is taken from this tutorial. The next few sentences in this tutorial describes how to compute the carry:

To calculate this part of the output, we could just get our computer to look at whether both of the inputs are 1. If they are — and only if they are — we need to do a NOT gate on qubit 3. That will flip it to the required value of 1 for this case only, giving us the output we need.

For this, we need a new gate: like a CNOT but controlled on two qubits instead of just one. This will perform a NOT on the target qubit only when both controls are in state 1. This new gate is called the Toffoli. For those of you who are familiar with Boolean logic gates, it is basically an AND gate.

In Qiskit, the Toffoli is represented with the ccx command.

The circuit after adding Toffoli gate should look like:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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