Finite differences and parameter shifts
A comparison of approximate small-step differentiation and exact shift identities for suitable quantum circuit expectations.
On this page
Definition, purpose and input assumptions
Finite differences estimate derivatives by evaluating nearby parameter values. Parameter-shift rules exploit known frequency structure and can be exact at finite offsets. Both use objective evaluations, but their truncation and noise behavior differ. A correct comparison specifies the generator spectrum, parameter reuse and measurement statistics.
Mathematical mechanism
The central finite difference is D_h f=[f(theta+h)-f(theta-h)]/(2h), with order-h-squared bias for a sufficiently smooth function. For f=cos(theta), D_h f=-sin(theta)sin(h)/h. A standard Pauli parameter shift instead uses h=pi/2 and prefactor1/2, yielding the exact derivative -sin(theta); it is not the central finite-difference formula with its usual denominator.
Fully solved reference example
At theta=pi/3 and h=0.1, the central difference is-(sqrt(3)/2)sin(0.1)/0.1, approximately -0.86458275. The exact derivative is approximately -0.86602540, so the error is about 0.00144265. Reducing h decreases this bias.
If two independent expectation estimates each have variance at most1/N, the central-difference variance is at most1/(2Nh^2). At h=0.1 this is 50/N. The standard parameter-shift estimator has variance at most1/(2N). Small h therefore amplifies measurement noise even while reducing truncation bias.
Limitations and classical comparison
A parameter-shift identity is unavailable in that simple form for every gate or shared parameter. Simulator backpropagation may be more efficient when internal states are accessible. Finite differences remain general, but their step size must balance bias, roundoff and sampling noise.
Scientific relationships
This comparison connects parameter-shift gradients, numerical precision and shot allocation. It distinguishes an exact analytic identity from an approximate derivative estimator.
A shared parameter that invalidates a naive shift
Apply two consecutive R_Y(θ) gates to |0> and measure Z. The gates combine to R_Y(2θ), so f(θ)=cos(2θ) and f'(θ)=-2sin(2θ). Shifting the shared parameter everywhere by ±π/2 gives f(θ+π/2)=f(θ-π/2)=-cos(2θ). Their half-difference is zero, which is generally the wrong derivative. The usual single-Pauli-gate rule was applied to a function with a different frequency.
At θ=π/8, the correct derivative is -√2. A frequency-aware rule uses shifts ±π/4 and coefficient one: f'(θ)=f(θ+π/4)-f(θ-π/4). The two values are -1/√2 and 1/√2, whose difference is -√2. The finite offset is exact because the entire function has only frequency two, not because a large central-difference step happens to approximate it well.
An alternative is to differentiate each gate occurrence separately. Holding the other occurrence fixed, a ±π/2 shift on one gate gives contribution -sin(2θ). Summing the two occurrences gives -2sin(2θ). This method follows the actual parameter-sharing map and remains valid when surrounding gates prevent the simple combination into R_Y(2θ). In the special commuting example, identical shifted circuits can be reused, but that simplification should be proved rather than assumed.
An exact four-evaluation rule for two frequencies
Consider f(θ)=[cos θ+cos(2θ)]/2, which can arise as an equally weighted classical mixture of two expectation models. Its derivative is -(1/2)sin θ-sin(2θ). Define d1=f(θ+π/2)-f(θ-π/2) and d2=f(θ+π/4)-f(θ-π/4). The first difference equals -sin θ, while the second equals -(1/√2)sin θ-sin(2θ).
Solving for the desired derivative gives f'(θ)=d2+[(1-√2)/2]d1. At θ=π/6, this equals -1/4-√3/2. Both frequency components are recovered exactly from four function values. A rule designed only for the frequency-one part would miss the second harmonic, while a rule designed only for frequency two would give the wrong coefficient for the first.
The coefficients follow from a small linear system matching sine responses at every known frequency. A general finite-spectrum rule uses enough shifts to resolve that support. If the actual circuit contains additional frequencies because of parameter reuse, nonlinear parameter expressions, or a different generator spectrum, the previously derived rule need not remain exact. The spectrum is an input to the identity, not a property inferred from the word rotation alone.
Comparing estimator variance at fixed shot counts
Suppose each of the four function estimates has independent variance at most 1/N. The variance of the two-frequency derivative estimate is at most 2[1+((1-√2)/2)²]/N=(7-2√2)/(2N). The coefficient weights therefore affect statistical cost even though the rule has no truncation bias. Unequal shot allocation can reduce the variance by assigning more samples to evaluations with larger weighted standard deviations.
A central finite difference instead divides by 2h. For a smooth single-frequency example at θ=π/3, the squared leading bias is h⁴/48, while a conservative shot-variance bound is 1/(2Nh²). Minimizing this approximate mean-squared-error model gives h⁶=12/N. The result explains why reducing h arbitrarily is not optimal when N is fixed: statistical noise eventually overwhelms the smaller truncation error.
That optimum is conditional on the local expansion and variance model. Actual observable variances can be lower than the bound, correlated evaluations can alter the difference variance, and floating-point cancellation introduces another contribution in a classical simulation. A reported step size should therefore be tied to a concrete error model rather than described as universally accurate.
Controlled generators and nonlinear classical processing
A controlled Pauli rotation has generator |1><1|⊗P/2, with eigenvalues zero and plus or minus one half. Its gap set includes both one half and one. The simple two-eigenvalue shift rule for P/2 does not automatically apply to the controlled gate as a whole. A correct implementation can derive an appropriate multi-frequency rule, decompose the gate into supported differentiable pieces, or use another valid differentiation method.
The derivative of a quantum expectation is also only one part of a hybrid cost. If the final objective is a nonlinear function of several expectations, the classical chain rule combines their Jacobian with derivatives of that postprocessing. For a postselected expectation, differentiating the success normalization is essential. Ignoring these dependencies can produce a mathematically correct derivative of the wrong scalar objective.
Classical adjoint differentiation is often efficient when the simulator exposes full state arrays, whereas hardware access provides sampled outcomes rather than those arrays. Comparing the methods should preserve that information difference. Exact shift rules avoid finite-difference truncation, but they do not eliminate preparation cost, measurement variance, or the need to identify all parameter occurrences.
Sources
Verification scope
Recorded source check ·
Full official API page retrieved, 554 lines; shift recipes and generator frequencies inspected.
Formal or reference-semantic source anchor only; no SDK execution, hardware run, or empirical advantage is asserted. Original worked examples are independent mathematical constructions.
Verification scope
Recorded source check ·
Classical statevector differentiation, reversibility, and storage assumptions inspected.
Formal scientific or official reference-semantics anchor. No SDK execution, hardware run, universal performance claim, or independent external peer review asserted. Original finite examples and definitions are independent explanations.
Verification scope
Full-text source check ·
Full8-page PDF indexed; generator-spectrum condition for two-point shift inspected.
Exact expectation identities do not remove finite-shot variance; generators with more frequencies require appropriate generalized rules.