TAOCP Vol 1: Fundamental Algorithms · Week 31

TAOCP 1.2.2 Numbers, Powers, and Logarithms

Updated

About 4 hours29 exercises, rated 00 to M30

Summary

TAOCP 1.2.2 Numbers, Powers, and Logarithms: A careful build-up of integers, rationals and reals, then powers with real exponents and logarithms in any base. Budget about 4 hours; do exercises 4, 11 and 17.

It ends with practical ways to compute logarithms by hand-style methods.

Flashcards 15 cards for Anki and AnkiMobile · all decks

Anki deck.tsv

This week's steps

3 steps
  1. Read §1.2.2 Numbers, Powers, and Logarithms

    Skim the construction of the real numbers unless you enjoy it.

  2. Work the exercises (8 picked)

    Start with Ex 4, Ex 11, Ex 17; log what you solve below.

  3. Write down one thing you'd explain to someone

    A few sentences in your own words in Your notes: the idea, why it works, an example. 30 words ticks this.

Sign in to track this: tick each step off and it counts toward your week.

Exercises

This section has 29 exercises, rated 00 to M30, and Knuth marks seven of them with the triangle for recommended. Most are quick. The interesting ones for a programmer are the log-sizing questions (19, 22) and the shift-and-add algorithms at the end (25, 28).

Worth your time

  • Exercise 405▶ Recommended

    Evaluate a fractional power by hand. Quick check on the exponent rules.

    Discuss

  • Exercise 1110▶ Recommended

    Work out how many digits of a logarithm you need for a given accuracy in the power. Error propagation in miniature.

    Discuss

  • Exercise 1705▶ Recommended

    A quick round of logs in various bases, a couple of which do not exist.

    Discuss

  • Exercise 1920▶ Recommended

    Decide whether a 14-digit decimal number fits in a 47-bit word. The log-to-count-bits skill you use when sizing integers.

    Discuss

  • Exercise 2220▶ Recommended

    Show a cheap approximation of the base-2 log from ln and log10, and bound its error.

    Discuss

  • Exercise 2522

    Prove that a method using only shifts, additions and subtractions computes a binary logarithm. How machines did logs without multiplying.

    Discuss

  • Exercise 27M25▶ Recommended

    Error analysis of the text's log10 method when each step is computed with limited precision.

    Discuss

  • Exercise 28M30

    Design and analyze a shift-and-add method for exponentials, the inverse of exercise 25. The stretch.

    Discuss

Your log

Sign in to log the exercises you work: number, rating, how far you got.

Your notes

Only you

Sign in to keep private notes on this guide, in Markdown. They stay yours: never on your profile, and you can export them all.

Discussion

0 posts

Questions about the reading go here; each exercise has its own thread below. Hints over answers.

No posts yet. Ask a question or share a tip.

Sign in to postAnyone can read. Posting needs an account with a confirmed email.

Exercise threads

One thread per exercise. Open one to ask for a nudge or check your thinking.

  • Exercise 405No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 1110No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 1705No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 1920No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 2220No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 2522No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 27M25No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

  • Exercise 28M30No posts yet

    Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler: ||like this|| or a ```spoiler block.

    Sign in to postAnyone can read. Posting needs an account with a confirmed email.

Reference

Why it matters

Logs are everywhere in complexity analysis, bit counts and data sizes. Knowing exactly how log base changes work, and why lg n and ln n differ only by a constant, makes big-O arguments feel obvious instead of magical.

Before you start
  • High-school algebra
  • Exponent rules
How to approach it

Skim the construction of the real numbers unless you enjoy it. Work through the logarithm identities with pencil and make a cheat sheet of lg, ln and log10 conversions. Try the method for computing a logarithm digit by digit on a small example.

Common traps
  • Mixing up lg (base 2), ln (base e) and log10. Knuth uses lg for base 2 throughout the series.
  • Spending the whole week on the real-number construction. It is background, not the point.

Spot a mistake? Report it

Back to week 31