Logic Gates as Functions
A logic gate is just a deterministic function: the same inputs always produce the same output. NOT is a function of one bit; AND, OR, and XOR are functions of two bits. Thinking of gates as functions is the right mindset for quantum gates too — except quantum gates are functions that must be reversible and act on amplitudes, not just bits.
XOR (exclusive or, written ) outputs 1 exactly when its inputs differ: , , , . It is the classical cousin of the quantum CNOT gate you will meet later.
Try it
Return (use JavaScript's ^ operator).
Run your code to see the quantum state.
Sign in on the full site to ask questions and join the discussion.