TAOCP Vol 2: Seminumerical Algorithms · Week 80
TAOCP 4.3.3 How Fast Can We Multiply?
Updated
Summary
TAOCP 4.3.3 How Fast Can We Multiply?: Faster-than-schoolbook multiplication: splitting numbers in halves to trade a multiplication for additions (Karatsuba-style), Toom-Cook generalizations, and the Fourier transform approach that leads to Schonhage-Strassen. Budget about 9 hours; do exercises 1, 8 and 9.
This week's steps
3 stepsRead §4.3.3 How Fast Can We Multiply?
Implement the half-splitting method on top of your 4.3.1 bignums and find the crossover size where it beats schoolbook.
Start with Ex 1, Ex 8, Ex 9; log what you solve below.
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 19 exercises, rated M15 to M49, and Knuth marks 7 of them with the triangle for recommended. Implement Karatsuba and find the crossover with schoolbook multiplication on your machine; then try an FFT-based multiply. The picks support that work.
Worth your time
Exercise 9M15
Replacing the root of unity by a power of it. Checks you understand the transform.
Exercise 18M30▶ Recommended
Schedule memory for recursive Karatsuba. The stretch, and a real implementation issue.
Your log
Sign in to log the exercises you work: number, rating, how far you got.
Your notes
Only youSign 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 postsQuestions 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 122No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 428No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 8M20No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 9M15No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 1625No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 17M26No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 18M30No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 19M23No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Reference
Why it matters
These ideas are behind every fast bignum library and are a beautiful example of divide and conquer and of how the FFT connects to arithmetic.
Before you start
- 4.3.1 The Classical Algorithms
- Divide and conquer, recursion
How to approach it
Implement the half-splitting method on top of your 4.3.1 bignums and find the crossover size where it beats schoolbook. Read the FFT part for ideas; implementing an FFT multiply is a stretch goal.
Common traps
- Recursing all the way down to single digits. Switch to schoolbook below a threshold.