quantum gate directory

Gates Groups SDKs GitHub
$\mathrm{RCC}X$

multi-qubit· 3 qubits

Margolus

Simplified Toffoli gate, equal to the Toffoli up to a $-1$ phase on $|101\rangle$, costing only three CNOTs.

Open in Quirk ↗ hermitian

The Margolus gate (Qiskit's "relative-phase" or "simplified" Toffoli, RCCX) acts exactly like the Toffoli on every computational basis state except one, where it picks up a harmless-looking sign:

$$ \mathrm{RCC}X = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & -1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix} $$

That is, $\mathrm{RCC}X = \mathrm{CC}X$ except $|101\rangle \mapsto -|101\rangle$.

Why it matters

An exact Toffoli requires six CNOTs; the Margolus gate needs only three (Shende and Markov proved both counts optimal). Whenever a Toffoli is used in a compute–uncompute pair — as ancilla logic almost always is — the stray phase cancels between the compute and uncompute halves, so the cheap version is safe and halves the entangling-gate cost.

Decompositions

  • Three CNOTs and four rotations, all real: $$ \begin{align*} \mathrm{RCC}X = {} & R_y(-\tfrac{\pi}{4})_t \, \mathrm{CX}_{2,t} \, R_y(-\tfrac{\pi}{4})_t \, \mathrm{CX}_{1,t} \\ & \times R_y(\tfrac{\pi}{4})_t \, \mathrm{CX}_{2,t} \, R_y(\tfrac{\pi}{4})_t \end{align*} $$ (read right to left; subscripts denote control, target).

Properties

  • Hermitian and self-inverse, like the Toffoli itself.
  • Entirely real, so it lies in the orthogonal group.

Also written

  • $\mathrm{RCCX}$
  • $\widetilde{\mathrm{CC}X}$

Groups

  • orthogonal

Reference

On the CNOT-cost of TOFFOLI gates (2008)

Data

  • This gate as JSON
  • Edit this page on GitHub

The unitary, drawn

Every entry of the matrix as a disc. The area is the transition probability $|U_{jk}|^2$; the colour and the hand are the phase. Rows are outputs $\langle j|$, columns inputs $|k\rangle$, in the computational basis.

Phase

Disc area $= |U_{jk}|^2$. Hover an entry for its value, or take the JSON.

SDK support

How to call this gate in each framework. Hover a ⓘ for a note; the support matrix compares every gate at once.

SDKName
Qiskit qiskit.circuit.library.RCCXGate
PennyLane —
Cirq —
Q# —
PyQuil —
Braket —
BQSKit bqskit.ir.gates.MargolusGate ⓘ
Qibo — ⓘ
pytket —
Stim —
OpenQASM —

← All gates

gate.directory made by nts $\oplus$ rdls