Build your own gates

The Gate Lab is where you build your own gates. Line up gates on a bench, and the lab shows what they add up to: however many you use, the answer is always one rotation of the sphere.

Open it with Gate Lab at the top of the app, on a computer or a tablet held sideways: it needs a wider screen than a phone's. It keeps its bench while you go back and forth, and gates you save there show up on the sphere's gate bar.

A Bloch sphere: the path of |0⟩ through H, then T, then H, as three solid arcs, and a dashed arc for the single 45-degree turn about x that has the same effect.|0⟩|1⟩|+⟩|−⟩|+i⟩|−i⟩
H, T, H on ∣0⟩|{0}\rangle: one solid arc for each turn, and dashed, the single turn they add up to: 45° about x.

Building a gate

  1. Click gates under Ingredients (X, Y, Z, H, S, T, their daggers, or a rotation by any angle). Each one lands on the bench as a tile, left to right in time order.
  2. The Result panel shows the gate the tiles make: its formula, its exact matrix, the single rotation it performs, and the known gate it equals, if any.
  3. The test sphere plays it: each tile's turn as a solid arc, then the one equivalent rotation, dashed. Pick the state to test on under Test on, and replay with ▶ Play.

For example, H, then T, then H adds up to a 45° turn about x:

H T H=eiπ/8 Rx(45∘)H\,T\,H = e^{i\pi/8}\,R_x(45^\circ)

The lab reports the rotation (45° about x) and the match, "≡ Rx(45°)", up to the global phase eiπ/8e^{i\pi/8}.

Taking gates apart

Under the bench, operations act on the selected tile, or on the whole bench when none is selected:

  • Undo † makes the inverse, U†U^\dagger: the same turn backward. For a whole bench it reverses the order and undoes each tile, since (A B)†=B†A†(A\,B)^\dagger = B^\dagger A^\dagger.
  • Repeat ×2, ×3, ×4 applies a gate several times: T2=ST^2 = S, S2=ZS^2 = Z, and T8=IT^8 = I.
  • Fraction ½, ⅓, ¼ takes part of a turn: X1/2X^{1/2}, the square root of X, is a quarter turn about x.
  • Compare reversed order plays the tiles backward too, to show whether order matters for them.

Saving and using your gates

Give the gate a Name and a short Label (up to four characters, for its button), and choose Save to My gates. With Pin to gate bar on, it appears next to the built-in gates on the sphere. Apply takes it straight back to the sphere and plays it there. Saved gates are kept in this browser.

Try it

Each link opens the lab with these tiles on the bench:

The last one moves X's axis: turning by S† first and by S after turns the x axis a quarter turn, onto y. More on why in Gates are rotations.

S X S†=YS\,X\,S^\dagger = Y