Daily Chess Puzzle – Train your tactical vision with fresh puzzles. Click any card, think, and then reveal the solution in the post body.

Unconstrained one variable function minimization by Fibonacci search

The Fibonacci Search: An Interactive Masterclass
A close-up of a nautilus shell showing the Fibonacci spiral

The Fibonacci Search: An Interactive Masterclass on Minimization

Discover how nature's most famous number sequence provides an elegant and optimal strategy for finding the lowest point in a valley.

A New Quest: The Hunt for the Minimum

In our previous guides, we were detectives hunting for "zero"—the points where a function crosses the x-axis. But often in science and engineering, we face a different, equally important challenge: finding the function's minimum value. This is the core of optimizationIn math and computer science, optimization is the process of finding the best possible solution from all available options, like finding the lowest point in a valley or the highest point on a hill..

Imagine you are an engineer designing a bridge. You have a function that describes the total cost based on the thickness of a steel beam. Too thin, and you need many expensive supports. Too thick, and the beam itself is expensive. Somewhere in between is a "sweet spot" that minimizes the cost. Or perhaps you're a data scientist tuning an AI model, and you have a function that measures its error. Your goal is to find the model parameter that makes this error as small as possible. You are hunting for the minimum.

This masterclass explores one of the most elegant and efficient methods for this task: the Fibonacci Search Method. It's a clever bracketing technique that, like the Bisection Method, is guaranteed to work, but it uses a surprising tool from nature to close in on the minimum with remarkable speed.


The Key Assumption: Unimodality

The Fibonacci search method is powerful, but it relies on one crucial assumption: the function must be unimodal on our search interval. This is a fancy word for a very simple idea.

A unimodalFrom 'uni' (one) and 'modus' (mode). A unimodal function has only one peak (a maximum) or one valley (a minimum) within a given interval. It doesn't go up and down multiple times. function is one that, within our chosen interval $[a, b]$, has only one valley (a minimum). The function consistently decreases until it hits the minimum, and then consistently increases afterwards. It doesn't have multiple wiggles or hills. This property is vital because it allows us to discard parts of our search interval with confidence, knowing the minimum cannot possibly be in the section we're throwing away.


The Secret Weapon: Nature's Numbering System

What makes this method so special is its use of the famous Fibonacci sequence. You've surely seen it before: you start with 1 and 1, and each subsequent number is the sum of the two preceding ones.

$$ F_0=0, F_1=1, F_2=1, F_3=2, F_4=3, F_5=5, F_6=8, F_7=13, \dots $$

This sequence appears everywhere in nature, from the petals on a flower to the branching of trees. In our case, it provides the mathematically optimal way to place test points within an interval to shrink it as efficiently as possible when we've decided in advance how many times we're willing to check the function.

The core idea is to use ratios of these numbers to place two interior test points, $x_1$ and $x_2$, within our interval $[a, b]$. By comparing the function values $f(x_1)$ and $f(x_2)$, we can eliminate a portion of the interval. The true genius lies in the fact that on the next step, one of our old test points is perfectly positioned to be reused as a new test point, meaning we only need to perform one new function evaluation per iteration. This makes the method incredibly efficient when function evaluations are computationally expensive.


The Fibonacci Search Algorithm in Action

Let's break down the process into clear, repeatable steps.

  1. Step 1: Define the Problem. Choose your function $f(x)$, your initial interval of uncertainty $[a, b]$, and—crucially—the total number of function evaluations, $N$, you're willing to perform.
  2. Step 2: Generate Fibonacci Numbers. You'll need the sequence up to $F_N$.
  3. Step 3: Place Initial Test Points. For the first iteration ($k=1$), calculate two interior points, $x_1$ and $x_2$, using a ratio of Fibonacci numbers. The distance from each endpoint is determined by the ratio $F_{N-k-1}/F_{N-k+1}$ (initially $F_{N-2}/F_N$).
  4. Step 4: Evaluate and Reduce. Compare the function values at the interior points.
    • If $f(x_1) < f(x_2)$, the minimum must be in the left sub-interval. Our new interval becomes $[a, x_2]$, and our old $x_1$ becomes the new $x_1$ for this smaller interval.
    • If $f(x_1) > f(x_2)$, the minimum must be in the right sub-interval. Our new interval becomes $[x_1, b]$, and our old $x_2$ becomes the new $x_2$.
  5. Step 5: Repeat. Continue for $N-1$ iterations. Each time, you'll only need to calculate one new interior point because the other is magically reused from the previous step.

The Fibonacci Search Visualizer

Let's find the minimum of $f(x) = (x-2)^2$ on the interval $[0, 8]$. We'll allow for a total of $N=6$ iterations. Press "Next Iteration" to see how the interval shrinks.

Iter (k)abL_kx1x2f(x1)f(x2)

Convergence Analysis: Optimal and Efficient

Like the Bisection Method, Fibonacci search is a bracketing method and is therefore guaranteed to converge to the minimum. Its real advantage lies in its efficiency.

For a fixed number of function evaluations $N$, the Fibonacci search method is the optimal search strategy. This means it produces the smallest possible final interval of uncertainty compared to any other search method that uses the same number of evaluations. The length of the final interval after $N$ evaluations is precisely:

$$ L_N^* = \frac{L_0}{F_N} $$

The reduction ratio at each step approaches $\frac{1}{\phi} \approx 0.618$, where $\phi$ is the Golden Ratio. This means we are eliminating about 38% of the interval at every step, which is significantly better than other simple search methods.


Solving Numerical Problems: A Step-by-Step Guide

Problem 1: Manual Fibonacci Search Iterations

Question: Perform the first three iterations of the Fibonacci search method to find the minimum of $f(x) = x^2 - 10x + 2$ on the interval $[0, 8]$, assuming a total of $N=6$ evaluations are allowed.

Step 1: Setup
$f(x) = x^2 - 10x + 2$, $[a_1, b_1] = [0, 8]$, $N=6$.
The initial interval length is $L_1 = 8 - 0 = 8$.
We need Fibonacci numbers up to $F_6$: $F_0=0, F_1=1, F_2=1, F_3=2, F_4=3, F_5=5, F_6=8$.

Iteration 1 (k=1):
Calculate the initial distance: $L_1^* = \frac{F_{N-1}}{F_N} L_1 = \frac{F_5}{F_6}(8) = \frac{5}{8}(8) = 5$.
Place the interior points:

  • $x_1 = a_1 + L_1^* = 0 + 5 = 5$ (Note: this is incorrect, the formula is for distance from endpoints, let's use the ratio method)
  • Let's use the reduction ratio: $\rho_k = 1 - \frac{F_{N-k}}{F_{N-k+1}}$. For $k=1$, $\rho_1 = 1 - F_5/F_6 = 1 - 5/8 = 3/8$. The length is reduced to $(1-\rho_1)L_1 = (5/8) * 8 = 5$.
  • A simpler way is $d_1 = \frac{F_{N-1}}{F_N}(b_1-a_1) = \frac{5}{8}(8)=5$. $x_1 = a_1 + d_1 = 5$, $x_2=b_1-d_1 = 3$. This is incorrect. Let's use the standard formula.
  • $d_1 = \frac{F_{N-2}}{F_N}(b_1-a_1) = \frac{3}{8}(8)=3$. $x_1 = a_1 + d_1 = 3$. $x_2 = b_1 - d_1 = 8-3=5$. Correct.
  • $f(x_1) = f(3) = 3^2 - 10(3) + 2 = 9-30+2 = -19$.
  • $f(x_2) = f(5) = 5^2 - 10(5) + 2 = 25-50+2 = -23$.
  • Since $f(5) < f(3)$, the minimum is in the right sub-interval. The new interval is $[a_2, b_2] = [x_1, b_1] = [3, 8]$.

Iteration 2 (k=2):
New interval $[3, 8]$, length $L_2 = 5$. Our old $x_2=5$ is one of our new points. We just need one more.

  • The new interval is $[3, 8]$. The old $x_2=5$ becomes our new $x_2$. Our old $x_1=3$ is the new endpoint $a_2$.
  • $d_2 = \frac{F_{N-3}}{F_N}(b_1-a_1) = \frac{2}{8}(8) = 2$. New $x_1 = a_2+d_2 = 3+2=5$. Wait, this is the same point. The standard algorithm re-evaluates the distance each step based on the *new* interval.
  • Let's restart the calculation correctly. $d_k = b_k - a_k$. $x_1 = b_k - \rho_k d_k$, $x_2 = a_k + \rho_k d_k$ where $\rho_k = F_{N-k-1}/F_{N-k+1}$.
  • Iteration 1: $k=1, N=6$. $\rho_1 = F_4/F_6=3/8$. $d_1 = 8$. $x_1=8- (3/8)*8 = 5$. $x_2 = 0+(3/8)*8=3$. (I had them swapped). $f(3)=-19, f(5)=-23$. $f(x_2)Let's use a simpler formulation from a textbook. $L_k = F_{N-k+1}/F_N * L_0$. $I_1 = F_{N-2}/F_N * L_0$. Let's do this the easy way. $k=1$. Interval $[0,8]$, $N=6$. $L_1=8$. $d_1 = (F_{N-1}/F_N)*L_1 = (5/8)*8 = 5$. $x_1=b_1-d_1 = 8-5=3$. $x_2=a_1+d_1 = 0+5=5$. $f(3) = -19$. $f(5)=-23$. Since $f(3) > f(5)$, we discard the left interval. New interval $[a_2,b_2] = [x_1, b_1] = [3, 8]$. Iteration 2 (k=2): The new interval is $[3, 8]$. Length $L_2 = 5$. $d_2 = (F_{N-2}/F_{N-1})*L_2 = (3/5)*5=3$. The old $x_2=5$ is inside this new interval. The distance from the new left endpoint $a_2=3$ to $x_2=5$ is 2. The distance from the new right endpoint $b_2=8$ to $x_2=5$ is 3. The point at distance 3 is kept. So $x_2$ becomes the new $x_1$. Our new points are $x_1=5$ and $x_2 = a_2+d_2 = 3+3=6$. $f(5)=-23$. $f(6) = 36-60+2 = -22$. Since $f(5) < f(6)$, we discard the right interval. New interval $[a_3, b_3] = [a_2, x_2] = [3, 6]$. Iteration 3 (k=3): The new interval is $[3,6]$. Length $L_3=3$. $d_3=(F_{N-3}/F_{N-2})*L_3 = (2/3)*3=2$. Our old $x_1=5$ is inside this new interval. It's at distance 2 from the left end and 1 from the right end. It becomes our new $x_2$. Our new points are $x_2=5$ and $x_1 = b_3-d_3 = 6-2=4$. $f(4) = 16-40+2=-22$. $f(5)=-23$. Since $f(5) < f(4)$, we discard the left interval. New interval $[a_4,b_4] = [x_1,b_3] = [4,6]$. Result: After 3 iterations, the interval is $[4,6]$. The true minimum is at $x=5$.


Test Your Intuition!

Fibonacci Search Quiz

No comments

No comments yet. Be the first!

Post a Comment

Search This Blog

Explore More Topics

Loading topics…