|q⟩ Bad Qubits

beginner · Programming · Single-Qubit Gates I: X, Y, Z

Inverse Gates

Every quantum gate must be reversible — that is guaranteed by the requirement that gates are unitary (UU=IU^\dagger U = I). For a gate UU, its inverse is U1=UU^{-1} = U^\dagger (the conjugate transpose). For the Pauli gates this turns out to be especially simple.

The Pauli matrices are Hermitian and unitary

The three Pauli gates are

X=(0110),Y=(0ii0),Z=(1001).X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}, \quad Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}, \quad Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}.

Each matrix is equal to its own conjugate transpose: X=XX^\dagger = X, Y=YY^\dagger = Y, Z=ZZ^\dagger = Z. A matrix that equals its own conjugate transpose is called Hermitian. When a matrix is both Hermitian and unitary, the two conditions U=UU^\dagger = U and UU=IU^\dagger U = I combine to give

U2=I.U^2 = I.

You can verify this directly for each Pauli by squaring the matrix. For XX:

X2=(0110)(0110)=(1001)=I.X^2 = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = I.

The same calculation for YY and ZZ gives the same result. A matrix that squares to the identity satisfies U1=UU^{-1} = U, so:

Each Pauli gate is its own inverse.

Concretely:

Try it

The circuit below starts with the qubit in 0|0\rangle and immediately applies XX to produce 1|1\rangle. Your task is to undo that flip by applying the inverse of XX. The grader checks the full state vector, so the qubit must end in 0|0\rangle.

Run your code to see the quantum state.

After running: the Bloch vector returns to the north pole, and the amplitude on 0|0\rangle is exactly 11. Two XX gates cancel completely because X2=IX^2 = I.

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