Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a Pauli X gate to swap a qubit’s computational-basis states, |0⟩ and |1⟩. Use a Pauli Z gate to leave those basis labels unchanged while reversing the relative phase of the |1⟩ component. In short: X is the bit-flip operation; Z is the phase-flip operation. The right choice depends on the state transformation—or error—you need.

What Pauli X and Pauli Z do

The gates are defined by different matrices, so they act differently on the same input:

Property Pauli X Pauli Z
Matrix [[0, 1], [1, 0]] [[1, 0], [0, −1]]
On |0⟩ |1⟩ |0⟩
On |1⟩ |0⟩ −|1⟩
Common description Bit flip or NOT-like gate Phase flip
Bloch-sphere description π rotation about the x axis π rotation about the z axis
Error-correction shorthand Bit-flip error Phase-flip error

IBM Quantum Learning describes X as a bit flip or NOT operation and Z as a phase flip. The names capture their effects, but the gates are not interchangeable: X changes basis-state labels, while Z changes a sign.

When to use X: you need a bit flip

For a general qubit state α|0⟩ + β|1⟩, X exchanges the amplitudes:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

X(α|0⟩ + β|1⟩) = β|0⟩ + α|1⟩.

Thus, X sends |0⟩ to |1⟩ and |1⟩ to |0⟩. Choose it when that exchange is the intended circuit operation, or when describing a bit-flip error. X is also its own inverse: applying it twice gives the identity, XX = I.

When to use Z: you need a phase flip

Z leaves the computational-basis labels in place and negates the |1⟩ amplitude:

Z(α|0⟩ + β|1⟩) = α|0⟩ − β|1⟩.

Choose Z when you need to change the relative phase between the two components, or when describing a phase-flip error. Z is also its own inverse: ZZ = I.

Why Z is not simply “doing nothing”

On |0⟩ alone, Z returns |0⟩. On |1⟩ alone, it returns −|1⟩. That minus sign does not change the measurement probabilities of either isolated basis state. But in a superposition it is a relative phase, which can change interference and affect later gates.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, define |+⟩ = (|0⟩ + |1⟩)/√2 and |−⟩ = (|0⟩ − |1⟩)/√2. Applying Z to |+⟩ produces |−⟩. Both states have equal probabilities for measuring 0 or 1 in the computational basis, so that measurement alone does not distinguish them.

How a later gate makes the phase difference visible

A Hadamard gate provides a simple illustration. Starting with |0⟩, a Hadamard creates |+⟩. Z changes it to |−⟩; a second Hadamard then maps |−⟩ to |1⟩. Without the Z, the second Hadamard maps |+⟩ back to |0⟩.

  1. H|0⟩ = |+⟩
  2. Z|+⟩ = |−⟩
  3. H|−⟩ = |1⟩

So although |+⟩ and |−⟩ have the same computational-basis probabilities before the final Hadamard, their relative phase leads to different measurement outcomes afterward.

How X and Z relate to axes and bases

The computational basis, {|0⟩, |1⟩}, is associated with the Bloch sphere’s z axis. X is a π rotation about the x axis, while Z is a π rotation about the z axis. The states |+⟩ and |−⟩ are the eigenstates of X, so they form the basis in which X’s action is especially direct.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This explains why “bit flip” and “phase flip” describe effects relative to a basis. X exchanges the computational-basis states; Z changes their relative sign. In another basis, the same operation can have a different-looking effect.

What the gate symbols mean in error correction

In Pauli error terminology, X represents a bit-flip error and Z a phase-flip error. The Pauli Y operation is equivalent to XZ up to an overall phase, and X and Z anticommute:

  • XX = I and ZZ = I: each gate reverses itself when applied twice.
  • XZ = −ZX: changing the order of X and Z changes the result by a minus sign.

The letter may refer to a gate deliberately applied by a circuit, a Pauli observable, or an error model. Check the surrounding context rather than assuming every mention of X or Z describes an unwanted fault.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Pauli gates versus parameterized rotations

A rotation through π about an axis is closely related to the corresponding Pauli gate, but the matrices are not exactly equal. IBM’s Qiskit documentation gives RX(π) = −iX and RZ(π) = −iZ. The factor −i is a global phase: for an isolated state, a global phase has no observable effect. In controlled constructions, however, phase bookkeeping can matter, so do not silently replace one expression with the other when tracking a circuit’s phases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

These relations are documented in the Qiskit API entries for XGate and ZGate. The API documentation is version-sensitive; consult the documentation for the Qiskit version you use when relying on implementation details.

A quick choice guide

  • Choose X to exchange |0⟩ and |1⟩, swap the amplitudes, or model a bit-flip error.
  • Choose Z to preserve the computational-basis labels while changing the relative sign, or to model a phase-flip error.
  • If a Z operation appears to have no effect on a basis-state measurement, consider whether a later gate or interference step can reveal the changed phase.

Sources

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.