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: 0\vert 0 \rangle becomes 1\vert 1 \rangle and 1\vert 1 \rangle becomes 0\vert 0 \rangle. 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 0\vert 0 \rangle name the basis states and rotations are described on the Bloch sphere; the qubits lesson introduces both.

Call

WhereCall
Pythonqc.x(qubit)
JScircuit.x(qubit)
Qiskit classXGate
Controlled formcx(control, target)

Matrix

X=(0110)X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}

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

InputOutput
0\vert 0 \rangle1\vert 1 \rangle
1\vert 1 \rangle0\vert 0 \rangle
+\vert + \rangle+\vert + \rangle
\vert - \rangle-\vert - \rangle

On a superposition it swaps the two amplitudes, so +\vert + \rangle is unchanged and \vert - \rangle 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.

Stay in the loop.

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