How this calculation works
The supported circuit begins in the computational zero state and applies gates that conjugate Pauli operators into Pauli operators. Hadamard H, phase S and controlled-NOT CX gates preserve a stabilizer representation, allowing exact algebraic tracking without listing every complex amplitude.
Initialize |0>^n tableau with Zstabilizers. Implement H,S,CNOT,X,Z phase-aware conjugations; optionally use exact bounded statevector only as independent test oracle,not advertised tableausubstitute. Measure Zq: if any stabilizer anticommutes, outcomes0/1 each1/2 and updaterowbyrow withchosenoutcome; ifallcommute, membership/phase yields deterministic outcome. Reject forcedoutcome ofzero probability. Retain conditional branch probabilities and cumulativebranchprobability; seeded sampling seedstate explicit. RejectT/nonCliffordgates.A worked example
With the prefilled inputs, selectedBranchProbability = 0.5. Gate objects: H/S with qubit, CX with control/target, MZ with qubit and optional outcome0/1.
Good to know
Pure |0…0> input,phase-aware stabilizer conjugation. Optional forced Z measurement outcomes are conditioned branches;no T gates,statevector amplitudes or noisy channels.
Reference: Primary method reference or author-maintained documentation (opens in a new tab) ↗
Clifford gates preserve a compact stabilizer description
The supported circuit begins in the computational zero state and applies gates that conjugate Pauli operators into Pauli operators. Hadamard H, phase S and controlled-NOT CX gates preserve a stabilizer representation, allowing exact algebraic tracking without listing every complex amplitude.
This is a restricted quantum circuit simulator, not a universal one. A T gate or arbitrary rotation generally leaves the stabilizer class and is outside the accepted input. Rejecting such a gate is clearer than approximating it while continuing to label the result exact.
Compare with the Clifford multivector geometric product calculator with metric signature. Evolve quantum Pauli stabilizers under H,S,CNOT and projective measurements; geometricCliffordalgebra multiplication is unrelated to quantumCliffordcircuits.
Make gate order and qubit indexing explicit
Gate objects: H/S with qubit, CX with control/target, MZ with qubit and optional outcome0/1.Gate objects are executed in their submitted order, using zero-based qubit indices. The supported names are H, S, CX and MZ. Controlled-NOT uses separate control and target properties; swapping those roles changes the state. Other named gates, including bare X or Z instructions, are rejected by this interface even though some can be composed from supported Clifford operations.
Measurement rows specify the measured qubit and either a selected outcome or a sampling instruction. A selected outcome conditions the later state on that branch. It does not mean that the outcome is certain, so the returned probabilities must accompany the final stabilizers.
Conjugate both Pauli letters and their signs
A binary tableau stores Pauli support and enough phase information to distinguish plus from minus. Gate updates must implement conjugation signs as well as swapping or adding binary masks. Hadamard sends Y to minus Y, which is a useful small sign-sensitive test.
For a Z measurement, an anticommuting stabilizer implies two equally likely outcomes. The tableau then changes to enforce the selected eigenvalue while preserving a consistent independent generator set. If all stabilizers commute with the measured operator, phase-aware membership decides the deterministic outcome instead.
Prepare and measure a Bell pair
Apply Hadamard to qubit zero and then controlled-NOT from zero to one. The resulting Bell state has stabilizers XX and ZZ. Measuring qubit zero in the computational basis gives zero or one with probability one half each.
Condition on outcome zero for the first measurement. The second qubit is then certainly zero, so a following zero measurement has conditional probability one. The combined selected branch has probability one half, not one quarter; treating the two measurements as independent would be wrong.
Show conditional probabilities beside each measurement
A static Bell-circuit figure should label control and target roles and mark the selected branch. The returned measurements table records each outcome, whether it was random, and its conditional probability. The product is returned as selectedBranchProbability. This makes the effect of earlier conditioning explicit without suggesting that repeated measurements are independent.
Final stabilizer rows describe the conditional state after the selected history. They do not list every branch simultaneously. If the page offers sampled outcomes, show the seed and sampling mode separately from the algebraic probability calculation so reproducibility is not confused with certainty.
Impossible forced outcomes must stop the branch
After conditioning the Bell pair's first measurement to zero, forcing the second measurement to one has probability zero. The engine should identify the impossible row and stop that branch rather than overwrite the tableau to accommodate the requested value.
Repeated measurement of the same qubit without an intervening noncommuting gate is deterministic. This provides another consistency test. A simulator that keeps returning one-half probabilities for repeated measurements is ignoring state collapse or failing to track the measurement eigenvalue.
Validate the restricted simulation independently
For a few qubits, compare tableau results with an independent state-vector implementation using exact or tightly checked gate matrices. The state vector is a test oracle, while the production interface remains explicit about its supported Clifford operations and computational limits.
Test phase-sensitive sequences, reversed controlled-NOT roles, repeated measurements and zero-probability selected outcomes. A seeded random generator can make sampling reproducible, but it cannot compensate for incorrect deterministic-versus-random classification in the quantum update rules. The public prefill selects Bell outcomes one and one, whereas the worked explanation selects zero and zero. Each history has branch probability one half. Their final stabilizer signs differ because they describe different conditional states. The seed controls only measurements without an explicitly requested outcome; it does not change either selected branch probability or make an impossible outcome valid. Pure |0…0> input,phase-aware stabilizer conjugation. Optional forced Z measurement outcomes are conditioned branches;no T gates,statevector amplitudes or noisy channels.
A few questions, answered
Can this simulator execute a T gate?
No. T is non-Clifford and generally leaves the supported stabilizer representation.
Are the two Bell-pair measurements independent?
No. The first outcome determines the second when both are measured in the computational basis.
What happens if I force an impossible measurement outcome?
The branch has probability zero and should be rejected at that measurement row.
Does a fixed seed change measurement probabilities?
No. It selects a reproducible sampled history. The underlying conditional quantum probabilities remain the same.