Curriculum / Quantum Gates Deep Dive / Gate Synthesis

Lesson 9 of 12Code challengePro+150 XP

Gate Synthesis

Build the Hadamard gate from RY and RZ rotations and verify it matches.

Gate Synthesis

Real hardware does not implement most textbook gates directly. A superconducting backend might natively offer only a CNOT plus a few single-qubit rotations; an ion trap exposes a different set again. Every circuit you write gets compiled: rewritten as a sequence of native gates that implements the same unitary, usually up to a global phase that no experiment can detect. The previous lesson gave you the theory (the ZYZ decomposition); in this challenge you act as the compiler and verify your output like an experimentalist would, through measurement statistics.

The Hadamard gate H is equivalent, up to a global phase, to the circuit followed by . In matrix form (rightmost factor acts first): . Your challenge: verify this decomposition by showing both circuits produce identical measurement statistics.

Order matters twice

Matrix products act right-to-left (the rightmost factor hits the state first), while circuits read left-to-right in time. therefore means: apply rz(π) FIRST, then ry(π/2). Mixing up these two reading orders is the single most common decomposition bug.

Your Challenge

  1. 1.Circuit A: Apply H gate directly to |0⟩
  2. 2.Circuit B: Apply RZ(π) then RY(π/2) to |0⟩ (the ZYZ decomposition of H, in circuit order)
  3. 3.Compare measurement results, both should give ~50/50

Then verify on a second input:

  1. 4.Circuit C: Apply H then H (should recover |0⟩)
  2. 5.Circuit D: Apply the rz-then-ry pair twice (should also recover |0⟩, the global phases cancel out of the statistics)

How Strong Is This Evidence?

Be careful about what matching statistics actually prove. Identical results on one input state, measured in one basis, do not pin down a gate. RY(π/2) also sends |0⟩ to a 50/50 superposition, yet it is not the Hadamard: H is self-inverse (H·H = I), while RY(π/2) applied twice is RY(π), which carries |0⟩ all the way to |1⟩. That is exactly why this challenge includes circuits C and D, applying a candidate twice probes behavior that a single application hides. Certifying a gate completely requires checking its action on a full set of input states and measurement bases, a procedure called quantum process tomography.

This is the opening of the lesson. The full walkthrough, the interactive circuit, and the graded challenge continue inside myqubit.

How this lesson works

A hands-on coding challenge. You write Qiskit-compatible Python in the browser editor, run it instantly via WebAssembly, watch the circuit and Bloch sphere react, and pass automatic output checks. The AI tutor Qubitus gives Socratic hints if you get stuck.

Part of: Quantum Gates Deep Dive

Master single-qubit and multi-qubit gates. Understand rotations, phases, and the math behind every gate in Qiskit.

This lesson is part of Pro

Unlock Quantum Gates Deep Dive and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.