FS
Fibonacci Optimizer
Numerical Optimization · Line Search

Frontier line search.
At minimum cost.

Derivative-free 1D interval reduction using consecutive Fibonacci ratios. Minimises the 65-year Mauna Loa atmospheric CO₂ growth rate model in exactly 37 evaluations to \(10^{-8}\) precision.

📄 Download Technical Report (PDF)
Optimal Interval Reduction
1 / FN+1

Proven optimal sequential minimax reduction strategy by J. Kiefer (1953) — guarantees the narrowest interval of uncertainty.

0.016051 / yr
Growth Rate r*
37 evals
vs 100,001 Grid
0.687 ppm
Model RMSE
43.2 years
CO₂ Doubling Time
Doubling Time
43.2
ln(2) / r* years
RMSE & SSE
0.687
SSE = 30.66 ppm²
Function Evals
37
2,700× faster than grid
Fitted Variable-Projection Equation
CO₂(t) = 255.15 + 59.5550 · exp(0.01605 · (year − 1959))
1959 – 2023 NOAA Records N = 65 Years
Optimization Parameters C++ / JS
Minimising SSE(r) via variable projection over bracket [0.005, 0.10].
Comma-separated target forecast years
CSV Data Exports:
Interactive Interval Reduction Visualizer

Step-by-Step Fibonacci Bracket Shrinkage

Step 1 of 36

Observe Kiefer's optimal reduction in real-time. Notice how one interior point is always reused, costing only one evaluation per step!

a
x₁
x₂
b
Initializing bracket [0.00500, 0.10000]...
Atmospheric CO₂: Observed vs Fitted Exponential 1959–2060
Unimodal Objective Function SSE(r) Minimum r* = 0.016051
Algorithm Comparison & Precision Analysis

Evaluations Needed vs. Tolerance

Fibonacci search delivers the exact theoretical minimum sequential evaluations for any prescribed tolerance.

Tolerance (tol) Fibonacci Search (evals) Golden Section (evals) Brute-force Grid (100k steps) Interval Width Reduction Factor Theoretical Efficiency
Climate Projection Horizon

Extrapolated CO₂ Trajectory

Extrapolation of the fitted NOAA model \(CO_2(t) = C_0 + A \cdot e^{r (t - 1959)}\) for future milestone years.

Full Trajectory

Complete Fibonacci Search Iteration Log

Native Engine

C++17 Implementation & Live Binary Execution

Standard C++17 implementation with zero external dependencies. Click below to execute the compiled MinGW binary live!

Compiled with MinGW GCC -O2 -std=c++14
Terminal Stdout Console
Click "Run 'fibonacci_search.exe' Live" to execute the native binary and inspect compiler output.
fibonacci_search.cpp (C++17)
Standard C++17
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iostream>
#include <vector>

using Func = std::function<double(double)>;

struct SearchResult {
    double x;
    double fx;
    double a;
    double b;
    int evals;
    std::vector<std::pair<double, double>> history;
};

std::vector<long long> fibonacciNumbers(int n) {
    std::vector<long long> F(n + 1);
    F[0] = 0;
    if (n >= 1) F[1] = 1;
    for (int i = 2; i <= n; ++i) F[i] = F[i - 1] + F[i - 2];
    return F;
}

SearchResult fibonacciSearch(const Func& f, double a, double b, double tol) {
    const double L0 = b - a;
    int n = 3;
    while (fibonacciNumbers(n)[n] < 2.0 * L0 / tol) ++n;
    const std::vector<long long> F = fibonacciNumbers(n);

    SearchResult res;
    res.history.push_back({a, b});

    int k = n;
    double x1 = a + static_cast<double>(F[k - 2]) / F[k] * (b - a);
    double x2 = a + static_cast<double>(F[k - 1]) / F[k] * (b - a);
    double f1 = f(x1);
    double f2 = f(x2);
    res.evals = 2;

    while (k > 3) {
        if (f1 < f2) {
            b = x2;
            x2 = x1;
            f2 = f1;
            --k;
            x1 = a + static_cast<double>(F[k - 2]) / F[k] * (b - a);
            f1 = f(x1);
        } else {
            a = x1;
            x1 = x2;
            f1 = f2;
            --k;
            x2 = a + static_cast<double>(F[k - 1]) / F[k] * (b - a);
            f2 = f(x2);
        }
        ++res.evals;
        res.history.push_back({a, b});
    }

    res.x = 0.5 * (a + b);
    res.fx = f(res.x);
    ++res.evals;
    res.a = a;
    res.b = b;
    return res;
}