Thursday, February 25, 2010

Long division taken apart, continued

Now that we have taken long division apart, in the last posting, and made a multiplication table for the divisor `21`, in the posting before that, we are ready to look at the standard long division algorithm, with Jakow Trachtenberg's trick.

We are dividing `1543` by `21`, using the multiplication table

`\qquad\qquad\qquad[(0, 0),(1, 21),(2,42),(3,63),(4,84),(5,105),(6,126),(7,147),(8,168),(9,189)]`.

Start by writing

`\qquad\qquad\qquad\qquad\quad"****."`
`\qquad\qquad\qquad 21 )\bar1543.`

From the table, see that no whole `21`s go into `1` or into `15`, but that `7` whole `21`s, but not `8`, go into `154` :

`\qquad\qquad\qquad\qquad\qquad\quad7"*."`
`\qquad\qquad\qquad 21 )\bar1543.`
`\qquad\qquad\qquad\qquad\quad147 .`

Subtract `1470` from `1543` leaving `73`.

`\qquad\qquad\qquad\qquad\qquad\quad7"*."`
`\qquad\qquad\qquad 21 )\bar1543.`
`\qquad\qquad\qquad\qquad\quad\ul1470.`
`\qquad\qquad\qquad\qquad\qquad\quad73.`

From the table, again, `3` whole `21`s, i.e. `63`, go into `73`, leaving `10`.

`\qquad\qquad\qquad\qquad\qquad\quad73.`
`\qquad\qquad\qquad 21 )\bar1543.`
`\qquad\qquad\qquad\qquad\quad\ul1470`
`\qquad\qquad\qquad\qquad\qquad\quad73.`
`\qquad\qquad\qquad\qquad\qquad\quad\ul63.`
`\qquad\qquad\qquad\qquad\qquad\quad10.`

This is the stopping point for divmod division, so that `1543 :- 21 = 73 " remainder " 10.`

For decimal division, one continues `21`s into `100` go `4` times, i.e. `84` leaving `16`.

`\qquad\qquad\qquad\qquad\qquad\quad73.`
`\qquad\qquad\qquad 21 )\bar1543.`
`\qquad\qquad\qquad\qquad\quad\ul1470`
`\qquad\qquad\qquad\qquad\qquad\quad73.`
`\qquad\qquad\qquad\qquad\qquad\quad\ul63.`
`\qquad\qquad\qquad\qquad\qquad\quad10.0`
`\qquad\qquad\qquad\qquad\qquad\qquad\ul8.4`
`\qquad\qquad\qquad\qquad\qquad\qquad1.6`

This continues until one has reached the desired degree of accuracy.

Long division taken apart

When we divide, we are trying to find out how many times the divisor (e.g. 21) goes into the dividend (e.g. 1543).

We could just repeatedly subtract, keeping a tally of the number of times we have subtracted, stopping when further subtraction would give a negative result.  At least, that is how we could do divmod division.

Keeping such a tally would be tedious, however.  It is better to subtract large but convenient multiples of the divisor, than smaller multiples, keeping tally of these separately as we go.

In our usual decimal system of numeration, powers of ten are particularly convenient multipliers.

In 1543, the highest nonzero column is the thousands column.  We can therefore try subtracting thousands of `21`s.  We could not subtract `21` thousand even once from `1` thousand and anything without the result being negative.  So we need `0` thousands of `21`s, and we still have `1` thousand and something.

Next, we try hundreds of `21`s.  Again, we cannot subtract even `21` hundreds even once from `15` hundred and something, without the result being negative.  So we need `0` hundreds of `21`s, and we still have `15` hundred and something.

Next, we try tens of `21`s.  We can subtract `21` tens from `154` tens and something.  Indeed, we can subtract `7` times, a total of `147` tens, without getting negative result.  So now we have that `154` tens and `3` is the same as `7` lots of `21` tens, and then `7` tens and `3`.

Next we try whole `21`s.  We can subtract `21` from `73` just `3` times without going negative.  This subtracts a total of `63` from `73`, leaving `10`.

So now we have that `1543` is the same as `7` lots of `21` tens, and `3` lots of `21` ones, and a further `10`.

This can instead be understood as `70` lots of `21`, and `3` lots of `21`, and `10` more.  This in turn is `73 xx 21` and `10`.  i.e.

`\qquad\qquad\qquad 1543 = (73 xx 21) + 10.`

If we are doing divmod division, we can stop :

`\qquad\qquad\qquad 1543 -: 21 = 73" remainder "10.`

But if, instead of a remainder, we want the quotient to have a fractional part expressed as a decimal, then we keep going.

We have `10` that still needs to be divided by `21`.  So now we try subtracting tenths of `21`.  `10` is `100` tenths.  We can subtract `4` lots of tenths of `21`, i.e. `84` tenths, from `100` tenths, leaving `16` tenths.

Next, we try subtracting hundredths of `21` from `160` hundredths.  `7` hundredths of `21` is `147` hundredths, which when subtracted from `160` hundredths leaves `13` hundredths.

Stopping at this point, we find that

`\qquad\qquad\qquad 1543 = (73.47 xx 21) + 0.13`,

which we can write

`\qquad\qquad\qquad 1543 -: 21 = 73.47" remainder "0.13`.

The preceding discussion has been rather lengthy--such work is usually set out in a much more compressed format.  Unfortunately, long division seems to have been taught procedurally without adequate preparation, so that the elided computational form entrains elided thinking.  Even among the few in these calculator-infested days who can still actually do long division, a substantial fraction can give no convincing account of why the standard long division algorithm works.

Building ad hoc multiplication tables

Proportion tables are sometimes useful for doing long division. 

For many people, the most difficult part of that standard long division algorithm is estimating which multiple of the divisor to subtract.  Jakow Trachtenberg taught a simple trick for avoiding this difficulty.

In the next posting, we are going to divide 1543 by 21, using the standard long division algorithm and Trachtenberg's trick.

The first step is to invest some time making a table of multiples of `21`, up to the `9 xx 21`.  The `0` and `1` rows are obvious :

`\qquad\qquad\qquad[(0, 0),(1, 21)]`.

The `2` row can be found by doubling the second row :

`\qquad\qquad\qquad[(0, 0),(1, 21),(2,42)]`.

The `3` row can be found by adding the `1` row and the `2` row :

`\qquad\qquad\qquad[(0, 0),(1, 21),(2,42),(3,63)]`.

The `4` row can be found either by adding the `1` row to the `3` row, or else by doubling the `2` row.  One picks whichever is more convenient :

`\qquad\qquad\qquad[(0, 0),(1, 21),(2,42),(3,63),(4,84)]`.

The `5` row can be found either by adding the `2` row and the `3` row, or else by adding the `1` row and the `5` row.  Again, one picks whichever is more convenient :

`\qquad\qquad\qquad[(0, 0),(1, 21),(2,42),(3,63),(4,84),(5,105)]`.

One continues in this way, constructing the next row opportunistically, until at last one has :

`\qquad\qquad\qquad[(0, 0),(1, 21),(2,42),(3,63),(4,84),(5,105),(6,126),(7,147),(8,168),(9,189)]`.

This can be checked by casting out nines, if one knows how to do that.  (If not, it needs to be the subject of yet another post.)

Now we are ready divide anything by `21`.

`\qquad\qquad\qquad[(0, 0,(0)),(1, 21,(3)),(2,42,(6)),(3,63,(0)),(4,84,(3)),(5,105,(6)),(6,126,(0)),(7,147,(3)),(8,168,(6)),(9,189,(0))]`.

This checks out, so we can rely on the table we have made.

Wednesday, February 24, 2010

Egyptian division prolonged---fractions

Last time, we used Egyptian division to find a whole number quotient and a remainder for the division `1543 -: 21`, in the process formed the table

`\qquad\qquad\qquad[(1543, x),(21, 1),(168,8),(1344,64), (1533,73)]`.

To calculate the fractional part in decimal form, we begin by subtracting the last row from the first, and append the result at the bottom:

`\qquad\qquad\qquad[(1543, x),(21, 1),(168,8),(1344,64), (1533,73), (10, 10/21)]`.

In practice, of course, don't actually subtract, but just write the remainder we have already found, and that same remainder divided by the divisor in fractional form in the next column.

Now we take the divisor row, `[21, 1]`, halve it to get `[10.5, 0.5]`, and append at the bottom :

`\qquad\qquad\qquad[(1543, x),(21, 1),(168,8),(1344,64), (1533,73), (10, 10/21),(10.5, 0.5)]`.

We now continue, halving the bottom row and appending, halving the bottom row and appending, until the second number in the bottom row is comparable to the accuracy we require.  Suppose we want the fractional part of the quotient to be accurate to two decimal places, then :

`\qquad\qquad\qquad[(1543, x),(21, 1),(168,8),(1344,64), (1533,73), (10, 10/21),(10.5, 0.5), (5.25, 0.25), (2.625, 0.125), (1.3125,0.0625), (0.65625,0.03125), (0.328125,0.015625), (0.1640625, 0.0078125)]`.

We now make a sum as close as we can to the `10` in the target row `[10, 10/21]`, by adding together some of the rows below it.  `10.5` is larger than `10`, so we ignore that row.  `5.25` is smaller, so that row get used.  `10 - 5.25 = 4.75` left to account for. This is larger than `2.625`, so we use that row too, leaving `4.75 - 2.625 = 2.125` to account for.  Continuing, `2.125 - 1.3125 = 0.8125`; `0.8125 - 0.65625 = 0.15625`; skip `0.328125`.  For the last entry, we perform the subtraction, even though the result is negative, `0.15625 - 0.1640625 = -0.0078125`.  The reason is that it leaves an error `-0.0078125` that is smaller in magnitude than the error we would have without the subtraction, i.e. `0.1640625`. This gives us more accuracy than we expected.

Deleting (or striking out) the rows to be ignored, we get :

`\qquad\qquad\qquad [(1543, x),(21, 1),(168,8),(1344,64), (1533,73), (10, 10/21),(5.25, 0.25), (2.625, 0.125), (1.3125,0.0625), (0.65625,0.03125), (0.1640625, 0.0078125)]`.

Adding the contributing rows, we get

`5.25+2.625+1.3125+0.65625+0.1640625 = 10.0078125`,

(or, easier, `10 - -0.0078125 = 10.0078125`) and

`0.25+0.125+0.0625+0.03125+0.0078125 = 0.4765625`,

so the table finally becomes

`\qquad\qquad\qquad [(1543, x),(21, 1),(168,8),(1344,64), (1533,73), (10, 10/21),(5.25, 0.25), (2.625, 0.125), (1.3125,0.0625), (0.65625,0.03125), (0.1640625, 0.0078125),(10.0078125, 0.4765625)]`.

Since `10.0078125` is within a tenth of a percent of `10`, we must have that `0.4765625` is within a tenth of a percent of `10/21`, i.e. `10/21 \approx 0.477`, this compares well with the accurate answer of `0.476190...`  i.e. we have almost three decimal places of accuracy.

So `1543/71 \approx 73.477.`

Although it makes relatively few demands in terms of times tables, and this part requires only that we know how to halve decimal quantities, one has to put in considerable labor for each decimal place.

The method is much better adapted to binary fractions than to decimals.  These are sometimes useful, e.g. when one is working to sixteenths or thirty-seconds of an inch, say.  In binary fractions, the final table looks like this,

`\qquad\qquad\qquad [(1543, x),(21, 1),(168,8),(1344,64), (1533,73), (10, 10/21),(5 1/4, 1/4), (2 5/8, 1/8), (1 5/16, 1/16), (21/32,1/32), (21/64, 1/64),(21/128, 1/128),(10 1/128, 61/128)]`,

so that `1543/71 \approx 73 61/128.`

Egyptian division and proportion tables

Let us repeat the problem of the last posting, but solve it exactly using Egyptian division.  Egyptian division employs two columns of numbers that form a proportion table.  It does not require knowledge of times tables---knowing how to double suffices.  Nor does it require guess and check estimation of multiplies usually employed with the standard long division algorithm.  The disadvantage is that the calculation is roughly three times as long as for the standard algorithm. 

We can start just as we did for approximate division in the last posting :

`\qquad\qquad\qquad[(1543, x),(21, 1)]`.

To this, double the last row and append, double the last row and append, continuing until the numbers at the bottom of the first column bracket `1543`, i.e. `1344 < 1543 < 2688` :

`\qquad\qquad\qquad[(1543, x),(21, 1),(42,2),(84,4),(168,8),(336,16),(672,32),(1344,64),(2688,128)]`.

Now we start add the bottom, succesively adding some rows but not others, trying to make `1543`.  `2688` is already too big, so we ignore it.  (In practice, we could usually forsee this and do not write that row in the first place.)  The next row up, led by `1344` is smaller than 1543, and contributes.

`\qquad\qquad\qquad[(1543, x),(21, 1),(42,2),(84,4),(168,8),(336,16),(672,32),(1344,64)]`.

The next row up, led by `1344` is smaller than `1543`, so that row contributes, as it always does. We still have `1543 - 1344 = 199` to account for.  `672` and `336` are both bigger than `199`, so those rows do not contribute, and can be ignored.  `168` is smaller, so it contributes, leaving `199 - 168 = 31` to account for. `84` and `42` are larger than `31`, so those rows do not contribute.  `21` is smaller, so that row contributes, and leaves a remainder is `31 - 21 = 10`.

On paper, we would strike out the rows to be ignored: here we delete them all.

`\qquad\qquad\qquad[(1543, x),(21, 1),(168,8),(1344,64)]`.

Now, we append the sum of the bottom three rows :

`\qquad\qquad\qquad[(1543, x),(21, 1),(168,8),(1344,64), (21+168+1344,1+8+64)] = [(1543, x),(21, 1),(168,8),(1344,64), (1533,73)]`.

In practice, again, we would not perform the sum `21 + 168 + 1344 =1533`.  We do not need it, and even if we did, it is more readily calculated by subtracting the remainder from our original dividend, `1543 - 10 = 1533`.

We do have to perform `1+8+64 = 73`, however, to get the quotient `73`.

So we have, `1543 -: 21 = 73 " remainder "10`.

So far, we have performed divmod division, i.e. found an integer quotient and a remainder.  (div and mod are two convenient computer arithmetic terms. div gives only the integer quotient, `1543 " div " 21 = 3`, while mod gives only the remainder,`1543 " mod " 21 = 10`.)

Using wiggle notation, we can write :

`\qquad\qquad1543 -: 21 = 73;_{21}10 = 73 10/21`.

where now we are looking at the result as a mixed fraction.

It is easy to extend Egyptian division so that it gives us a decimal fraction result to any desired degree of accuracy, as we shall see in the next post.

Approximate division using a proportion table

Suppose we are trying to get a roughly estimate of how many times `21` goes into `1543`.  i.e. we are looking to approximate `1543/21`.

We can set this up as an incomplete proportion table :

`\qquad\qquad\qquad[(1543, x),(21, 1)]`.

Using the proportion table form of the Rule of Three, we can solve for `x` by multiplying the neighbors and dividing by the opposite corner :

`\qquad\qquad\qquad x = \frac{1543 xx 1}{21}`,

i.e., completing this proportion table correctly should indeed give us exactly the quantity we seek.  But we are not seeking an exact value, and are instead hoping to extract an approximate answer with less work.

First, we multiply the last row by ten and append, and repeat this until the number at the top left of the table is bracketed by the first values on the two last rows, i.e. `210<1543<2100` :

`\qquad\qquad\qquad[(1543, x),(21, 1),(210, 10),(2100, 100)]`.

Since in the first column `210<1543<2100`, we can conclude from the second column that `10 < x < 100`.

To sharpen this estimate a little, we can round `2100` to `2000` and `1543` to `1500`.  Now `1500` is three quarters of `2000`, so `x` is about three quarters of `100`, i.e. `1543/21` is roughly `75`.

Extending a proportion table

So far, we have rearranged proportion tables, we have deleted rows and/or columns, and we have cut proportion tables into smaller pieces.

Now we want to make larger tables.

One way to make a larger table is simply to duplicate a row,

`\qquad\qquad [(2, 4, 5, 9),(4, 8, 10, 18),(6, 12, 15, 27)] \qquad->\qquad [(2, 4, 5, 9),(4, 8, 10, 18),(4, 8, 10, 18),(6, 12, 15, 27)] `.

or a column,

`\qquad\qquad [(2, 4, 5, 9, 5),(4, 8, 10, 18, 10),(6, 12, 15, 27, 15)] \qquad->\qquad [(2, 4, 5, 9, 5),(4, 8, 10, 18, 10),(6, 12, 15, 27, 15)] `.

or both :

`\qquad\qquad [(2, 4, 5, 9),(4, 8, 10, 18),(6, 12, 15, 27)] \qquad->\qquad [(2, 4, 5, 9, 5),(4, 8, 10, 18, 10),(4, 8, 10, 18, 10),(6, 12, 15, 27, 15)] `

Of course we can duplicate any row or column as many times as we like.  And we can do that to many distinct rows and many distinct columns.

Another way to augment a proportion table is by appending a row that is a multiple of another row.   A multiple of one row is necessarily a multiple (usually by different multipliers) of every row :

`\qquad\qquad [(2, 4, 5, 9),(4, 8, 10, 18),(6, 12, 15, 27)] \qquad->\qquad [(2, 4, 5, 9),(4, 8, 10, 18),(6, 12, 15, 27),(60, 120, 150, 270)] `.

It should be clear that the result of appending a multiple row will always still be a proportion table, and mutatis mutandis for columns.

One can always append a column that is a sum of two or more other columns (and mutatis mutandis for rows) :

`\qquad\qquad [(2, 4, 5, 9),(4, 8, 10, 18),(6, 12, 15, 27)] \qquad->\qquad [(2, 4, 5, 9, 5+9),(4, 8, 10, 18,10+18),(6, 12, 15, 27,15+27)] `,

`\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad =  \qquad [(2, 4, 5, 9, 14),(4, 8, 10, 18, 28),(6, 12, 15, 27, 42)]`.

More generally, the result of appending a sum or difference of existing  rows or of columns is another proportion table.

In the last posting, we dealt with subtables and amalgamation.  Amalgamating two rows is equivalent to appending their sum, and deleting the original two rows, and similarly for amalgamating two columns. Any amalgamation whatever of a table (i.e. over a tartanlike decomposition) can be constructed by a suitably chosen succession of amalgamations of pairs of rows and pairs of columns.