Quantum Lab
Quantum Lab

An interactive quantum mechanics learning platform and cryostat wiring co-design tool. From plain-language intuition to formal mathematics.

contact@quantumcircuitsimulator.com

Product

  • Circuit Lab
  • Learn
  • Hardware Studio
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Quantum Lab. All rights reserved.

This site, including its original quantum simulations, cryostat reference systems, 3D models, and interface design, contains protected proprietary material.

Home/Quantum Physics/Lessons/Toffoli Gate (CCX)
CCX

Toffoli Gate (CCX)

Multi-qubit3-qubitAND

Flips target only when both controls are |1⟩.

Intuition

The Toffoli gate is a three-qubit gate that extends the CNOT idea: it flips the target qubit only when both control qubits are |1⟩. Classically, this implements a reversible AND gate. But quantumly, it acts on superpositions of all eight three-qubit basis states simultaneously. The Toffoli gate is universal for classical reversible computing, and when combined with Hadamard, it becomes universal for quantum computing.

Matrix representation
I8​ with ∣110⟩↔∣111⟩
Action on states
∣ab,c⟩→∣ab,c⊕(a∧b)⟩
Circuit
Open in simulator →
q0q1q2XXCCX
▶ Try it in the simulator
Precise explanation

Toffoli (CCX) is a three-qubit gate acting as |ab,c⟩ → |ab, c ⊕ (a ∧ b)⟩. It is a doubly-controlled X: the target flips if and only if both controls are |1⟩. The gate is its own inverse, unitary, and preserves computational basis states. It can simulate any classical logic circuit reversibly. On quantum states, it applies the controlled-controlled-NOT operation coherently across all branches of a superposition.

Observable effect

Classical AND logic applied to the amplitudes.

Hidden effect

Still acts coherently on superpositions — not purely classical despite looking like a classical gate.

Bloch sphere

Conditional X on target when both controls are |1⟩. Individual Bloch vectors depend on the full three-qubit state.

Truth table
|000⟩→|000⟩
|010⟩→|010⟩
|100⟩→|100⟩
|110⟩→|111⟩
|111⟩→|110⟩
Worked example

Reversible AND computation

  1. 1Start with |110⟩: both controls are |1⟩, target is |0⟩.
  2. 2Apply Toffoli: since both controls are 1, the target flips. State becomes |111⟩.
  3. 3Now start with |100⟩: only one control is |1⟩.
  4. 4Apply Toffoli: the target stays unchanged. State remains |100⟩.
  5. 5The target qubit now holds the AND of the two controls.
Common use cases
  • Reversible classical logic inside quantum circuits
  • Quantum arithmetic (adders, multipliers)
  • Oracle construction for Grover’s search
  • Quantum error correction circuits
  • Universal classical computation (any Boolean function)
Relation to other gates
  • Toffoli = doubly-controlled X (CCX)
  • With one control fixed to |1⟩, Toffoli reduces to CNOT
  • Toffoli + H = universal quantum gate set
  • Toffoli can be decomposed into 6 CNOTs and single-qubit gates
Common misconception

The Toffoli gate looks classical because its truth table matches AND, but it operates on quantum superpositions. When the controls are in superposition, the result is a coherent quantum state, not a classical mixture.

Why this gate matters

Toffoli proves that quantum computing includes all of classical computing. Any classical algorithm can be embedded as a reversible quantum circuit using Toffoli gates, and then quantum features like superposition can be layered on top.

Test your understanding

What classical logic gate does Toffoli implement reversibly?

▶ Try it in the simulatorQuick reference →↗ Nielsen and Chuang, Quantum Computation and Quantum Information
←
Previous
CNOT
Next
Swap
→
← Back to all lessons