Why the Method of Lagrange Multipliers Works

— From constrained extrema to the secular equation and the covalent bond (Computational Materials Science, Lecture 11)

“Minimize something while satisfying a condition.” Physics is full of problems of this form. Minimize the energy for a given number of electrons, maximize the entropy for a given energy, minimize the action over a given time. The tool for solving these is the method of Lagrange multipliers. Here we first build an intuition, with a picture, for “why that procedure works,” and then apply it to the energy expectation value of a molecule AB to derive the secular equation.

The conclusion first At a constrained extremum, a contour line of the objective function just touches the constraint curve. “Touching” means “the two gradients are parallel,” and the constant of proportionality is the Lagrange multiplier. And this Lagrange multiplier is not just a computational device — in the molecular-orbital problem, it becomes a physical quantity in its own right: half of the energy level (E = 2ε).

1. Seeing It in a Picture — Why Do They “Touch”?

Suppose we want to minimize a function f(x, y) of two variables under the condition g(x, y) = 0. Since g = 0 is a single curve in the plane, this is the problem of walking only along that curve and looking for the lowest point.

If f is still changing as we walk along the curve, there is still room to go lower. We can go no lower when f stops changing as we move along the curve. Denoting the direction along the curve by t, this means

(1) ∇f·t=0

However, since g remains 0 even as we walk along the constraint curve, ∇g·t=0 also always holds. Thus both ∇f and ∇g are perpendicular to t. In two dimensions, the only vectors perpendicular to the same direction are parallel ones (this assumes ∇g ≠ 0, that is, that the constraint curve is smooth at that point and does not degenerate there). Therefore

(2) ∇f=λ∇g

This λ is the Lagrange multiplier, also called the “undetermined multiplier.” It is “undetermined” because its value is not known from the start — it is a quantity that is fixed only once the problem has been solved.

Fig. 1. Where the contour lines touch the constraint curve. The background color shows the value of f (the bluer, the smaller; the redder, the larger), the thin lines on top are contour lines, and the thick green line is the constraint g = 0. If you move the red point along the curve with the slider, the two arrows become parallel the moment the contour touches the curve, and that is the point where f is stationary along the curve — a candidate for the minimum (or maximum).

2. The Third Equation Brings the Constraint Back

Eq. (2) consists of two equations, but there are three unknowns: x, y, and λ. One equation is missing. The missing one is the constraint itself, g = 0. The device that produces all three of these automatically is the following function.

(3) F(x,y,λ) =f(x,y) −λ g(x,y) ∂F∂x= ∂F∂y= ∂F∂λ=0
Here is the trick ∂F/∂λ= −g=0 — differentiating with respect to λ brings back the constraint itself. So the “constrained problem in two variables” can be replaced wholesale by an “unconstrained problem in three variables.” That is all there is to the method of Lagrange multipliers. The simple idea of treating λ as “one more variable” is what makes it work.
The sign is a matter of taste Many textbooks write F=f+λg instead. Only the sign of λ changes; the answer is the same. The lecture notes use the form F=E−ε( ⟨Ψ|Ψ⟩−2) with the constraint term subtracted, so we follow that convention below.

3. Example — Minimizing the Energy of a Molecule AB

Now we come to the main subject. Mixing the atomic orbitals ψA, ψB of atoms A and B, we build a molecular orbital (the LCAO approximation).

(4) Ψ=cAψA +cBψB

What we want to determine is just two coefficients. The criterion is “make the energy as low as possible” — the variational principle. We need three kinds of integrals.

SymbolDefinitionMeaning
S ∭ψA*ψBdV Overlap integral. How much the two orbitals overlap in space (0 ≤ S ≤ 1)
αA, αB ∭ψA*H^ψAdV etc. Coulomb integral. A quantity corresponding to the electronic level of the atom before bonding (negative). H^ also includes the attraction from the other atom’s nucleus
β ∭ψA*H^ψBdV Resonance integral. The effect of the electron going back and forth between A and B (usually negative)

If the coefficients are real (cA=cA*), the expansion takes only a moment.

(5) ⟨Ψ|H^|Ψ⟩ =cA2αA +cB2αB +2cAcBβ
(6) ⟨Ψ|Ψ⟩ =cA2 +cB2 +2cAcBS =2
Why “= 2”? It is because two electrons occupy the bonding orbital. We normalize Ψ to the “density of two electrons.” Therefore E=⟨Ψ|H^|Ψ⟩ /⟨Ψ|Ψ⟩ is the energy per electron — that is, the level of the molecular orbital — and the total for two electrons is twice that.
And using (6), the division disappears, and we obtain E=12 (cA2αA +cB2αB +2cAcBβ) — a plain quadratic expression.

4. Applying the Method of Lagrange Multipliers

(7) F=E−ε (⟨Ψ|Ψ⟩−2) =12 (cA2αA +cB2αB +2cAcBβ) −ε(cA2 +cB2 +2cAcBS −2)

We set the three partial derivatives equal to 0.

(8) ∂F∂cA =cAαA +cBβ −ε(2cA +2cBS)=0
(9) ∂F∂cB =cBαB +cAβ −ε(2cB +2cAS)=0
(10) ∂F∂ε =− (cA2 +cB2 +2cAcBS −2)=0 (the constraint itself)

Collecting Eqs. (8) and (9) in terms of cA, cB and writing them in matrix form, we get

(11) [ αA−2ε β−2εS β−2εS αB−2ε ] [ cA cB ] = [00]

5. The Secular Equation — Why Do We Set the Determinant to 0?

Eq. (11) always has the solution cA=cB=0. But that does not satisfy the constraint (6), ⟨Ψ|Ψ⟩=2 — Ψ would vanish, and there would be no electrons anywhere. What we want is a “nontrivial solution.”

If an inverse matrix exists, only the trivial solution remains If the matrix M had an inverse, multiplying both sides of Mc = 0 by M−1 would force c = 0. So there must be no inverse matrix. The condition for having no inverse is det M = 0 — this is the secular equation.

Geometrically: Eqs. (8) and (9) are each a straight line through the origin. Two lines usually meet only at the origin. The moment the determinant becomes 0, the two lines coincide into one, and the intersection turns into “an entire line.” Only then do solutions other than the origin arise.
(12) | αA−2ε β−2εS β−2εS αB−2ε |=0

Expanding it gives a quadratic equation in ε.

(13) 4(1−S2)ε2 +(4βS−2αA −2αB)ε +(αAαB −β2)=0
(14) ε= 14(1−S2) [αA+αB −2βS± (αA+αB−2βS)2 −4(1−S2) (αAαB−β2)]
This is a generalized eigenvalue problem Eq. (11) can be written as Hc = 2ε Sc (H is the Hamiltonian matrix and S is the overlap matrix). If we line up n atomic orbitals, it becomes n×n and yields n molecular orbitals. This is exactly the equation that first-principles calculation programs actually solve.

6. The Hydrogen Molecule — Bonding and Antibonding

For identical atoms, αA=αB=α. The expression under the square root in Eq. (14) is (2α−2βS)2 −4(1−S2) (α2−β2) =(2αS−2β)2 — a neat perfect square — and therefore

(15) εb= α+β2(1+S) εa= α−β2(1−S)

We find the coefficients by going back to the first row of Eq. (11) (the first row can be factored by Sα−β, so we assume Sα≠β, that is, that the two roots do not coincide). For ε=εb we get cA−cB=0, and for ε=εa we get cA+cB=0. Fixing their magnitude with the constraint (6) gives

(16) Ψb= 11+S (ψA+ψB) Ψa= 11−S (ψA−ψB)
What the multiplier ε really is Here we have E=2ε. In other words, ε turned out to be (half of) the energy level of the molecular orbital itself. The auxiliary variable we introduced as “the strength of the constraint” was a physical quantity all along. The generalized forces (constraint forces) of analytical mechanics and the chemical potential of thermodynamics have exactly the same structure.

Fig. 2. Roots of the secular equation and the energy levels. On the left is the graph of the determinant D(ε); the two points where it crosses 0 are the roots. On the right is the level diagram determined from them. Moving αA and αB apart takes the bond from covalent toward ionic, and you can watch the covalent character fall. Note, however, that the read-out “stabilization energy” is measured relative to two neutral atoms (αA + αB), so its absolute value actually grows as the level difference is widened — please keep the choice of reference in mind.

7. What the Gap Formula Tells Us

We compute the separation between the bonding and antibonding levels. Taking the difference of the two roots in (15) gives

(17) Δε=εa−εb =Sα−β1−S2 ⟶S→0 −β
Difference from the lecture slides (one place) On slide 14, the formula reads Δε=( −β+Sα) /2(1−S2) — but if the common denominator is carried through to the end, the 2 in the denominator cancels and, as in (17), the denominator is 1−S2. (Because the denominator is halved, the value of Δε is twice that of the slide.)
Checking numerically: for α = −13.6, β = −9, and S = 0.5, εa − εb = −4.600 − (−7.533) = 2.933; the value of (17) is also 2.933, whereas the slide’s formula gives 1.467.
On slide 16, the formula Δε=((αA−αB)/2)2+β2 and the relation Δεc = −β are consistent with (17), so the conclusions stand as they are.

Three things can be read from this.

  1. The larger |β| is, the wider the gap. Since β is the effect of the electron going back and forth, A ↔ B, the closer the atoms come and the better the orbitals overlap, the stronger the bond becomes.
  2. Core electrons usually cannot be used for bonding. The deeper the level, the more strongly the orbital is bound to the nucleus and the less it spreads, so both S and β approach 0. The gap then becomes nearly 0, and electrons enter both the bonding and the antibonding orbitals, so the energy lowered and the energy raised cancel each other out — there is no gain.
  3. The level difference is the ionic contribution. Setting S = 0 in (14) gives Δε=( αA−αB2 )2+β2. It has the form of the hypotenuse of a right triangle (Δε is the difference of the roots εa − εb, so the “gap 2εa − 2εb” read out in Fig. 2 is twice this).
Covalent and ionic character do not “add up to 100 %” Let Δεc=−β (the covalent contribution) and Δεi=|αA−αB|/2 (the ionic contribution). Then Δε2=Δεc2+Δεi2 (for S = 0). The covalent character Δεc/Δε and the ionic character Δεi/Δε are such that their squares add up to 1. So there is no contradiction when the readout shows “covalent 71 %, ionic 71 %” (both are 1/√2, the exactly half-and-half case).
How the covalent gain shrinks as the level difference widens Writing the lower root of (14) for S = 0, we have 2εb=12[αA+αB−(αA−αB)2+4β2] — and when the level difference is large compared with |β|, expanding the square root, with the level of the deeper atom (here B) as the reference, gives 2εb≒αB−β2|αA−αB| — that is, the energy falls by only 2β2/|αA−αB| for the two electrons together. The wider the level difference, the less there is to gain from resonance; the statement in the next section, §8, that “a 100 % ionic bond has no covalent gain,” is where this trend ends up.
(The “stabilization energy” read out in Fig. 2 is measured from two neutral atoms, so its reference differs from the “deeper level as the reference” used here.)

8. Why Is There No Covalent Gain in a 100 % Ionic Bond?

Let us try the state in which all the electrons have gone to B. The choice cA=0, cB=2 satisfies the constraint (6). In that case

(18) E=12 (0+2αB+0) =αB
In this model, it is exactly the same as the level of an isolated atom B Since the β term is multiplied by cAcB, the moment one of the coefficients becomes 0, the effect of the resonance integral disappears entirely. The stabilization due to resonance is zero — in this two-orbital model, a 100 % ionic bond has no covalent gain.
However, what makes a real ionic bond such as NaCl stable is mainly the electrostatic attraction between the ions (in a crystal, the Madelung energy), and that contribution is not included in this model. All we can say here is that “the gain from the resonance integral vanishes.”

Put the other way around — the very fact that “we cannot tell which atom the electron came from” is the energy source of the bond. To borrow a phrase from the lecture notes, a particle is most stable when it is playing “hide-and-seek.”

9. Checking Numerically

We checked the equations above using the very code contained in the simulator (35 items, all passed).

What was checkedResult
(14): Do the solutions of the quadratic equation coincide with the roots of the determinant (12)? |D(ε)| < 8×10−15
(15): Does it agree with the closed form (α±β)/2(1±S) for identical atoms? relative difference < 10−12
(2): At the solution point, are ∇(½⟨Ψ|H|Ψ⟩) and ∇⟨Ψ|Ψ⟩ parallel? (cross product = 0) |∇F| < 2×10−14, cross product < 5×10−14
(6): Does the solution satisfy the constraint ⟨Ψ|Ψ⟩ = 2, and is E = 2ε? relative difference < 10−10
(16): Are the coefficients 1/√(1±S)? relative difference < 10−10
Does the minimum point found numerically on the ellipse (2000 points + ternary search) agree with the analytical solution? (4 cases) Agreement to within 10−8 in both position and energy
(18): Does cA = 0, cB = √2 give E = αB? Exact agreement (the true minimum is a further 0.26 eV lower)
(17): Δε = (Sα−β)/(1−S²) (the formula on slide 14 is off by a factor of 2) Measured 2.9333 = the value of (17)
Do the covalent and ionic characters satisfy √(Δε_c² + Δε_i²) = Δε (S = 0, Δε = ε_a − ε_b)? relative difference < 10−12
Inversion of S(R) = e−R(1+R+R²/3) (to obtain the internuclear distance used in the wave-function picture) Round-trip error < 2×10−16, S = 0.7529 → R = 1.400 a₀
If β > Sα, does the lower solution switch to ψA − ψB (the antibonding form)? Confirmed that it switches (β = −2, Sα = −6.8 eV)

10. Summary

  1. At a constrained extremum, a contour line of the objective function touches the constraint curve. Touching = parallel gradients = ∇f=λ∇g (2).
  2. If we set F=f−λg, the condition ∂F/∂λ=0 automatically brings back the constraint. This is all there is to the method of Lagrange multipliers (3).
  3. Applied to the molecular orbital, it gives simultaneous equations for the two coefficients (11).
  4. Because we need a nontrivial solution, the inverse matrix must not exist ⇒ determinant = 0 ⇒ secular equation (12).
  5. There are two roots. In the usual case of β<Sα, the lower one is the bonding orbital and the higher one is the antibonding orbital (15), (16). (If β>Sα, the lower solution switches to the form ψA − ψB — see the last row of §9.)
  6. The Lagrange multiplier ε was half of the energy level of the molecular orbital (E = 2ε).
  7. The gap is the hypotenuse of the right triangle whose legs are the covalent contribution (−β) and the ionic contribution (|αA−αB|/2) (the form obtained from (14) with S = 0). The moment one of the coefficients becomes 0, the effect of β disappears, so a 100 % ionic bond has no covalent gain (18).

Mochizuki Research Group, Tokyo University of Science | From Lecture 11, “The Secular Equation and the Covalent Bond,” of the course “Computational Materials Science.” The general discussion in §1 and §2 and the organization of the gap results in §7 are additions that go beyond the lecture slides. The numerical verification used direct double-precision calculation, a ternary search on the ellipse, and bisection for the 1s overlap integral. To check with graphs, go to the simulator. The equations are typeset with the browser’s standard MathML (there are no external libraries and no network communication at all).