← Math
Math

Linear, exponential, and logarithmic growth

How long until every node has the change?

Identify what adds, what multiplies and when a capacity limit changes the growth rule.

Outcome

Tell linear from exponential growth, count multiplying rounds as a logarithm rounded up, and estimate the linear tail a cap creates.

Terminology (6)Terms used in this lesson

Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.

Linear growth
Adding the same amount each step. After r steps the total has grown by r times that amount.
Exponential growth
Multiplying by the same factor each step. After r steps the total has been multiplied by the factor to the power r.
Logarithmic growth
The number of multiplying steps needed to reach a size grows like the logarithm of that size: doubling the size adds one step.
Fan-out Also branching factor
How many others each participant contacts per round. With fan-out f the informed count multiplies by f + 1.
Concurrency limit
A cap on how much work can happen in one step. It turns the exponential phase of a process into a linear tail.
Doubling time
How long a quantity growing at a steady rate takes to double: ln 2 divided by ln(1 + rate), about 70 divided by the percentage rate.

Why this matters

Rollouts, gossip protocols, cache warm-up, retries and user growth all multiply. Search trees and binary search shrink by a factor. Estimating them as if they added a fixed amount per step is off by orders of magnitude, and a limit somewhere in the system can turn a fast multiplying process into a slower linear tail. This broadcast is an ideal planning model: real gossip may contact nodes that already know the change or lose deliveries, so it can take longer.

This lesson assumes logarithms and powers of two from earlier lessons.

How growth rules determine the estimate

Linear growth adds a fixed amount each step. Exponential growth multiplies the current amount by a fixed factor. A logarithm reverses that multiplication: it asks how many factors are needed to reach a target. Counting complete rounds then requires a whole-number boundary decision.

A delivery cap can change the rule during the process. Before it binds, the informed population determines how much can be sent; afterward, the cap determines the new deliveries per round. Estimate those successive phases using the stated ideal model, including its distinct recipients and successful sends.

01Repeated doubling

Repeated doubling

A configuration controller plans a broadcast through a 20,000-node fleet. Its model assigns each informed node three distinct uninformed peers per round, with no failed or duplicate sends. A fleet-wide cap of 1,000 new deliveries per round changes the completion estimate. Work out where multiplying gives way to adding.

If the informed count doubles each round, after r rounds it is 2^r. The rounds needed to reach n are the smallest r with 2^r ≥ n, which is log₂ n rounded up. Predict the three lines this program prints.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const nodes = 2 ** 49 + 1; // just past a power of two

console.log(Math.ceil(Math.log2(20_000))); // doubling to a 20,000-node fleet
console.log(Math.ceil(Math.log2(nodes))); // the same formula, far larger

let rounds = 0;

for (let count = 1; count < nodes; count *= 2) rounds++;

console.log(rounds); // counting with integers
Which line is wrong?

Math.log2 returns a double. Numbers are exact integers up to 2⁵³, but log2 of 2⁴⁹ + 1 is closer to 49 than to any other double, so it returns 49. Count with integers, or use the length of n − 1 in binary.

02Multiply by 1 + f

Multiply by 1 + f

With fan-out 3, each informed node tells 3 new nodes and stays informed itself, so the count multiplies by 4 each round. The rounds to reach n are log₄ n rounded up.

How many rounds for 20,000 nodes with fan-out 3?

Computing log₄ n as Math.log(n) / Math.log(4) can land a hair above an integer for an exact power and round up one round too many. Multiplying an integer counter until it reaches n takes at most a few dozen steps and is exact.

03A cap makes a linear tail

A cap makes a linear tail

Now the network accepts at most 1,000 new connections per round. The count still multiplies by 4 while the informed nodes would add fewer than 1,000.

Informed nodes per round, fan-out 3, cap 1,000
RoundAddedInformed
0—1
57681,024
61,000 (3,072 asked)2,024
71,0003,024
24976 (last nodes)20,000
Why does the cap set the delivery limit for each full round after round 5?

04Compute the tail

Compute the tail

After round 5, 1,024 nodes are informed and 18,976 remain. At 1,000 per round they take ⌈18,976 / 1,000⌉ = 19 rounds, so the broadcast takes 24 rounds instead of 8. A loop that simulates every round works for this case, but with a cap of 1 and 10¹⁵ nodes it would run 10¹⁵ times. Multiply while the cap does not bind, then divide once.

Taking the larger of the two estimates, 8 rounds uncapped or ⌈(n − 1) / 1,000⌉ = 20 rounds fully linear, gives 20. The exponential phase and the linear tail happen one after the other, so their rounds add.

05Growth rates and doubling time

Growth rates and doubling time

Binary search over 10⁶ sorted keys needs at most how many comparisons?

06Estimate the broadcast

Estimate the broadcast

The controller first needs the least whole number of doubling rounds, including a target just beyond a large power. Its assigned fan-out then changes the multiplication factor to 1 + f. The global delivery cap introduces a second phase: compute when it binds, then count the remaining full or partial rounds without simulating a potentially enormous tail.

A cluster broadcast

Count doubling rounds, count fan-out rounds, then respect the rate limit.

  1. easy · M-GROWTH-V4-1 Count doubling rounds
  2. medium · M-GROWTH-V4-2 Count fan-out rounds
  3. hard · M-GROWTH-V4-3 Respect the rate limit
In the frontend A rollout estimate in Next.js and Svelte Optional

A rollout dashboard shows rounds left from the current informed count. The estimate uses the same multiply-then-divide rule, so it stays fast even when the tail is long, and it is memoized or derived so it reruns only when the inputs change. It uses the lab’s whole-number bounds and requires at least one informed node; unavailable inputs produce no estimate instead of a nonprogressing loop. The final round stops at the fleet size.

Estimate.tsx
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
import { useMemo } from "react";

// Ideal collision-free deliveries; final partial rounds count as whole rounds.
function roundsLeft(
  nodes: number,
  informed: number,
  fanout: number,
  cap: number
): number | null {
  if (
    ![nodes, informed, fanout, cap].every(Number.isSafeInteger) ||
    nodes < 1 ||
    nodes > 2 ** 52 ||
    informed < 1 ||
    informed > nodes ||
    fanout < 1 ||
    fanout > 1_000 ||
    cap < 1 ||
    cap > 2 ** 52
  )
    return null;

  let count = informed;
  let rounds = 0;

  while (count < nodes) {
    const added = count * fanout;

    if (added >= cap) return rounds + Math.ceil((nodes - count) / cap);

    count += added;
    rounds++;
  }

  return rounds;
}

export function RolloutEta({
  nodes,
  informed,
  fanout,
  cap,
  secondsPerRound
}: {
  nodes: number;
  informed: number;
  fanout: number;
  cap: number;
  secondsPerRound: number;
}) {
  const rounds = useMemo(
    () => roundsLeft(nodes, informed, fanout, cap),
    [nodes, informed, fanout, cap]
  );

  if (
    rounds === null ||
    !Number.isFinite(secondsPerRound) ||
    secondsPerRound <= 0 ||
    secondsPerRound > 3_600
  ) {
    return <p>Estimate unavailable</p>;
  }

  return (
    <p>
      {rounds} rounds left, about {Math.ceil((rounds * secondsPerRound) / 60)} min
    </p>
  );
}

Check this idea later
A retry policy doubles the delay each attempt from 100 ms. Which attempt first waits at least a minute?
A cap limits each round. Is the total time the larger of the exponential and linear estimates?
Sources

Values above were run in Node 22, Go 1.27, Rust 1.99 and Apple clang 17. The cluster is a worked model.

Report a problem in this lesson

For typos, mistakes and things that don’t work. We read every report and fix what’s wrong, but we don’t reply here, so a question won’t get an answer.