Video 3, chapter 5

Multiplication by Halving

How Russian peasant multiplication finds a product by halving and doubling, why the rows with an odd left entry give the answer, and how binary representation, powers of two and ancient Egyptian multiplication explain it.

  • Video 3, chapter 5
  • Numbers with a hidden mechanism

Suppose you can halve, double and add, but you have no multiplication table. Can you still find 13 times 27? Write 13 and 27 side by side, keep halving the left number and doubling the right one, then add some of the right-hand numbers. This page explains which rows to add, why the total is always the exact product, and how the rows that survive spell out the first number in binary.

Key terms

Russian peasant multiplication

Definition Russian peasant multiplication finds the product mbmb of a nonnegative whole number mm and a whole number bb. Write mm and bb as the first row of a two-column table. To make each new row, halve the left entry and discard any fractional part, so that 13 becomes 6, and double the right entry. Stop after the row whose left entry is 1. Then cross out every row whose left entry is even, and add the right entries of the rows that remain, the rows whose left entry is odd. The sum equals mbmb for every such mm and bb. When m=0m = 0 no row has left entry 1, and the table is the single row with entries 0 and bb. That row is crossed out, so nothing is added and the product is 0. The halved number must be a nonnegative whole number. The doubled number may be any number, because the method only doubles it and adds, and a product with a negative first factor is found by multiplying the absolute value of that factor by bb and changing the sign of the result.

In plain words Halve on the left, double on the right, and keep the rows where the left number is odd. An odd left entry marks a group that cannot be paired up and is set aside, and the answer is the total of everything set aside.

Example For 13 times 27 the table is the following.

HalvedDoubledRow
1327kept
654crossed out
3108kept
1216kept

The kept rows add up to 27+108+216=35127 + 108 + 216 = 351, and indeed 13⋅27=35113 \cdot 27 = 351. The number 13 was never multiplied by 27 directly.

Halving and doubling

Definition Halving and doubling rest on two identities, which hold for every whole number k≥0k \ge 0 and every number bb.

(2k) b=k (2b),(2k+1) b=k (2b)+b.\begin{gathered} (2k)\,b = k\,(2b), \\[0.4em] (2k + 1)\,b = k\,(2b) + b. \end{gathered}

Halving here is integer halving. A whole number L≥0L \ge 0 is either even, L=2kL = 2k, or odd, L=2k+1L = 2k + 1, and in both cases its integer half is k=⌊L/2⌋k = \lfloor L/2 \rfloor, where ⌊x⌋\lfloor x \rfloor is the largest whole number not exceeding xx. Let SS be the sum of the right entries kept so far. One step of the method goes from a row with entries LL and RR to the row with entries ⌊L/2⌋\lfloor L/2 \rfloor and 2R2R, first adding RR to SS when LL is odd. By the identities the quantity S+LRS + LR is an invariant, a quantity that is the same after every step. It starts as 0+mb0 + mb. Each step makes a positive left entry smaller, so the left entry eventually becomes 0, one step after the row with left entry 1, and at that point S+0⋅R=SS + 0 \cdot R = S. Hence the kept entries add up to exactly mbmb.

In plain words Think of LL groups with RR objects in each. An even number of groups pairs off into half as many groups of twice the size, with nothing left over. An odd number of groups leaves one group unpaired, so that group is set aside first and the rest are paired. No object is ever lost or counted twice, so in the end the groups set aside hold all mbmb objects.

Example Track the saved total SS for 13 times 27. In each row, SS is the total saved from the rows above it, and the last line shows the state one step after the row with left entry 1.

Groups LLSize RRSaved SSS+LRS + LR
13270351
65427351
310827351
1216135351
0432351351

Thirteen groups of 27 become one saved group of 27 and six groups of 54. Six groups pair off exactly into three groups of 108, which is why the row starting with 6 adds nothing. Its objects are not lost but carried into the next row in bigger groups, and counting that row as well would count them twice.

Powers of two

Definition The powers of two are the numbers 2j2^j for whole numbers j≥0j \ge 0, namely 1, 2, 4, 8, 16, 32 and so on, where 20=12^0 = 1 and each power is twice the one before. For every j≥1j \ge 1 the powers below 2j2^j add up to one less than it,

1+2+4+⋯+2j−1=2j−1.\begin{aligned} &1 + 2 + 4 + \cdots + 2^{j-1} \\[0.4em] &\quad = 2^j - 1. \end{aligned}

In the multiplication table for mm and bb, the row numbered jj, counting the first row as row 0, holds ⌊m/2j⌋\lfloor m/2^j \rfloor on the left and 2jb2^j b on the right. For m≥1m \ge 1 the table has J+1J + 1 rows, where 2J2^J is the largest power of two not exceeding mm.

In plain words Powers of two are what you get by doubling 1 again and again. The doubled column lists 1, 2, 4, 8 and so on copies of the second number, and each power of two is larger than all the smaller ones put together.

Example The first four powers add up to 1+2+4+8=151 + 2 + 4 + 8 = 15, one less than 16. For a first factor of 1000 the largest power of two not exceeding it is 29=5122^9 = 512, so the table has only 10 rows. For 1000 times 3 the kept right entries are 24, 96, 192, 384, 768 and 1536, which add up to 3000.

Binary representation

Definition Every positive whole number mm can be written in exactly one way as a sum of distinct powers of two. Taking the largest power that does not exceed mm and repeating with what is left produces such a sum. That largest power must appear in every such sum for mm, because all smaller powers together add up to 1 less than it, and repeating this argument with what is left shows that the sum is unique. The binary representation of mm lists, from the largest power used down to 202^0, the digit 1 for each power in the sum and 0 for each power not in it. The number 0 is written 0. Integer halving reads these digits from the right. A whole number is odd exactly when its last binary digit is 1, and halving with the fractional part discarded deletes the last binary digit. So in the multiplication table the left entry of row jj is odd exactly when binary digit jj of mm, counted from the right starting at 0, is 1. The kept rows therefore hold 2jb2^j b for exactly the powers 2j2^j that make up mm, and they add up to mbmb.

In plain words Binary writes a number using only the place values 1, 2, 4, 8 and so on, each used once or not at all. Halving peels these place values off from the smallest up, and an odd row says that the current place value is used.

Example Since 13=8+4+113 = 8 + 4 + 1, the binary representation of 13 is 1101. In the table for 13 times 27 the right entries 27, 54, 108 and 216 are 1, 2, 4 and 8 copies of 27, and the left entries 13, 6, 3 and 1 are odd, even, odd and odd, which matches the digits of 1101 read from right to left. So

13⋅27=(8+4+1)⋅27=216+108+27.\begin{aligned} 13 \cdot 27 &= (8 + 4 + 1) \cdot 27 \\[0.4em] &= 216 + 108 + 27. \end{aligned}

An even first factor works the same way. For 18 times 23 the rows are 18 and 23, 9 and 46, 4 and 92, 2 and 184, and 1 and 368. Only the left entries 9 and 1 are odd, matching 18=16+218 = 16 + 2, which is 10010 in binary, and the product is 46+368=41446 + 368 = 414.

Ancient Egyptian multiplication

Definition Ancient Egyptian multiplication finds the product mbmb for a positive whole number mm by doubling alone. Make a table whose rows are 1 and bb, then 2 and 2b2b, then 4 and 4b4b and so on, doubling both entries each time, and stop at the last row whose left entry does not exceed mm. Then mark the rows whose left entries add up to exactly mm, using each row at most once. Working from the last row up, mark a row whenever its left entry is no more than what is still needed, and subtract it. The marked rows are the powers of two in the binary representation of mm, so the marked right entries add up to mbmb. They are the same right entries that Russian peasant multiplication keeps, found from the other end. The method appears in the Rhind papyrus, an Egyptian mathematical text from about 1550 BC.

In plain words Double the second number until the doubling counts are about to pass the first number, then pick the doublings that make up the first number exactly. Halving does the same picking automatically, one binary digit at a time.

Example For 13 times 27 the doubling table has rows 1 and 27, 2 and 54, 4 and 108, and 8 and 216, and it stops there because the next left entry, 16, would exceed 13. From the last row up, 8 fits into 13 and leaves 5, then 4 fits and leaves 1, then 2 does not fit, and 1 fits and leaves 0. So 13=8+4+113 = 8 + 4 + 1, and

13⋅27=216+108+27=351,\begin{aligned} 13 \cdot 27 &= 216 + 108 + 27 \\[0.4em] &= 351, \end{aligned}

the same three numbers the halving table kept.

Check yourself

  1. Use halving and doubling to compute 21 times 34. Which rows are kept, and how do they match the binary representation of 21?
Show the answer

The table is the following.

HalvedDoubledRow
2134kept
1068crossed out
5136kept
2272crossed out
1544kept

The kept rows give 34+136+544=71434 + 136 + 544 = 714, and 21⋅34=71421 \cdot 34 = 714. They are rows 0, 2 and 4, holding 1, 4 and 16 copies of 34, and indeed 21=16+4+121 = 16 + 4 + 1, which is 10101 in binary.

  1. Someone halves 13 by rounding up instead of discarding the fractional part, so the left column reads 13, 7, 4, 2 and 1. Keeping the odd rows as before, what total do they get, and where does the method break?
Show the answer

The right column is still 27, 54, 108, 216 and 432. The odd left entries are 13, 7 and 1, so the total is 27+54+432=51327 + 54 + 432 = 513 instead of 351. The method needs an odd count 2k+12k + 1 to become kk, so that one group is saved and the remaining 2k2k groups pair off exactly. Thirteen groups of 27 hold 351 objects, and after one group of 27 is saved, 324 objects remain. Rounding up claims seven groups of 54, which would hold 378 objects, so the table has gained 54 objects that do not exist. The next rounding up, from 7 to 4, gains another 108 in the same way, and 351+54+108=513351 + 54 + 108 = 513. Halving has to discard the fractional part.

  1. Extend the pattern. Replace halving by dividing by 3 with the remainder discarded, and doubling by tripling. How much of each right entry should be kept? Test your rule on 23 times 4.
Show the answer

Write each left entry as L=3k+rL = 3k + r with remainder rr equal to 0, 1 or 2. Then LL groups of RR objects become kk groups of 3R3R objects and rr leftover groups, because

(3k+r) R=k (3R)+rR.(3k + r)\,R = k\,(3R) + rR.

So keep rr times the right entry, and stop when the left entry becomes 0. For 23 times 4 the table is the following.

LeftRightRemainderKept
23428
712112
236272

The next left entry would be 0, so the table ends, and 8+12+72=92=23⋅48 + 12 + 72 = 92 = 23 \cdot 4. The remainders read from the last row up are 2, 1 and 2, and indeed 23=2⋅9+1⋅3+223 = 2 \cdot 9 + 1 \cdot 3 + 2, which is 212 in base 3. Halving is the base 2 case, where every remainder is 0 or 1, so each row is either crossed out or kept whole.