Algorithm Search⌘K

Proofs: Golden-section search

These are the human proofs of Golden-section search, at full length.

Golden-section search keeps the minimum in its interval and reuses one point per step full

This proof shows: correctness.

We use the pseudocode of the page, with ρ=(5−1)/2\rho = (\sqrt5 - 1)/2. The number ρ\rho is the positive root of ρ2+ρ−1=0\rho^2 + \rho - 1 = 0, so ρ2=1−ρ\rho^2 = 1 - \rho and 1/2<ρ<11/2 < \rho < 1. Let ff be strictly unimodal for a minimum on [a0,b0][a_0, b_0] with mode mm: strictly decreasing on the points ≤m\le m and strictly increasing on the points ≥m\ge m. The comparison lemma for a minimum reads, for x1<x2x_1 < x_2: f(x1)<f(x2)f(x_1) < f(x_2) implies m<x2m < x_2; f(x1)>f(x2)f(x_1) > f(x_2) implies m>x1m > x_1; f(x1)=f(x2)f(x_1) = f(x_2) implies x1<m<x2x_1 < m < x_2. Its proof is the one for a maximum with ff replaced by −f-f.

Claim. GOLDEN-MIN(f,a0,b0,steps)(f, a_0, b_0, steps) evaluates ff exactly steps+2steps + 2 times. Before line L8, m∈[a,b]m \in [a, b] and, in exact arithmetic, b−a=ρsteps(b0−a0)b - a = \rho^{steps}(b_0 - a_0). The returned point is within 12ρsteps+1(b0−a0)\tfrac12 \rho^{steps + 1}(b_0 - a_0) of mm.

Invariant. Before each test of line L5, with L=b−aL = b - a:

  1. m∈[a,b]m \in [a, b];
  2. c=a+ρ2Lc = a + \rho^2 L and d=a+ρLd = a + \rho L, so a<c<d<ba < c < d < b;
  3. fc=f(c)fc = f(c) and fd=f(d)fd = f(d).

Initialization. Line L2 sets c=b−ρL=a+(1−ρ)L=a+ρ2Lc = b - \rho L = a + (1 - \rho)L = a + \rho^2 L and d=a+ρLd = a + \rho L. Since ρ2<ρ<1\rho^2 < \rho < 1, the order a<c<d<ba < c < d < b holds. Line L3 sets the values. Item 1 holds by the assumption on ff.

Maintenance, case fc<fdfc < fd (line L6). By the lemma, m<dm < d, so m∈[a,d]m \in [a, d], the new interval. Its left end is a′=aa' = a and its length is L′=d−a=ρLL' = d - a = \rho L. The new dd is the old c=a+ρ2L=a′+ρL′c = a + \rho^2 L = a' + \rho L', the correct inner point, and its value is the old fcfc. The new cc is computed as b′−ρL′=a′+(1−ρ)L′=a′+ρ2L′b' - \rho L' = a' + (1 - \rho) L' = a' + \rho^2 L', and ff is evaluated there once.

Maintenance, case fc≥fdfc \ge fd (line L7). If fc>fdfc > fd, the lemma gives m>cm > c; if fc=fdfc = fd, it gives c<m<dc < m < d. In both cases m∈[c,b]m \in [c, b], the new interval. Its left end is a′=c=a+ρ2La' = c = a + \rho^2 L and its length is L′=b−c=(1−ρ2)L=ρLL' = b - c = (1 - \rho^2) L = \rho L. From ρ2+ρ=1\rho^2 + \rho = 1 we get ρ(1+ρ)=1\rho(1 + \rho) = 1, so a′+ρ2L′=a+ρ2L(1+ρ)=a+ρLa' + \rho^2 L' = a + \rho^2 L (1 + \rho) = a + \rho L, which is the old dd. So the old dd is the correct new cc, with value fdfd. The new dd is computed as a′+ρL′a' + \rho L', and ff is evaluated there once.

In both cases the invariant holds again with L′=ρLL' = \rho L.

Termination and result. The loop runs stepssteps times, with one evaluation each, after the two of line L3: steps+2steps + 2 evaluations. Before line L8, b−a=ρsteps(b0−a0)b - a = \rho^{steps}(b_0 - a_0) and m∈[a,b]m \in [a, b]. Line L8 applies the same case analysis once more without a new evaluation: m∈[a,d]m \in [a, d] or m∈[c,b]m \in [c, b], both of length ρ(b−a)\rho(b - a). The midpoint of an interval of length ρsteps+1(b0−a0)\rho^{steps + 1}(b_0 - a_0) that holds mm is within half that length of mm. □\square

Remark on floating point. Items 2 and 3 hold only up to rounding, because the reused point keeps its old computed value. The proof of item 1 uses only that fcfc and fdfd are the values at two points c<dc < d of [a,b][a, b] and that the new interval is [a,d][a, d] or [c,b][c, b]. So the minimum stays in the interval in floating point as long as the computed points keep the order a≤c<d≤ba \le c < d \le b, which holds until the interval holds only a few doubles. Rounding affects the length bound, not the bracket.

Why the ratio must be ρ\rho. Suppose a method uses inner points at the fractions 1−t1 - t and tt of each interval, with 1/2<t<11/2 < t < 1, and wants the kept inner point to be an inner point of the next interval. After keeping [a,d][a, d], the new length is tLtL and the old cc sits at (1−t)L(1 - t)L from aa. For it to be at the fraction tt of the new interval we need (1−t)L=t⋅tL(1 - t)L = t \cdot tL, that is t2+t−1=0t^2 + t - 1 = 0, so t=ρt = \rho.

Back to Golden-section search