Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
FREEDOM251

Freedom251 › Blog › Pauli gates

How to Apply Pauli X and Z Gates in a Quantum Circuit

By Freedom251 Team · · 2 min read

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

In Qiskit, apply Pauli X or Z to a chosen qubit with qc.x(q) or qc.z(q). X flips computational-basis values; Z changes the phase of the |1⟩ component. Both are single-qubit instructions that can be added in sequence or alongside gates on other qubits.

Apply X or Z in Qiskit

Create a QuantumCircuit with enough qubits, then call the method for the qubit you want to affect:

As an Amazon Associate I earn from qualifying purchases.

from qiskit import QuantumCircuit

qc = QuantumCircuit(1)
qc.x(0)  # apply Pauli X to qubit 0
qc.z(0)  # then apply Pauli Z to qubit 0

print(qc.draw())

The official IBM Quantum lesson on bits, gates, and circuits demonstrates adding X to a single-qubit circuit; the XGate and ZGate API references document the corresponding gate methods. The call order is circuit order: in this example, X is applied first, followed by Z.

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

Use a specific qubit

For a two-qubit circuit, pass the index of the target qubit to each method:

qc = QuantumCircuit(2)
qc.x(0)  # X acts on qubit 0
qc.z(1)  # Z acts on qubit 1

Each instruction acts on the selected qubit and leaves the other subsystem unchanged. When reading a drawn circuit or displayed bitstring, pay attention to the framework’s qubit-indexing and display conventions.

What X and Z do to a qubit

A qubit in a general pure state can be written as α|0⟩ + β|1⟩, where α and β are amplitudes. Applying a gate transforms those amplitudes as follows:

  • Pauli X: α|0⟩ + β|1⟩ → α|1⟩ + β|0⟩.
  • Pauli Z: α|0⟩ + β|1⟩ → α|0⟩ − β|1⟩.

The matrix forms and computational-basis effects make the distinction clear:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Gate Matrix Effect on basis states Common description Qiskit method
Pauli X [[0, 1], [1, 0]] |0⟩ → |1⟩; |1⟩ → |0⟩ Bit flip qc.x(q)
Pauli Z [[1, 0], [0, −1]] |0⟩ → |0⟩; |1⟩ → −|1⟩ Phase flip qc.z(q)

On the all-zero starting state, X on a single qubit produces |1⟩. Z leaves |0⟩ unchanged, so its effect is not visible on that state alone; its sign change matters when the |0⟩ and |1⟩ components are in superposition.

Check the circuit’s state

In the IBM Quantum learning workflow, the state can be inspected with Qiskit’s Statevector:

from qiskit.quantum_info import Statevector

state = Statevector(qc)
print(state)

This gives the state implied by the circuit instructions. To see measurement outcomes, a measurement operation and an execution or simulator workflow are needed; a statevector inspection by itself is not a measurement.

Does the order of X and Z matter?

Yes. On the same qubit, the operators anticommute: XZ = −ZX. Their resulting statevectors therefore differ by a minus sign if their order is reversed. For an isolated state, that overall sign is a global phase and does not change measurement probabilities. But operator order must not be treated as interchangeable in controlled operations or larger constructions, where phase relationships can affect the result.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Pauli gates versus rotation gates

Qiskit’s Pauli X and Z instructions are not exactly the same unitary matrices as π rotations around the corresponding axes: RX(π) = −iX and RZ(π) = −iZ. The difference is a global phase for an isolated state, so it does not change its measurement probabilities. Keep the factor when comparing exact unitary operators or composing gates in a larger construction.

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.

Pauli gatesQiskitquantum circuitsQuantum Computing

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.