X gate
The X gate, the quantum NOT: matrix, effect on |0⟩ and |1⟩, the x() call in Python and JS, and its IonQ native-gate form.
The X gate, the quantum NOT, flips a qubit: becomes and becomes . It acts on one qubit and takes no parameters. The Circuit panel draws it as X. Measured straight after it, a qubit that started as 0 reads 1.
Kets such as name the basis states and rotations are described on the Bloch sphere; the qubits lesson introduces both.
Call
| Where | Call |
|---|---|
| Python | qc.x(qubit) |
| JS | circuit.x(qubit) |
| Qiskit class | XGate |
| Controlled form | cx(control, target) |
Matrix
On the Bloch sphere this is a half-turn about the X axis. It is the same operation as rx(π) up to a global phase.
Effect on basis states
| Input | Output |
|---|---|
On a superposition it swaps the two amplitudes, so is unchanged and only picks up a sign.
Inverse
X is its own inverse. Two X gates in a row on the same qubit cancel.
Usage
from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.x(0)
qc.measure(0, 0)
import { QuantumCircuit } from 'qiskit';
const circuit = QuantumCircuit(1, 1);
circuit.x(0);
circuit.measure(0, 0);
Every shot reads 1.
On IonQ hardware
X is exactly GPi(0), a native gate, so it costs one physical pulse. See How your circuit is compiled.
Related
Stay in the loop.
Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.
Gates