|q⟩ Bad Qubits

beginner · Programming · Bits, Logic & Classical Computation

Truth Tables

A truth table lists a gate's output for every combination of inputs. For a 2-input gate there are 22=42^2 = 4 input rows; for nn inputs there are 2n2^n rows. Here is AND:

| a | b | a AND b | | --- | --- | --- | | 0 | 0 | 0 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 |

Truth tables completely specify a classical gate. Quantum gates need a richer description — a matrix of complex amplitudes — precisely because they can act on superpositions of all those input rows at once.

Try it

How many rows does a truth table for a gate with 3 inputs have?

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.