Skip to main content

Golden-Section Calculator

The Bisection Calculator closes in on a root by reading a sign: f is negative on one side, positive on the other, and the midpoint tells you which half to keep. A minimum offers no such sign — the curve comes down to the floor and goes back up, positive the whole way. Golden-section search is bisection's counterpart for valleys: keep two interior probes, each 0.618 of the window in from an end, and compare them. On a single valley the higher probe rules out the whole stretch beyond it, so one end drops for certain; and because 0.618 is the golden ratio's complement, the surviving probe already sits exactly where the next pair needs it — every iteration costs one fresh evaluation and shrinks the bracket ×0.618.

Type an expression in x and it is minimized as-is. Type a full equation f(x) = g(x) and it is solved as least squares — minimizing the squared gap (f − g)², whose floor sits where the sides meet. That is the shape of the goal · regular engine's λ₃ fit: a miss to minimize, not a sign to read — and that page's step 4 emits a paste for this calculator, the same expression its bisection paste uses, walked down as the valley it is. Every probe pair is narrated below, exactly like the fit's own trace.

Seeded with the same Poisson-tail equation the Bisection page opens with: Ptail(2.50, x) = 0.47854397. Read as least squares it converges to the same λ ≈ 2.587961 — two searches, one answer.

The honest caveat: golden-section's guarantee needs one valley in the bracket. With two (the cos chip) the comparisons walk into one of them and never see the other — so the calculator first scans the bracket and counts the dips, and warns when the closed valley is not the deepest one it saw. A floor that slides to the bracket's edge (a monotone stretch) is flagged too.

/ steps a bracket bound, Shift steps bigger.

Golden-section facts
f unimodal on [a, b] (one valley) ⇒ the higher of two interior probes rules out the end beyond it — no sign, no derivative
Probes sit 0.618 of the width from each end, so the survivor lands exactly where the next pair needs it: one fresh evaluation per step, width ×0.618
Comparisons to a tolerance τ: ⌈ln(τ/(b − a))/ln 0.618⌉ — here ⌈ln(1e-6/8)/ln 0.618⌉ = 34
Inputs
Objectivef(x) or f(x) = g(x)
an equation — a minimum has no sign to bisect, so it is solved as least squares: minimizing (Ptail(2.5, x) - 0.47854397)², whose floor sits where the two sides meet
+ − × ÷ ^ ( ) · juxtaposition (2x) · x, pi, e, tau · sin cos tan asin acos atan sinh cosh tanh exp ln log log2 sqrt cbrt abs floor ceil round sign min max pow atan2 · P Pcdf Ptail malay prob fact choose
Tryexamples
Bracket starta
Left end of the bracket the minimum is assumed to sit in.
|a| ≤ 10¹² and a < b
Bracket endb
Right end of the bracket.
|b| ≤ 10¹² and b > a
Toleranceτ
Stop once the bracket is this narrow — the engine's λ₃ fit stops at 1e-6.
The minimum
x*minimum — closed from [0, 8] in 34 comparisons, 36 evaluations (the setup pair + one per step)f(x*) = 2.926e-18 — the best probe SEEN ships, not the final midpoint (ties with the odds engine's λ₃ fit)2.5879612
Scan the bracket — 97 samples counting valleys
·sampled 97 points, one every 0.0833333, across [0, 8]a sample sitting at/below both neighbours marks a valley — dips narrower than one spacing can hide1 dip
1dip 1 near x ≈ 2.58333f ≈ 1.359e-6 therethe valley
The probe pairs, narrated
0start: bracket [0, 8], width 8.000000 — place two probes 0.618 of the width in from each endc = 3.0557281 and d = 4.9442719 (a mirror pair: c + d = a + b); f(c) = 0.012240, f(d) = 0.1536882 evaluations
1window [0.0000000, 8.0000000] → compare f(3.0557281) = 0.012240 with f(4.9442719) = 0.153688f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 1.8885438 (f = 0.034357)◀ keep the left part
2window [0.0000000, 4.9442719] → compare f(1.8885438) = 0.034357 with f(3.0557281) = 0.012240f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 3.7770876 (f = 0.061921)keep the right part ▶
3window [1.8885438, 4.9442719] → compare f(3.0557281) = 0.012240 with f(3.7770876) = 0.061921f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.6099034 (f = 3.036e-5)◀ keep the left part
4window [1.8885438, 3.7770876] → compare f(2.6099034) = 3.036e-5 with f(3.0557281) = 0.012240f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.3343685 (f = 0.004289)◀ keep the left part
5window [1.8885438, 3.0557281] → compare f(2.3343685) = 0.004289 with f(2.6099034) = 3.036e-5f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.7801933 (f = 0.002234)keep the right part ▶
6window [2.3343685, 3.0557281] → compare f(2.6099034) = 3.036e-5 with f(2.7801933) = 0.002234f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5046584 (f = 0.000448)◀ keep the left part
7window [2.3343685, 2.7801933] → compare f(2.5046584) = 0.000448 with f(2.6099034) = 3.036e-5f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.6749483 (f = 0.000470)keep the right part ▶
8window [2.5046584, 2.7801933] → compare f(2.6099034) = 3.036e-5 with f(2.6749483) = 0.000470f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5697034 (f = 2.121e-5)◀ keep the left part
9window [2.5046584, 2.6749483] → compare f(2.5697034) = 2.121e-5 with f(2.6099034) = 3.036e-5f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5448584 (f = 0.000119)◀ keep the left part
10window [2.5046584, 2.6099034] → compare f(2.5448584) = 0.000119 with f(2.5697034) = 2.121e-5f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5850584 (f = 5.343e-7)keep the right part ▶
11window [2.5448584, 2.6099034] → compare f(2.5697034) = 2.121e-5 with f(2.5850584) = 5.343e-7f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5945483 (f = 2.746e-6)keep the right part ▶
12window [2.5697034, 2.6099034] → compare f(2.5850584) = 5.343e-7 with f(2.5945483) = 2.746e-6f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5791933 (f = 4.881e-6)◀ keep the left part
13window [2.5697034, 2.5945483] → compare f(2.5791933) = 4.881e-6 with f(2.5850584) = 5.343e-7f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5886832 (f = 3.303e-8)keep the right part ▶
14window [2.5791933, 2.5945483] → compare f(2.5850584) = 5.343e-7 with f(2.5886832) = 3.303e-8f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5909235 (f = 5.557e-7)keep the right part ▶
15window [2.5850584, 2.5945483] → compare f(2.5886832) = 3.303e-8 with f(2.5909235) = 5.557e-7f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5872987 (f = 2.782e-8)◀ keep the left part
16window [2.5850584, 2.5909235] → compare f(2.5872987) = 2.782e-8 with f(2.5886832) = 3.303e-8f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5864430 (f = 1.461e-7)◀ keep the left part
17window [2.5850584, 2.5886832] → compare f(2.5864430) = 1.461e-7 with f(2.5872987) = 2.782e-8f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5878275 (f = 1.132e-9)keep the right part ▶
18window [2.5864430, 2.5886832] → compare f(2.5872987) = 2.782e-8 with f(2.5878275) = 1.132e-9f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5881544 (f = 2.365e-9)keep the right part ▶
19window [2.5872987, 2.5886832] → compare f(2.5878275) = 1.132e-9 with f(2.5881544) = 2.365e-9f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5876255 (f = 7.142e-9)◀ keep the left part
20window [2.5872987, 2.5881544] → compare f(2.5876255) = 7.142e-9 with f(2.5878275) = 1.132e-9f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5879524 (f = 4.944e-12)keep the right part ▶
21window [2.5876255, 2.5881544] → compare f(2.5878275) = 1.132e-9 with f(2.5879524) = 4.944e-12f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5880295 (f = 2.958e-10)keep the right part ▶
22window [2.5878275, 2.5881544] → compare f(2.5879524) = 4.944e-12 with f(2.5880295) = 2.958e-10f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5879047 (f = 2.024e-10)◀ keep the left part
23window [2.5878275, 2.5880295] → compare f(2.5879047) = 2.024e-10 with f(2.5879524) = 4.944e-12f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5879819 (f = 2.700e-11)keep the right part ▶
24window [2.5879047, 2.5880295] → compare f(2.5879524) = 4.944e-12 with f(2.5879819) = 2.700e-11f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5879342 (f = 4.636e-11)◀ keep the left part
25window [2.5879047, 2.5879819] → compare f(2.5879342) = 4.636e-11 with f(2.5879524) = 4.944e-12f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5879636 (f = 3.726e-13)keep the right part ▶
26window [2.5879342, 2.5879819] → compare f(2.5879524) = 4.944e-12 with f(2.5879636) = 3.726e-13f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5879706 (f = 5.578e-12)keep the right part ▶
27window [2.5879524, 2.5879819] → compare f(2.5879636) = 3.726e-13 with f(2.5879706) = 5.578e-12f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5879593 (f = 2.229e-13)◀ keep the left part
28window [2.5879524, 2.5879706] → compare f(2.5879593) = 2.229e-13 with f(2.5879636) = 3.726e-13f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5879567 (f = 1.302e-12)◀ keep the left part
29window [2.5879524, 2.5879636] → compare f(2.5879567) = 1.302e-12 with f(2.5879593) = 2.229e-13f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5879610 (f = 3.435e-15)keep the right part ▶
30window [2.5879567, 2.5879636] → compare f(2.5879593) = 2.229e-13 with f(2.5879610) = 3.435e-15f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5879620 (f = 3.878e-14)keep the right part ▶
31window [2.5879593, 2.5879636] → compare f(2.5879610) = 3.435e-15 with f(2.5879620) = 3.878e-14f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5879604 (f = 4.689e-14)◀ keep the left part
32window [2.5879593, 2.5879620] → compare f(2.5879604) = 4.689e-14 with f(2.5879610) = 3.435e-15f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5879614 (f = 1.520e-15)keep the right part ▶
33window [2.5879604, 2.5879620] → compare f(2.5879610) = 3.435e-15 with f(2.5879614) = 1.520e-15f(c) > f(d): the floor cannot sit before c — drop [a, c); d is reused as the new c, one fresh probe at 2.5879616 (f = 9.864e-15)keep the right part ▶
34window [2.5879610, 2.5879620] → compare f(2.5879614) = 1.520e-15 with f(2.5879616) = 9.864e-15f(c) ≤ f(d): on one valley the floor cannot sit past d — drop (d, b]; c is reused as the new d, one fresh probe at 2.5879612 (f = 2.926e-18)◀ keep the left part
window [2.5879610, 2.5879616] is 6.27e-7 wide — inside the 1e-6 toleranceship the best probe seen anywhere: x* = 2.5879612, f(x*) = 2.926e-182.5879612