RZ gate

The RZ gate, a rotation about Z by any angle: matrix, effect on the basis states, the rz() call in Python and JS, and why it costs nothing on IonQ hardware.

The RZ gate rotates a qubit about the Z axis of the Bloch sphere by an angle ϕ\phi. It acts on one qubit and takes one parameter, ϕ\phi in radians. The Circuit panel draws it as Rz(φ) with the angle shown as a multiple of π. On its own it changes nothing a measurement can see, whatever the angle; the rotation shows once the qubit is in superposition.

Kets such as 0\vert 0 \rangle name the basis states and rotations are described on the Bloch sphere; the qubits lesson introduces both.

Call

WhereCall
Pythonqc.rz(φ, qubit)
JScircuit.rz(φ, qubit)
Qiskit classRZGate
Controlled formcrz(φ, control, target)

Matrix

RZ(ϕ)=(eiϕ/200eiϕ/2)RZ(\phi) = \begin{pmatrix} e^{-i\phi/2} & 0 \\ 0 & e^{i\phi/2} \end{pmatrix}

RZ and the P gate are the same operation up to a global phase: rz(φ) and p(φ) give identical measurement statistics in any circuit. rz(π) is a Z gate up to a global phase.

Effect on basis states

InputOutput
0\vert 0 \rangleeiϕ/20e^{-i\phi/2}\vert 0 \rangle
1\vert 1 \rangleeiϕ/21e^{i\phi/2}\vert 1 \rangle
+\vert + \rangle12(eiϕ/20+eiϕ/21)\tfrac{1}{\sqrt{2}}(e^{-i\phi/2}\vert 0 \rangle + e^{i\phi/2}\vert 1 \rangle)

A measurement straight after RZ shows no change on 0\vert 0 \rangle or 1\vert 1 \rangle, whatever the angle. The rotation shows once the qubit is in superposition.

Inverse

The inverse of rz(φ) is rz(-φ).

Usage

from math import pi
from qiskit import QuantumCircuit

qc = QuantumCircuit(1, 1)
qc.h(0)
qc.rz(pi, 0)
qc.h(0)
qc.measure(0, 0)
import { QuantumCircuit } from 'qiskit';

const circuit = QuantumCircuit(1, 1);
circuit.h(0);
circuit.rz(Math.PI, 0);
circuit.h(0);
circuit.measure(0, 0);

Every shot reads 1: rz(π) acts as a Z, and H Z H is an X.

On IonQ hardware

RZ is the virtual Z itself. The hardware performs no physical operation for it; the compiler adds the angle to the phase of the pulses that follow, so RZ costs no gate and no time on the machine, whatever the angle. A circuit heavy in Z rotations can compile smaller than its written gate count suggests. See How your circuit is compiled.

Stay in the loop.

Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.