The X Gate

Master the quantum NOT gate—your first step into manipulating quantum states with gates.

About this module

In this module you will:

  • Learn how the X gate flips quantum states
  • Understand X gate behavior on basis states
  • Explore what happens when X acts on superposition
  • Discover the reversibility of quantum gates

Prerequisites: Lessons 1-3. Understanding of qubits and superposition.

4.1 The X Gate: Quantum NOT

The X gate is the quantum version of the classical NOT gate. It flips a qubit: |0⟩ becomes |1⟩, and |1⟩ becomes |0⟩. Simple, right?

In classical computing, NOT flips bits. In quantum computing, the X gate does the same for qubits—but because qubits can be in superposition, the X gate reveals something deeper about quantum mechanics.

Key Concept: Deterministic Flip

Unlike measurement (which is probabilistic), the X gate is deterministic. Apply X to |0⟩ and you always get |1⟩. No randomness!

Interactive: X Gate on Basis States

Try applying the X gate to |0⟩ and |1⟩. See how it deterministically flips the state.

|0⟩
X
?

Notice: X always flips the state. |0⟩ → |1⟩ and |1⟩ → |0⟩. This is deterministic!

4.2 X Gate on Superposition

Here's where it gets interesting. What happens when you apply X to a qubit in superposition?

Consider the state |+⟩ = (1/√2)|0⟩ + (1/√2)|1⟩. If X flips |0⟩ to |1⟩ and |1⟩ to |0⟩, then X|+⟩ = (1/√2)|1⟩ + (1/√2)|0⟩ = |+⟩! The superposition remains, just with swapped amplitudes.

Key Insight: Amplitude Swap

The X gate swaps the amplitudes (probabilities) of |0⟩ and |1⟩. For equal superposition, this looks like nothing changed—but it did!

Interactive: X Gate on Superposition

Create superposition with H, then apply X. Measure multiple times to see the effect.

|0⟩
H
X
📊

Result: Still 50/50! On equal superposition, X swaps amplitudes but measurements show the same distribution.

Experiment: Different Circuits

What about different combinations? Try X on different starting states and circuits.

4.3 Multiple X Gates: Reversibility

Quantum gates are reversible. This means applying a gate twice returns you to the original state. The X gate is its own inverse: X · X = I (identity).

If you flip a qubit twice, you're back where you started. This is a fundamental property of quantum computing—all quantum operations must be reversible (until measurement).

Interactive: X Applied Multiple Times

Apply X gate 1, 2, 3, or more times and see the pattern.

Pattern: Odd number of X gates → flip. Even number → return to original. X is self-inverse!

Why Reversibility Matters

Reversibility is not just mathematical elegance—it's a fundamental requirement of quantum mechanics. Information cannot be destroyed in quantum operations (until measurement collapses the state).

Test Your Understanding

Question 1: What does the X gate do to the state |0⟩?

Question 2: What is the result of applying X twice to |0⟩?

Question 3: Is the X gate deterministic or probabilistic?

Question 4: What happens when you apply X to equal superposition |+⟩?