Starlight Tools

Quantum • Gate matrices • Ideal state-vector simulation • Browser-only

Quantum Gate Truth Table Generator & Basis-State Simulator

A quantum “truth table” is not a Boolean AND/OR table. It shows how a unitary gate or circuit transforms each computational basis ket into amplitudes with magnitudes, phases, and measurement probabilities. Use the quick gate reference or build a circuit to calculate its state-vector map and unitary matrix.

One-click gate reference

Symbol

Action

Inverse

Key property

Unitary matrix

Build an editable circuit

Gate steps

    Circuit diagram

    No gate steps. The circuit is the identity.

    Conventional symbols: ● control, ⊕ controlled-X target, connected ● for CZ, and connected × for SWAP. Qubit 0 is the top wire.

    Advertisement

    Complete basis-state transformations

    Every nonzero output is shown; no outcomes are truncated.

    Method: each table row is U|b⟩. The probability of outcome |x⟩ is P(x)=|⟨x|U|b⟩|².

    Calculated circuit unitary U

    Basis-state transformation table with exact and decimal state-vector details
    Input basis |b⟩Output state, amplitudes, magnitude, probability, and phase

    Guided examples

    Each example uses input |0…0⟩. Load it to inspect the complete transformation table and unitary.

    Pauli-X: deterministic flip

    Input: |0⟩

    Sequence: X(q0)

    Intermediate/final: |0⟩ → |1⟩

    Probabilities: P(1)=100%

    Hadamard: superposition

    Input: |0⟩

    Sequence: H(q0)

    Intermediate/final: |0⟩ → (|0⟩+|1⟩)/√2

    Probabilities: P(0)=P(1)=50%

    CNOT: conditional flip

    Input: |10⟩ in top-wire order |q0 q1⟩

    Sequence: X(q0), CNOT(q0→q1)

    Intermediate: |00⟩ → |10⟩

    Final/probability: |11⟩, 100%

    Bell-state creation

    Input: |00⟩

    Sequence: H(q0), CNOT(q0→q1)

    Intermediate: (|00⟩+|10⟩)/√2 in top-wire order

    Final: (|00⟩+|11⟩)/√2; 50% each

    SWAP: exchange qubit states

    Input: |10⟩ in top-wire order

    Sequence: X(q0), SWAP(q0,q1)

    Intermediate: |00⟩ → |10⟩

    Final/probability: |01⟩, 100%

    Phase-only change

    Input: |0⟩

    Sequence: H(q0), Z(q0)

    Intermediate: (|0⟩+|1⟩)/√2

    Final: (|0⟩−|1⟩)/√2; still 50% each

    H–Z–H interference

    Input: |0⟩

    Sequence: H, Z, H

    Intermediate: |0⟩ → |+⟩ → |−⟩

    Final: |1⟩, because HZH=X—not phase kickback

    How to use the generator

    1. Choose 1–3 qubits and a ket display convention.
    2. Select a gate and assign only the roles that gate needs.
    3. Add, edit, reorder, undo, or remove steps.
    4. Read U, each U|b⟩, and the complete outcome bars.

    What a quantum truth table means

    A classical reversible gate permutes basis states. A quantum gate can also create superpositions and relative phases, so its table must preserve complex amplitudes. For example, H maps |0⟩ to (|0⟩+|1⟩)/√2 rather than one Boolean output.

    Amplitude versus probability

    An amplitude is a complex number a+bi. Its magnitude is √(a²+b²), and its measurement probability is a²+b². Probabilities discard phase, so the state-vector and probability views answer different questions.

    Gate matrices and unitary evolution

    The selected steps multiply into one circuit matrix U. Its columns are the output vectors for the displayed input basis order. Unitarity preserves total probability and makes every supported gate reversible.

    Global versus relative phase

    Multiplying the entire state by one phase has no observable effect. Changing the phase of only some terms is relative phase; later gates can convert it into different probabilities through interference. HZH=X is phase-to-bit conversion, not phase kickback. True kickback needs a controlled operation and a target eigenstate.

    Measurement and collapse

    The bars show theoretical computational-basis probabilities. A physical measurement samples one outcome and collapses the state. This simulator does not sample shots or insert measurement operations.

    Bit-order convention

    Internally q0 is the least-significant bit and is the top wire. In default Qiskit-style labels, |q1 q0⟩ means CNOT q0→q1 uses the rightmost character as control and the leftmost as target: |01⟩→|11⟩. Switch to top-wire order and the same mapping reads |10⟩→|11⟩.

    Simulator limitations

    The simulator is intentionally small and ideal: 1–3 qubits, the listed fixed gates, no noise, no decoherence, no connectivity or timing constraints, no parameterized rotations, and no mid-circuit measurement or classical control.

    Calculation method and limitations

    This page performs an ideal client-side state-vector simulation using double-precision JavaScript complex arithmetic. It applies each 2 × 2 gate to paired amplitudes and controlled/permutation gates by basis-index mapping, then constructs the circuit unitary by simulating every basis vector. Values below 10−10 are treated as numerical zero for display; exact forms are recognized for common introductory constants, while decimals remain the computed source of truth.

    • Limits: 1–3 qubits; X, Y, Z, H, S, T, CNOT, CZ, SWAP, and Toffoli; no set gate-count cap beyond practical browser/UI limits.
    • Ordering: q0 is always the top wire and least-significant bit. Labels can display |q(n−1)…q0⟩ or top-wire |q0…q(n−1)⟩.
    • Not modeled: noise, hardware calibration, decoherence, measurement sampling/collapse, reset, mid-circuit measurement, or device connectivity.

    Method references: IBM Quantum Composer state-vector and probability visualizations and Google Cirq simulation documentation.

    Reviewed and updated: .

    Quantum gate truth table FAQ

    Do quantum gates have truth tables?

    They have basis-state transformation tables. Unlike Boolean truth tables, they may map one input ket to several output kets with complex amplitudes and phases.

    What is the Hadamard truth table?

    H|0⟩=(|0⟩+|1⟩)/√2 and H|1⟩=(|0⟩−|1⟩)/√2. Both inputs give 50/50 measurement probabilities, but their relative signs differ.

    What is the CNOT truth table?

    For |control target⟩: |00⟩→|00⟩, |01⟩→|01⟩, |10⟩→|11⟩, |11⟩→|10⟩. Check the selected display order before identifying characters.

    Why can one input produce multiple output states?

    A unitary such as H can create a superposition. The output is one quantum state with multiple basis components, not several simultaneous classical answers.

    Why can phase change while probability stays the same?

    Probability is amplitude magnitude squared, so rotating an amplitude in the complex plane does not change its magnitude. Relative phase becomes observable when later operations make amplitudes interfere.

    What order are qubits written in a ket?

    The default is Qiskit style, |q(n−1)…q0⟩, where top-wire q0 is rightmost. The alternate option writes the top wire first as |q0 q1…⟩.

    Do probabilities always sum to one?

    Yes for normalized states and unitary evolution, apart from tiny floating-point error. Every row displays its computed total as a check.

    Does this tool perform measurement or model noise?

    No. It calculates ideal computational-basis probabilities but does not sample shots, collapse states, or model real-device noise.

    Explore more tools