|q⟩ Bad Qubits

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

Pauli Matrices

The gates XX, YY, and ZZ that you have applied in the last three lessons each correspond to a 2×22 \times 2 matrix. Together they are called the Pauli matrices, named after the physicist Wolfgang Pauli. Knowing their explicit form lets you read off how each gate transforms any state vector by ordinary matrix–vector multiplication.

The three matrices

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

A few patterns worth memorising:

Reading the action from the matrix

Matrix–vector multiplication connects the matrix entries to the gate's action. For XX acting on a general qubit α0+β1\alpha|0\rangle + \beta|1\rangle:

X(αβ)=(0110)(αβ)=(βα),X \begin{pmatrix} \alpha \\ \beta \end{pmatrix} = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} \alpha \\ \beta \end{pmatrix} = \begin{pmatrix} \beta \\ \alpha \end{pmatrix},

so XX swaps the two amplitudes — exactly the bit-flip you observed in the simulator.

For ZZ:

Z(αβ)=(1001)(αβ)=(αβ).Z \begin{pmatrix} \alpha \\ \beta \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} \begin{pmatrix} \alpha \\ \beta \end{pmatrix} = \begin{pmatrix} \alpha \\ -\beta \end{pmatrix}.

The amplitude of 0|0\rangle is unchanged while the amplitude of 1|1\rangle picks up a minus sign.

For YY:

Y(αβ)=(0ii0)(αβ)=(iβiα).Y \begin{pmatrix} \alpha \\ \beta \end{pmatrix} = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix} \begin{pmatrix} \alpha \\ \beta \end{pmatrix} = \begin{pmatrix} -i\beta \\ i\alpha \end{pmatrix}.

YY both swaps the amplitudes and multiplies each by ±i\pm i — a combination of XX and ZZ twisted by ii. In fact one can verify that Y=iXZY = iXZ.

Determinants as a consistency check

For any 2×22 \times 2 matrix (abcd)\bigl(\begin{smallmatrix}a & b \\ c & d\end{smallmatrix}\bigr), the determinant is adbcad - bc. Computing it for each Pauli matrix gives

det(X)=0011=1,det(Y)=00(i)(i)=((i)(i))=(i2)=(1)=1,det(Z)=(1)(1)0=1.\det(X) = 0 \cdot 0 - 1 \cdot 1 = -1, \quad \det(Y) = 0 \cdot 0 - (-i)(i) = -((-i)(i)) = -(-i^2) = -(1) = -1, \quad \det(Z) = (1)(-1) - 0 = -1.

All three determinants equal 1-1. This is not a coincidence. The group SU(2)SU(2) consists of 2 ⁣× ⁣22\!\times\!2 unitary matrices with determinant exactly +1+1; the Pauli matrices have det=1\det = -1, so they lie in U(2)U(2) but outside SU(2)SU(2). On the Bloch sphere each Pauli gate acts as a 180°180° rotation about its namesake axis (XX about x^\hat{x}, YY about y^\hat{y}, ZZ about z^\hat{z}) — a proper rotation — so the det=1\det = -1 in the 2 ⁣× ⁣22\!\times\!2 matrix sense does not indicate a reflection on the Bloch sphere.

Try it

Use the determinant formula to compute det(X)+det(Y)+det(Z)\det(X) + \det(Y) + \det(Z) and return the result.

Run your code to see the quantum state.

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