Bukit Timah Tutor Mathematics

A connected Mathematics learning system from school foundations to examinations, applications and advanced study. Use the Mathematics Hub to move between levels, concepts, diagnosis, examinations, applications and world routes.

Quantum Mathematics Learning Guide 14: Variational Quantum Eigensolvers, Rayleigh Quotients and Optimisation

Three learners review open books together at a classroom table, with stacks of textbooks, stationery and a whiteboard in the bright room.

A variational quantum eigensolver searches for a low-energy state by combining quantum measurements with classical optimisation. Its central guarantee is an energy bound—not a promise that the optimiser will find the ground state.

Imagine being given an enormous Hermitian matrix. You want its smallest eigenvalue, but constructing every entry and diagonalising the whole matrix may be impractical. Instead, you can prepare selected states and estimate their energy. Can repeated, informed adjustments move those states toward the lowest-energy direction?

That is the organising idea of the variational quantum eigensolver, usually abbreviated VQE. A parameterised circuit prepares a candidate state, measurements estimate a cost, and a classical algorithm changes the parameters. The original experimental proposal and the subsequent hybrid-algorithm theory established this combination of quantum expectation estimation and classical optimisation. [1,2]

This guide develops the mathematics rather than treating VQE as a software command. We will derive the Rayleigh bound, solve a one-qubit example completely, construct a two-qubit example where entanglement changes what is reachable, calculate measurement uncertainty and explain what a low reported energy does—and does not—prove.

This is university-level enrichment. Begin with matrices, eigenvalues and measurement and density matrices and expectation values. No particular hardware platform or software version is assumed.

Reading route: the Rayleigh quotient → a complete one-qubit solution → measurement and uncertainty → what the circuit can reach → verification → worked practice.

1. The Rayleigh quotient separates direction from scale

For a nonzero vector v and Hermitian H, define the Rayleigh quotient R(v) = v†Hv/(v†v). Multiplying v by any nonzero scalar leaves the quotient unchanged because the numerator and denominator are multiplied by the same squared magnitude.

The quotient therefore asks about a direction in state space, not the arbitrary length of its coordinate vector. For a normalised state ψ, the denominator is one and R(ψ) = ⟨ψ|H|ψ⟩. This is the expectation value of H.

If a candidate vector is not normalised, omitting the denominator can produce a meaningless comparison. Scaling a vector toward zero would then make its unnormalised quadratic form approach zero without improving the state. Normalisation is a constraint carrying physical meaning, not a cosmetic final step.

2. Derive the variational bound

Let the eigenvalues of H be E₀ ≤ E₁ ≤ …, with an orthonormal eigenbasis. Expand a normalised candidate as ψ = Σ cj|Ej⟩. The expectation is Σ |cj|²Ej, because cross terms vanish by orthogonality.

Every Ej is at least E₀ and the weights sum to one. Consequently,

⟨ψ|H|ψ⟩ − E₀ = Σ |cj|²(Ej−E₀) ≥ 0.

This is the finite-dimensional variational principle. The exact energy of every valid candidate is an upper bound on the ground energy. Equality requires the state to lie entirely in the ground eigenspace. The same bound holds for a density matrix because an expectation is then a convex average of pure-state expectations. [2,3]

The theorem does not say that every downhill optimisation path reaches E₀. It says that the physical objective has a floor. Reaching the floor is a separate computational question.

3. The four distinct parts of VQE

First specify H, the operator whose low-energy state matters. Second choose a circuit family U(θ), with parameters θ. Third specify how to estimate E(θ) = ⟨ψ(θ)|H|ψ(θ)⟩ for ψ(θ) = U(θ)|reference⟩. Fourth choose the classical procedure that updates θ. These four parts define the basic hybrid loop. [3]

Each part can fail independently. A wrong H solves the wrong model. A restrictive circuit may exclude the desired state. A poor estimator can return a biased or noisy cost. An optimiser may stop in an unhelpful region even when a better candidate exists.

Calling the whole procedure VQE does not remove these distinctions. A diagnosis should identify which part is limiting the result before recommending more parameters, more shots or more iterations.

4. An ansatz is a reachable family, not a guessed answer

The circuit family is often called an ansatz. Its parameters determine which candidate states can be prepared. The reference state is the initial state before the adjustable gates; it can incorporate useful knowledge of the problem.

There are two different questions. Is the family expressive enough to contain a useful approximation? Can the optimiser locate that approximation efficiently with the available measurements? More expressivity can help the first question while making the second harder.

For teaching, keep the family small enough to analyse. A one-parameter circuit can reveal the entire landscape and make errors visible. A large unexplained circuit may hide a basic sign, ordering or normalisation mistake beneath an impressive number of gates.

5. A complete one-qubit example

Choose H = Z + X/2. In the computational basis its matrix is [[1,1/2],[1/2,−1]]. The characteristic equation is λ²−5/4 = 0, so the exact eigenvalues are ±√5/2. The ground energy is therefore −√5/2, approximately −1.11803399.

Use the real one-parameter state ψ(θ) = cos(θ/2)|0⟩ + sin(θ/2)|1⟩. Its norm is one by the trigonometric identity. Direct multiplication gives ⟨Z⟩ = cos θ and ⟨X⟩ = sin θ. Thus the variational objective is

E(θ) = cos θ + (1/2)sin θ.

A matrix eigenvalue problem has become an elementary trigonometric minimisation problem. That reduction is useful because every part can be checked without relying on a black-box optimiser.

6. Solve the minimum analytically

Write E(θ) = (√5/2)cos(θ−α), where α = arctan(1/2). The coefficients match because cos α = 2/√5 and sin α = 1/√5. The minimum occurs at θ = π+α, approximately 3.60524026 radians.

At this angle, cos θ = −2/√5 and sin θ = −1/√5. Substitution gives E = −2/√5−1/(2√5) = −√5/2. The chosen family reaches the exact ground energy.

The derivative offers an independent check: E′(θ) = −sin θ + cos θ/2. It vanishes at the proposed angle. The second derivative is −cos θ−sin θ/2, which is positive there. Solving E′=0 without distinguishing minima from maxima would also find the opposite direction, whose energy is +√5/2.

7. What the same example says about a bad circuit family

Suppose the only adjustable operation is a Z rotation applied to |0⟩. That operation changes |0⟩ only by a global phase. Every parameter value therefore describes the same physical state, and every cost evaluation returns E = 1.

No amount of optimisation can lower that cost within this family. The problem is not insufficient learning rate, unlucky initialisation or too few iterations. The available transformation never leaves the wrong state direction.

This is the simplest example of expressivity failure. Before optimising a complicated circuit, ask whether its generators can actually move the state into the subspace required by the Hamiltonian. A parameter is useful only when changing it changes something relevant.

8. Estimate energy through Pauli expectations

For a qubit Hamiltonian H = Σ hjPj, linearity gives E = Σ hj⟨Pj⟩. Each Hermitian Pauli string has outcomes +1 and −1, so repeated preparation and measurement can estimate its expectation. The estimator need not reconstruct the full state vector. [2,3]

In our one-qubit example, estimate Z on one set of independently prepared copies and X on another. Combine the sample means as Ê = Z̄ + X̄/2. One cannot obtain both incompatible observables from the same single-qubit projective readout, but the expectation of their sum is still the sum of their expectations.

This is different from measuring the entire H in its exact eigenbasis. The latter would require a suitable measurement implementation of H. Pauli-term estimation trades that difficult measurement for repeated simpler measurements and classical arithmetic.

9. A shot is a sample, not an exact expectation

If P has outcomes ±1 and true mean μ, then P² = 1 for every outcome. Its variance is therefore 1−μ². The mean of m independent outcomes has variance (1−μ²)/m.

For separately sampled Pauli terms, the energy-estimator variance is Σ hj²(1−μj²)/mj. This expression assumes independence between the groups. When several terms are inferred from the same measurement records, covariance terms must be retained rather than silently discarded.

The square root is a sampling standard error, not a bound on every possible realised deviation. It also excludes systematic readout error, state drift and Hamiltonian-model error. More samples reduce one specific statistical component; they do not automatically repair all sources of inaccuracy.

10. Worked uncertainty calculation at the exact optimum

At our analytic optimum, μZ = −2/√5 and μX = −1/√5. Therefore Var(Z) = 1/5 and Var(X) = 4/5. Use 1,000 independent shots for each term.

The energy-estimator variance is (1/5)/1000 + (1/4)(4/5)/1000 = 0.0004. Its standard error is 0.02 energy units. This is a calculation for the stated ideal sampling model, not a report of experimental data.

The exact state is an energy eigenstate, so an ideal direct measurement of H would have zero intrinsic energy variance. Yet the separate-term estimator has nonzero sampling variance. There is no contradiction: the measurement procedures are different. The covariance that would appear in a joint H measurement is not available when incompatible terms are estimated on different copies.

11. Allocate measurements where they reduce uncertainty most

Let aj = hj²Var(Pj) and suppose a total of M shots is available. Minimising Σ aj/mj subject to Σ mj = M gives mj proportional to √aj, or |hj| times the standard deviation of that term.

For an illustrative two-term calculation with a₁ = 4, a₂ = 1 and M = 900, choose m₁ = 600 and m₂ = 300. The variance is 4/600+1/300 = 0.01. Equal allocation gives 5/450, approximately 0.011111. The improvement comes from reducing a larger uncertainty contribution more aggressively.

In practice the variances may be unknown initially. Pilot measurements can estimate them, after which the allocation can be adjusted. A variance estimate of zero from a small sample is not proof that the true variance is zero; conservative minimum allocations help prevent that mistake.

12. Parameter-shift gradients

Consider a parameter that occurs once in a gate exp(−iθP/2), where P² = I, and assume the other circuit operations do not depend on this parameter. Its expectation-value derivative obeys the exact parameter-shift identity

∂E/∂θ = [E(θ+π/2) − E(θ−π/2)]/2.

This is not a small-step finite difference. It follows from the two-eigenvalue generator and its sinusoidal parameter dependence. The shifted energies can be estimated using quantum measurements, giving an unbiased gradient estimator under the corresponding ideal sampling assumptions. [4]

Check the assumptions before applying the formula. A shared parameter appearing in several gates generally requires summing the contributions from its separate occurrences. More general generators can require different shifts or more evaluations. “Two shifted circuits” is not a universal derivative rule for every parameterised quantum program.

13. Verify the gradient on the solvable example

For E(θ) = cos θ + sin θ/2, evaluate E(θ+π/2) = −sin θ + cos θ/2 and E(θ−π/2) = sin θ − cos θ/2. Their difference divided by two is −sin θ + cos θ/2, exactly the derivative obtained by ordinary calculus.

With sampling, the two shifted energy estimates fluctuate. If they are independent, the variance of their half-difference is one quarter of the sum of their variances. An exact analytic identity does not turn finite experimental estimates into exact numbers.

This distinction explains why an optimiser can struggle near a minimum: the true gradient may be smaller than the gradient estimator’s uncertainty. The appropriate response may be a different sampling budget or stopping criterion, not an endless sequence of increasingly noisy parameter updates.

14. An example where product states cannot reach the ground energy

Consider the two-qubit Hamiltonian H = −X⊗X − Z⊗Z. The Bell state Φ⁺ = (|00⟩+|11⟩)/√2 has both XX and ZZ expectation equal to one, so its energy is −2.

For a product state, let the two local Bloch vectors have components (xA,yA,zA) and (xB,yB,zB). Its energy is −xAxB−zAzB. By Cauchy–Schwarz, the magnitude of this two-component dot product is at most one because each Bloch-vector length is at most one.

Every product state therefore has energy at least −1. Convex mixtures of product states obey the same bound. The gap between −1 and −2 is not an optimiser defect: an unentangled family simply cannot reach the ground energy for this Hamiltonian.

15. Add an entangling operation and solve again

Prepare ψ(θ) = cos(θ/2)|00⟩ + sin(θ/2)|11⟩. One implementation begins with |00⟩, rotates the first qubit about Y and then applies a controlled-NOT from the first qubit to the second.

Every state in this family has ⟨ZZ⟩ = 1. Direct calculation gives ⟨XX⟩ = sin θ. Thus E(θ) = −1−sin θ, whose minimum is −2 at θ = π/2. At that angle the state is exactly Φ⁺.

This example provides a complete diagnostic comparison: the Hamiltonian is fixed, the product-state floor is proved, the larger family is specified, and the improvement is calculated. It shows why useful entangling structure matters without making the much broader and false claim that every problem improves whenever more entangling gates are added.

16. Commuting does not always mean locally measurable together

The operators XX and ZZ commute: the two single-qubit anticommutation signs cancel. They share the Bell eigenbasis. Nevertheless, they are not qubit-wise commuting in a way that allows both to be read from one ordinary product-basis measurement using only independent local basis choices.

A joint measurement can require an entangling basis transformation. This distinction matters when grouping Hamiltonian terms for measurement. Global commutation is an algebraic condition; easy simultaneous readout is an implementation condition.

For learning, compare three concepts explicitly: commutation of whole operators, commutation on each individual qubit and the physical circuit used for readout. Treating these as the same statement can lead to incorrect shot counts or an impossible measurement prescription.

17. Separate ansatz error from optimisation error

Let Efamily be the lowest exact energy reachable within the chosen circuit family. The ansatz limitation is Efamily−E₀. If the optimiser returns a candidate with exact energy Ereturned, its remaining optimisation gap within that family is Ereturned−Efamily.

These quantities need not be directly known in a large problem, but the distinction is still useful. In the product-state example, the ansatz limitation is at least one energy unit. Changing the optimiser cannot remove it. In the one-qubit solvable example, the family contains the exact answer, so failure to reach it can be investigated as an optimisation or estimation problem.

Sampling and systematic measurement errors are additional contributions to the reported number. They should not be folded into the definition of what the circuit can physically prepare.

18. Flat landscapes and barren plateaus

A large circuit can contain many parameters while providing very small informative gradients. Barren-plateau results identify conditions under which gradient fluctuations become exponentially suppressed with system size, making training through finite-shot estimates difficult. Those results concern specified circuit and cost-function settings; they do not imply that every variational circuit must fail. [5]

There are also simpler reasons for a flat objective: a parameter may act only as a global phase, the reference may sit in a symmetry sector that the gates preserve, or the measured objective may be insensitive to the direction being varied. Diagnose these elementary possibilities before applying a broad theoretical label.

A sensible design uses problem structure, checks parameter relevance and compares several initial conditions. It does not equate a larger parameter count with a more trainable model.

19. Why a sampled energy can fall below the ground energy

The variational theorem concerns the exact expectation Tr(ρH) of a valid state for the specified H. A finite-sample estimator fluctuates around that expectation and can fall below E₀ on a particular run. That does not violate the theorem.

Optimisation can intensify this issue. When many noisy candidates are tested and the lowest observed value is selected, the chosen estimate tends to be unusually favourable because of selection. Re-evaluating the final parameters using fresh, independent samples helps separate a genuine improvement from a lucky downward fluctuation.

Physical state noise alone still leaves a valid density matrix, so its exact energy obeys the variational bound for the same H. Biased measurement processing, a wrong Hamiltonian, inconsistent calibration or some error-mitigation estimates can instead produce a number that is not the expectation of any physical state of that H. These explanations must be kept distinct.

20. An energy gap converts energy accuracy into state information

Assume a nondegenerate ground state and a known spectral gap Δ = E₁−E₀ > 0. If a normalised candidate has energy E₀+ε, then every excited-state component costs at least Δ. Therefore ε ≥ Δ(1−|⟨E₀|ψ⟩|²).

Rearranging gives the useful certificate

|⟨E₀|ψ⟩|² ≥ 1−ε/Δ.

For example, if Δ = 0.5 and the true energy excess is at most 0.01, the ground-state overlap is at least 0.98. If the gap is tiny or unknown, a small energy difference may provide a much weaker statement about the state. For a degenerate ground space, replace the single-state overlap by the total weight in that subspace.

21. Energy variance checks eigenstate character, not ground-state identity

For E = ⟨H⟩, the residual vector is (H−E)ψ. Its squared norm is ⟨H²⟩−⟨H⟩², the energy variance. A zero residual means ψ is an eigenstate; a small residual suggests concentration near a spectral value, with the precise conclusion depending on the spectrum.

An excited eigenstate also has zero variance. Consequently, reporting a tiny variance does not prove that the candidate is the ground state. It must be combined with energy information, symmetry-sector identification, lower bounds or other evidence.

There is a measurement cost too: H² can contain additional Pauli terms. A proposed verification step should include the cost of obtaining its evidence rather than treating certification as free.

22. The full resource calculation

A VQE run uses more than qubits and optimiser iterations. It uses state preparations, measurement settings, shots per setting, repeated gradient evaluations, circuit compilation and classical processing. The same shallow circuit may be executed a very large number of times.

An arbitrary matrix can have an exponentially large Pauli decomposition. Efficient expectation estimation therefore depends on a manageable representation of H and a suitable measurement scheme, not merely on the fact that every operator has a Pauli expansion. The hybrid framework does not guarantee an efficient solution to every eigenvalue problem. [2,3]

A fair comparison includes strong classical methods appropriate to the same structure. Exact diagonalisation is a useful small-instance reference, but sparse solvers, symmetry reduction and tensor-network methods may be more relevant at larger sizes. The next methods are alternatives to compare, not obstacles to dismiss.

23. Worked practice: twelve questions with explanations

1. Evaluate the Rayleigh quotient of v = (2,0) for H = Z

The numerator is v†Zv = 4 and the denominator is v†v = 4, so R(v) = 1. Normalising v gives |0⟩ and the same answer. The calculation demonstrates that the quotient removes arbitrary vector scale rather than rewarding small or large amplitudes indiscriminately.

2. A state has weights 0.8 and 0.2 on energies −2 and 3. Find its energy

The energy is 0.8(−2)+0.2(3) = −1. Its excess above the ground is one. The gap is five, so ε/Δ = 1/5 gives an excited-state weight of 0.2. In this two-level example, the gap-based overlap inequality is saturated.

3. Evaluate E(θ) for H = Z+X/2 at θ = 0 and θ = π

At zero, E = 1. At π, E = −1. The latter is better but not optimal: the true minimum is −√5/2, reached at π+arctan(1/2). Finding a candidate lower than the reference does not establish that no further improvement remains.

4. Differentiate the same objective at θ = π/2

The derivative −sin θ+cos θ/2 equals −1 at π/2. The parameter-shift calculation agrees: [E(π)−E(0)]/2 = (−1−1)/2 = −1. Two independent derivations help detect sign and angle-convention mistakes.

5. A Pauli observable has mean 0.6. What is the standard error of 400 independent shots?

The single-shot variance is 1−0.6² = 0.64. The sample-mean variance is 0.64/400 = 0.0016, so the standard error is 0.04. This is the ideal sampling contribution; a fixed detector bias is not divided by √400.

6. Why is the variance weighted by h², not h?

Multiplying a random estimate by h multiplies each deviation from its mean by h. Squaring those deviations multiplies the variance by h². A negative Hamiltonian coefficient changes the sign of its contribution to the energy but cannot make its uncertainty contribution negative.

7. What is the best product-state energy for H = −XX−ZZ?

It is −1. The Cauchy–Schwarz argument proves no product state can do better, and |00⟩ attains −1. The Bell state attains −2, so a product-only circuit has a genuine expressivity limitation for this example.

8. A measured energy is below a known E₀. Must the experiment be impossible?

No. A finite-sample estimate can fluctuate below the true mean. First inspect the uncertainty and use an independent evaluation. A persistent statistically significant violation points toward model, calibration or processing problems, because the exact expectation of a valid state cannot lie below the ground energy of the same H.

9. Use Δ = 0.2 and ε = 0.006 to bound ground-state overlap

The bound is 1−ε/Δ = 1−0.006/0.2 = 0.97. It requires the stated gap and a bound on the true energy excess, not merely the lowest noisy estimate encountered during optimisation. The result concerns overlap with a nondegenerate ground state or total weight in a separated ground subspace.

10. Does zero energy variance identify the ground state?

It identifies an eigenstate or a state supported within one degenerate energy eigenspace. It does not identify which energy. An excited eigenstate has zero variance too. Ground-state certification needs additional information distinguishing the bottom of the spectrum from the rest.

11. Why should the final parameters be measured again?

The optimiser selected those parameters using previous noisy observations. A fresh evaluation avoids reusing the favourable fluctuation that may have influenced the selection. It provides a cleaner estimate of the returned state’s energy, although it still requires enough shots and control of systematic errors.

12. A circuit has twice as many parameters. Is it necessarily better?

No. It may reach more states, but it can also require more evaluations, introduce irrelevant directions, increase noise and make optimisation harder. Compare the best verified energy at the same total resource budget, not parameter count alone. A small problem-informed family can outperform a much larger poorly chosen one.

24. How to teach and verify the complete loop

Begin with an H whose eigenvalues can be calculated exactly. Derive the circuit state’s coordinates, verify normalisation and write E(θ) symbolically. Solve at least one minimum by hand. Only then introduce simulated measurement samples and an optimiser.

This order lets a learner locate the first wrong move. A wrong symbolic energy suggests an operator or state error. A correct symbolic minimum but poor deterministic optimisation suggests an optimisation issue. A correct noiseless run but unstable sampled run suggests an estimation or stopping-rule issue.

The final learning test is transfer: change the Hamiltonian coefficient, restrict the circuit family or add a known sampling budget. Can the learner predict which part of the result should change? Understanding VQE means controlling that whole chain, not merely obtaining a low number from one implementation.

Sources and further study

[1] Alberto Peruzzo and colleagues, A variational eigenvalue solver on a quantum processor. The original experimental VQE paper motivates the quantum–classical division of work.

[2] Jarrod R. McClean and colleagues, The theory of variational hybrid quantum-classical algorithms. A theoretical treatment of variational state preparation, energy estimation and resource requirements.

[3] IBM Quantum Learning, The variational quantum eigensolver. An introduction to the Hamiltonian, ansatz, estimator and classical optimiser, including practical limitations.

[4] Maria Schuld and colleagues, Evaluating analytic gradients on quantum hardware. This source develops analytic differentiation methods, including parameter-shift rules and their generator-dependent assumptions.

[5] Jarrod R. McClean and colleagues, Barren plateaus in quantum neural network training landscapes. The paper establishes vanishing-gradient behaviour under specified random-circuit conditions, rather than a universal failure theorem for all ansätze.

Continue through Quantum Mathematics

Guide 13: Hamiltonian Simulation, Trotter–Suzuki Product Formulas and Error Bounds studies dynamical approximation. Guide 15: Quantum Metrology, Fisher Information and Precision Limits develops the estimation questions underneath noisy measurements. Guide 16: Tensor Networks, Matrix Product States and Entanglement Compression presents a complementary classical representation for structured states.

Return to the BTT Mathematics Learning Hub.