|q⟩ Bad Qubits

beginner · Programming · Building & Reading Quantum Circuits

Equivalent Circuits

Two quantum circuits are equivalent when they perform exactly the same transformation on every input state — that is, when they implement the same unitary matrix UU. Recognising equivalent circuits is a practical skill: compilers use it to swap an expensive gate for a cheaper sequence of gates, and hardware providers publish tables of such identities so you can target their native gate set.

Phase gates and how they compose

The TT gate (sometimes called the π/8\pi/8 gate) advances the phase of 1|1\rangle by π/4\pi/4:

T=(100eiπ/4).T = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix}.

Applying TT twice means multiplying the matrix by itself:

T2=(100eiπ/4)(100eiπ/4)=(100eiπ/2)=(100i).T^2 = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix} \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/2} \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}.

That last matrix is the SS gate (also written P(π/2)P(\pi/2)). In other words, two consecutive TT gates are circuit-equivalent to a single SS gate. Both circuits act identically on every qubit state, so no experiment can distinguish them.

By the same logic, S2=ZS^2 = Z and T4=ZT^4 = Z, giving a small family of related identities:

T2=S,S2=Z,T4=Z,T8=I.T^2 = S, \qquad S^2 = Z, \qquad T^4 = Z, \qquad T^8 = I.

Each equality is a statement about unitary matrices, and each can be verified by multiplying the 2×22 \times 2 matrices together.

What the grader checks

The unitary grader computes the full 2×22 \times 2 complex matrix of your circuit and compares it to the expected matrix — in this case SS. An empty circuit (identity II) does not match SS, so you must actually apply the gates.

Try it

Implement the SS gate using only two TT gate calls. The grader will compare the unitary of your circuit against SS directly.

Run your code to see the quantum state.

After running, inspect the Matrix tab to see the 2×22 \times 2 unitary. The bottom-right entry should read i0+1ii \approx 0 + 1i, confirming you have realized S=T2S = T^2.

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