RX gate

The RX gate, a rotation about X by any angle: matrix, effect on the basis states, the rx() call in Python and JS, and its IonQ native-gate form.

The RX gate rotates a qubit about the X axis of the Bloch sphere by an angle θ\theta. It acts on one qubit and takes one parameter, θ\theta in radians. The Circuit panel draws it as Rx(θ) with the angle shown as a multiple of π. Measured straight after it, a qubit that started as 0 reads 1 with probability sin2(θ/2)\sin^2(\theta/2): never at θ=0\theta = 0, half the time at θ=π/2\theta = \pi/2, always at θ=π\theta = \pi.

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.rx(θ, qubit)
JScircuit.rx(θ, qubit)
Qiskit classRXGate
Controlled formcrx(θ, control, target)

Matrix

RX(θ)=(cosθ2isinθ2isinθ2cosθ2)RX(\theta) = \begin{pmatrix} \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} \\ -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}

rx(π) is an X gate and rx(π/2) is a √X gate, both up to a global phase.

Effect on basis states

InputOutput
0\vert 0 \ranglecosθ20isinθ21\cos\frac{\theta}{2}\vert 0 \rangle - i\sin\frac{\theta}{2}\vert 1 \rangle
1\vert 1 \rangleisinθ20+cosθ21-i\sin\frac{\theta}{2}\vert 0 \rangle + \cos\frac{\theta}{2}\vert 1 \rangle

Measured straight after rx(θ), a qubit that started in 0\vert 0 \rangle reads 1 with probability sin2(θ/2)\sin^2(\theta/2): 0 at θ=0\theta = 0, one half at θ=π/2\theta = \pi/2, certainty at θ=π\theta = \pi.

Inverse

The inverse of rx(θ) is rx(-θ).

Usage

from math import pi
from qiskit import QuantumCircuit

qc = QuantumCircuit(1, 1)
qc.rx(pi / 3, 0)
qc.measure(0, 0)
import { QuantumCircuit } from 'qiskit';

const circuit = QuantumCircuit(1, 1);
circuit.rx(Math.PI / 3, 0);
circuit.measure(0, 0);

Over many shots about a quarter of them read 1: sin2(π/6)=0.25\sin^2(\pi/6) = 0.25.

On IonQ hardware

RX is not a native gate for a general angle, because the native pulses GPi and GPi2 have fixed angles of π and π/2. An arbitrary rx(θ) compiles to two GPi2 pulses with a virtual Z of angle θ between them. The special angles are cheaper: rx(±π/2) is a single GPi2 and rx(π) is a single GPi. 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.