# Can anybody explain the following circuit?

I think I understand what it does. But i can't agree with output for sertain inputs. For example: if a=1 and b=1 then how the output on 4 line could be xor(a, b). Because as far as I know xor(1,1)=0 and also 1+1=1. It's not consistent. • Note that $1 \oplus 1 = 0$ Apr 26 at 5:00
• As pointed by KAJ 1+1=10, i.e. zero in the lowest bit with carry to higher one. Apr 26 at 5:59
• Also note that CNOT applied on computational basis states behaves as XOR, just write down action of that gate for all possible combination of zeros and ones on control and target qubits. Apr 26 at 6:01

Note that the first CNOT gives you

$$CNOT |a\rangle |0\rangle = |a\rangle |a \oplus 0 \rangle = |a\rangle |a \rangle$$

and then the second CNOT gives you

$$CNOT |b\rangle |a\rangle = |b\rangle |b \oplus a\rangle$$

Thus the target qubit state is now in $$|b \oplus a\rangle$$

• Now I understand. Thank you Apr 26 at 7:34

The notation of $$\oplus$$ does not simply denote addition. It denotes bitwise addition modulo 2, i.e. $$0\oplus 0=0,\quad 0\oplus1=1\oplus 0=1,\quad 1\oplus 1=0$$ which is exactly the same as the xor that you were predicting.