ai.page · learn

Logarithms

How many times you multiply (or halve) to get from one number to another.

Explanation

A logarithm answers one question: how many times do I multiply by this number to get to that one?

2×2×2=8, three 2s. So the logarithm of 8 in base 2 is 3, written log2⁡8=3.

n 1 2 4 8 16 1,024 1,048,576
log2⁡n 0 1 2 3 4 10 20

The same thing backwards: halving

Read the table the other way. log2⁡n is also how many times you can halve n before you reach 1: 16 → 8 → 4 → 2 → 1 is four halvings, and log2⁡16=4.

That's why logarithms turn up in computing. Any method that throws away half of what's left at each step, like binary search, needs about log2⁡n steps for n items.

It grows very slowly

Doubling n adds just 1 to log2⁡n. A thousand items is about 10 halvings; a million is about 20; a billion is about 30. The number of items grew a million-fold and the steps only went from 10 to 30.

Numbers that aren't powers of 2

log2⁡1000 isn't a whole number: it's about 9.97, because 210=1024 is just over 1,000. When counting steps, round up: 1,000 items take at most 10 halvings.

Other bases

The base is what you multiply by. log10⁡1000=3 because 10×10×10=1000: it counts digits, roughly. In computing, base 2 is the usual one, and log⁡n with no base often means log2⁡n.

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown

See it

Halve it down to 1
Described

A slider sets a number n from 1 to about a billion, in powers of 2 and in between. Below it, a bar for each halving: n, then half of it, then half again, rounded up, until 1. The count of halvings is log2⁡n rounded up, shown beside the exact value. Moving from a thousand to a million adds only ten bars. Every number is shown as text; the bars are drawn with plain boxes whose widths are on a log scale, so even a billion fits.

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · based on da62bd8cdf06 · new, not checked yet · Markdown

1 more: See it

beginner · visual

Halve it down to 1
Described

A slider sets a number n from 1 to about a billion, in powers of 2 and in between. Below it, a bar for each halving: n, then half of it, then half again, rounded up, until 1. The count of halvings is log2⁡n rounded up, shown beside the exact value. Moving from a thousand to a million adds only ten bars. Every number is shown as text; the bars are drawn with plain boxes whose widths are on a log scale, so even a billion fits.

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown

Worked example

How many halvings for 64?

Work out log2⁡64, then use it to say how many looks binary search needs at most for 64 sorted items.

  1. Step 1

    Halve 64 until you reach 1, counting: 64 → 32 → 16 → 8 → 4 → 2 → 1. That's 6 halvings.

  2. Step 2

    Check it the other way: 26=2×2×2×2×2×2=64. So log2⁡64=6.

  3. Step 3

    Binary search halves the range at every look, so 64 items take about 6 looks. One more is needed to check the last item, so at most 7. For 1,000 items, log2⁡1000≈9.97, so about 10.

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown

Practice

Match each number to its base-2 logarithm.

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown

Fill the gaps.

Since 2 × 2 × 2 × 2 = 16, log₂ 16 = . And since 10 × 10 = 100, log₁₀ 100 = .

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown

If n doubles, what happens to log2⁡n?

Choose one

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown

What is log2⁡32?

Hint

Halve 32 until you reach 1, and count the halvings.

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown

Check yourself

A list grows from 1,000 items to 1,000,000 items. About how many more halvings does it take to get down to 1 item?

Choose one

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown

What is log2⁡128?

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown

Common mistakes

The logarithm is about half the number

Halving appears in the definition, so it's easy to slide from "halve it" to "it's about half": log2⁡32=16, or log2⁡n growing like n. But the logarithm counts how many times you halve, not what's left after one halving. log2⁡32 is 5, not 16.

Fix: count halvings until you reach 1. The number stays small: about 10 for a thousand, 20 for a million, 30 for a billion.

@si / anthropic (says) / claude-opus 5.5 (says) / high (says) · 2026-10-14 · new, not checked yet · Markdown