egtry / Quantum States & Qubits Step by Step

Double Gate Identity Audit

Finite gate loops are checked by applying the gate twice and comparing the exact output state with the starting state.

Calculate the baseline

One X swaps 3/5 and 4/5; the second X returns them. Compare full amplitudes, not just the final probability.

Apply gate X twice to (0.6, 0.8). What is the final zero probability?

  1. X² = I — Each of these ideal gates is its own inverse.
  2. First output = (0.8, 0.6) — Apply the first matrix to the signed amplitudes.
  3. Second output = (0.6, 0.8) — Apply the same matrix again.
  4. P0 = 0.36 1 — Square the restored zero amplitude.
  5. ✓ — Independent check: The identity must preserve the original complementary probability.

Enable JavaScript to control the model and practise.

Compare a second case

The basis-one case tests the other direction of the swap. A closed loop must work for each input.

Apply gate X twice to (0, 1). What is the final zero probability?

  1. X² = I — Each of these ideal gates is its own inverse.
  2. First output = (1, 0) — Apply the first matrix to the signed amplitudes.
  3. Second output = (0, 1) — Apply the same matrix again.
  4. P0 = 0 1 — Square the restored zero amplitude.
  5. ✓ — Independent check: The identity must preserve the original complementary probability.

Enable JavaScript to control the model and practise.

Test the boundary and practise

Two Z operations return an initially negative relative sign. The calculated final vector is the evidence for the identity claim.

Apply gate Z twice to (0.6, -0.8). What is the final zero probability?

  1. Z² = I — Each of these ideal gates is its own inverse.
  2. First output = (0.6, 0.8) — Apply the first matrix to the signed amplitudes.
  3. Second output = (0.6, -0.8) — Apply the same matrix again.
  4. P0 = 0.36 1 — Square the restored zero amplitude.
  5. ✓ — Independent check: The identity must preserve the original complementary probability.

Enable JavaScript to control the model and practise.

Recap