Numerical precision in quantum simulation
The finite arithmetic accuracy used to represent amplitudes, operators and computed probabilities in a classical simulator.
On this page
Definition and significance
Numerical precision affects whether a simulated result faithfully represents its mathematical model. Floating-point roundoff is distinct from the model's physical noise. A numerically stable simulation of an ideal circuit does not establish that hardware is ideal, and a tiny rounding residual is not evidence of decoherence.
Mechanism and mathematical treatment
For a normalized statevector, sum_j |a_j|^2 should remain one within a documented numerical tolerance. An inner-product comparison is often more meaningful than entrywise equality because two vectors differing by one global phase represent the same pure state. A useful phase-insensitive quantity is |<psi|phi>|^2.
Fully worked reference example
Let |phi>=i|psi>. Their entrywise difference has norm sqrt(2), but their overlap magnitude squared is one. Conversely, |psi>=|+> and |phi>=|-> have identical computational probabilities while their overlap is zero. Both examples show why one naive equality metric can misclassify a result.
Limitations and common misconceptions
Renormalizing after every step can conceal a nonunitary implementation error. Validate known invariants and use reference calculations where feasible. Precision claims must state numeric type and algorithm, especially for ill-conditioned eigenvalue or reciprocal calculations.
Scientific relationships
Finite arithmetic affects fidelity to the selected mathematical model.
A small residual can coexist with a large solution error
Let A=diag(1,10 to the minus sixth) and b=(1,0). The exact solution is x=(1,0). A candidate x_hat=(1,1) has residual A x_hat-b=(0,10 to the minus sixth), which looks small in absolute norm. Its solution error has norm one, however, because the small second eigenvalue amplifies the residual by a factor of one million.
The normalized states associated with x and x_hat are |0> and |+>, whose fidelity is one-half. Thus a residual of magnitude one millionth is not enough to certify a useful normalized output state for this ill-conditioned system. A residual-based validation must include an inverse-norm or condition-number bound, and a state comparison must additionally account for normalization.
The same example can be viewed as input sensitivity. Replacing b by (1,10 to the minus sixth) changes the classical input by only one millionth in norm but changes the exact solution to (1,1). A numerically accurate solver can therefore return a very different answer for slightly perturbed data without any implementation defect. Arithmetic error, input uncertainty, and the mathematical problem's conditioning are separate contributions.
Cancellation and small probabilities
Under ordinary binary64 arithmetic, evaluating (10 to the sixteenth plus one) minus 10 to the sixteenth can produce zero, while evaluating (10 to the sixteenth minus 10 to the sixteenth) plus one produces one. The first addition loses the unit contribution because it lies below the spacing of representable values at that scale. This is an arithmetic-order effect, not a stochastic error or quantum phenomenon.
Related cancellation can arise when computing a small probability as a complement. For the state with amplitudes sqrt(1-epsilon squared) and epsilon, take epsilon=10 to the minus tenth. The small probability is epsilon squared=10 to the minus twentieth and can be represented directly from the second amplitude. In binary64, the first amplitude can round to one, so subtracting its squared magnitude from one yields zero and loses the small probability entirely.
A reported statevector norm can still round to one in that example. Norm preservation is necessary but cannot certify accurate relative values for every tiny probability. An output contract requiring absolute error of 10 to the minus eighth is very different from one requiring ten percent relative accuracy on a probability of 10 to the minus twentieth. Validation tolerances must follow the quantity of interest.
Phase alignment and stable state comparisons
For normalized vectors psi and phi, choose the alignment phase from the argument of their overlap. Multiplying phi by the negative of that phase makes the overlap real and nonnegative. Their minimum Euclidean separation over global phase is then sqrt(2-2|<psi|phi>|). This metric respects pure-state equivalence while retaining sensitivity to relative phases inside either vector.
When the states are extremely close, subtracting two nearly equal numbers in the expression under that square root can itself lose precision. Directly forming the phase-aligned vector difference can be a better numerical diagnostic. The phase is undefined when the overlap is zero, but the minimum distance is then sqrt(2) independently of the chosen alignment, so that boundary can be handled explicitly.
A fidelity close to one is not a certificate that every rare-event probability has small relative error. Conversely, a large entrywise difference before phase alignment can be physically irrelevant. Reporting a task-relevant observable error alongside a phase-insensitive state metric often makes a numerical comparison more informative than a single undifferentiated tolerance.
Accumulation bounds require operator assumptions
If exact gates U_j and approximate gates V_j are both unitary and each pair differs by at most epsilon_j in operator norm, a telescoping expansion bounds the complete product difference by the sum of epsilon_j. Unitarity prevents the surrounding products from magnifying each local difference. This mathematical bound concerns gate approximation, distinct from finite-shot statistics.
If the numerical V_j are not exactly unitary, their surrounding products can amplify error. A conservative bound involves products of factors 1+epsilon_j, giving an overall estimate of product_j(1+epsilon_j)-1 when the local bounds are appropriate. Renormalizing a state after every step can conceal norm growth without correcting the accumulated direction or phase error.
For density matrices, trace, Hermiticity, and positivity should be checked separately. A tiny negative eigenvalue may be compatible with a documented numerical tolerance, but clipping all negative eigenvalues and renormalizing changes the result. Such a repair should not replace investigation of an incorrect channel, unstable integration, or an inconsistent index convention. Physical postselection also produces subnormalized matrices intentionally, so a trace below one is not always drift.
Sources
Verification scope
Recorded source check ·
Simulation guide retrieved; explicit qubit_order semantics and distinction between state and measurement output inspected.
Conceptual reference semantics only. No code execution or universal backend support claim.
Verification scope
Recorded source check ·
Full ordering guide retrieved; statevector/integer/string conventions and explicit object-level result distinctions inspected.
Conceptual reference semantics only. No code execution or universal backend support claim.