1
$\begingroup$

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. enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ Note that $1 \oplus 1 = 0$ $\endgroup$
    – KAJ226
    Apr 26 at 5:00
  • 1
    $\begingroup$ As pointed by KAJ 1+1=10, i.e. zero in the lowest bit with carry to higher one. $\endgroup$ Apr 26 at 5:59
  • 1
    $\begingroup$ 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. $\endgroup$ Apr 26 at 6:01

2 Answers 2

3
$\begingroup$

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$

$\endgroup$
1
  • $\begingroup$ Now I understand. Thank you $\endgroup$
    – Somnus
    Apr 26 at 7:34
0
$\begingroup$

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.

$\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.