Skip to content
Tutorials Center
My learning

Topics

Lesson 37 of 39 · Projects and Practice

Project: Variational Versus Exact Energies for an Anharmonic Oscillator

Compare a one-parameter variational estimate, second-order perturbation theory and a converged matrix diagonalization for the quartic anharmonic oscillator.

This project brings together the central tools of the course on one problem, the quartic anharmonic oscillator. You will compute its ground-state energy three ways and decide when each method is trustworthy:

  1. Exact numerics by diagonalizing the Hamiltonian in a large harmonic-oscillator basis (the Rayleigh-Ritz method with an orthonormal basis).
  2. A one-parameter variational estimate with a Gaussian trial function.
  3. Rayleigh-Schrödinger perturbation theory to second order in the anharmonic coupling.

The model (in units ħ = m = ω = 1) is

Text
H = p²/2 + x²/2 + λ x⁴,        λ ≥ 0

For λ = 0 it is the harmonic oscillator with E₀ = 1/2. For λ > 0 the quartic term stiffens the well and raises the energy. There is no closed-form solution, but the problem is a standard test bed: perturbation series in λ is known to be asymptotic (it diverges for every λ > 0, although its first few terms are excellent for small λ).

Step 1: the matrix problem

In the basis of harmonic-oscillator eigenstates |n⟩, the position operator is x = (a + a†)/√2, with a|n⟩ = √n |n-1⟩. Then x⁴ = (x²)² has a banded matrix, and H = N + 1/2 + λ x⁴, where N is the number operator. Truncating to n < N_max and diagonalizing gives Ritz upper bounds on the energies; as N_max grows, they converge.

A practical caution. Multiply the matrices of x first at a larger size and truncate afterwards. If you build x already truncated to N_max and then take its fourth power, the last few rows and columns of the result are wrong, because the truncation removed states that x⁴ connects to.

Step 2: the variational estimate

With ψ = e^{-αx²}: ⟨T⟩ = α/2, ⟨x²⟩ = 1/(4α), ⟨x⁴⟩ = 3/(16α²), so

Text
E(α) = α/2 + 1/(8α) + 3λ/(16α²)

Minimize over α. Setting dE/dα = 0 gives 1/2 - 1/(8α²) - 3λ/(8α³) = 0, which is the cubic 4α³ - α - 3λ = 0; the code simply minimizes numerically. A Gaussian is the exact answer for λ = 0 and is a good, but not exact, shape for λ > 0.

Step 3: perturbation theory

Treating λ x⁴ as a perturbation of the harmonic oscillator, the known series for the ground state is

Text
E₀(λ) = 1/2 + (3/4) λ - (21/8) λ² + (333/16) λ³ - …

The coefficients grow factorially, which is why the series is only asymptotic. The code below uses the first three terms and compares.

Python Exact, variational and perturbative ground-state energies

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

When you run the table, note three things. The variational error is positive for every λ, as it must be. Only for very small λ (about 0.01 or below) is second-order perturbation theory more accurate than the one-parameter Gaussian; by λ = 0.05 the Gaussian wins, and for λ ≳ 0.5 perturbation theory fails badly (at λ = 1 it even gives a negative energy). It is not variational, so its error can have either sign. The variational result degrades only slowly as λ increases, because the Gaussian family can adapt its width.

Step 4: convergence with basis size

The matrix result is only as good as the basis. The following run solves the problem at λ = 0.5 with increasing basis sizes and shows the lowest three eigenvalues. By the variational principle (and the Hylleraas-Undheim-MacDonald theorem from the Rayleigh-Ritz lesson) each Ritz value decreases monotonically toward the exact energy from above.

Python Convergence of the matrix method with the basis size

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Extensions to try

  • Extend the variational family to ψ = e^{-αx²}(1 + c x²), and observe the improvement in E₀. A two-function basis {e^{-αx²}, x²e^{-αx²}} turns it into a 2x2 generalized eigenvalue problem for each α.
  • Estimate the first excited state variationally using an odd trial function x e^{-αx²} (odd parity guarantees orthogonality to the ground state).
  • Plot the ground-state energy against λ and fit the large-λ behavior. A scaling argument shows E₀ ∝ λ^{1/3} for large λ, because then the quartic term dominates.
  • Add a cubic term g x³ to see a potential that is unbounded below in the classical sense, and study how the perturbative series then fails.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. For the oscillator H = p²/2 + x²/2 + λx⁴, the Gaussian variational energy E(α) = α/2 + 1/(8α) + 3λ/(16α²) is:

    It is a variational upper bound; it equals the exact answer only at λ = 0, where the Gaussian is the exact ground state.
  2. 2. Why should you multiply matrices before truncating when building x⁴ in a truncated basis?

    (P x P)^4 differs from P x⁴ P since intermediate states above the cutoff are dropped; build x in a larger space, take the power, then truncate.
  3. 3. The perturbation series for the quartic oscillator is asymptotic. This means:

    The coefficients grow factorially, so the series has zero radius of convergence even though truncated partial sums are useful at small λ.
  4. 4. With larger basis size the lowest Ritz eigenvalue:

    A larger basis contains the smaller one, so the minimum of the energy functional cannot rise.

Summary

  • Matrix diagonalization in the harmonic-oscillator basis gives a controllable, converging upper bound for the quartic oscillator.
  • A one-parameter Gaussian variational estimate is cheap, bound-respecting and decent for all λ.
  • Second-order perturbation theory is best at tiny λ and fails at large λ; the series is asymptotic and gives no bounds.
  • Compare methods by their guarantees as well as their accuracy.

Next: Project: Simulating a Bell Test