Copyright © 2007 jsd
Here are some hints on how to do basic math calculations.
These suggestions are intended to make your life easier. Some of them may seem like extra work, but really they cause you less work in the long run.
This is a preliminary document, i.e. a work in progress.
If that’s too much bother, start with a plain piece of paper and sketch in faint guidelines when necessary.
If the meaning of variables such as a and b is not obvious, write down a legend somewhere (like the legend of a map), explaining in a sentence or two the meaning of each variable. That is, a name is not the same as an explanation. Do not expect the structure of a name or symbol to tell you everything you need to know. Most of what you need to know belongs in the legend. The name or symbol should allow you to look up the explanation in the legend.
Sometimes the penalty for getting this wrong is 328 million dollars, as in the case of the Mars Climate Orbiter (reference 2).
Most computer languages do not automatically keep track of the units, so you will have to do it by hand, in the comments. If the calculation is nicely structured, it may suffice to have a legend somewhere, spelling out the units for each of the variables. If variables are re-used and/or converted from one set of units to another, you need more than just a legend; you will need comments (possibly quite a lot of comments) to indicate what units are being used at each point in the code.
One policy that is sometimes helpful (but sometimes risky) is to convert everything to SI units as soon as it is read in, even in fields where SI units are not customary. Then you can do the calculation in SI units and convert back to conventional units (if necessary) immediately before writing out the results. (This is problematic when writing an “intermediate” file. Should it be SI or customary? How do you know the difference between an “intermediate” result and a final result?)
It is certainly possible for computer programs to keep track of the units automatically. A nice example is reference 3. It is a shame that such features are not more widely available
Here’s a classic example: The task is to add 198 plus 215. The easiest way to solve this problem in your head is to rearrange it as (215 + (200 − 2)) which is 415 − 2 which is 413. The small point is that by rearranging it, a lot of carrying can be avoided.
One of the larger points is that it is important to have multiple methods of solution. This and about ten other important points are discussed in reference 4.
The classic "textbook" diagram of an inequality uses shading to distinguish one half-plane from the other. This is nice and attractive, and is particularly powerful when diagramming the relationship between two or more inequalities, as shown in figure 2.
However, when you are working with pencil and paper, shading a region is somewhere between horribly laborious and impossible.
It is much more practical to use hatching instead, as shown in figure 3.
Obviously the hatched depiction is not as beautiful as the shaded depiction, but it is good enough. It is vastly preferable on cost/benefit grounds, for most purposes.
Short multiplication refers to any multiplication problem where you just memorize the answer. You must memorize the multiplication table for everything from 0×0 through 9×9. You get the next step (up to 10×10) practically for free, and it is often worthwhile to keep going up to 12×12.
Long multiplication refers to multiplying larger numbers. This works by breaking the numbers down into their individual digits, then multiplying on a digit-by-digit basis (using the short multiplication facts for zero through nine) and then combining all the results with due regard for place value.
We now discuss a nice way to do long multiplication. The first steps are shown in figure 5. There are two parts to the figure, representing two successive stages of the work. Anything shown in black is something you actually write down, whereas anything shown in color is just commentary, put there to help us get through the explanation the first time.
We start with the leftmost part of the figure. This is just the statement of the problem, namely 4567×321. The important point here is to line up the numbers as shown, so that the ones’ place of the top number lines up with the ones’ place of the bottom number, et cetera. Keeping things aligned in columns is crucial, since the colums represent place value. If you have trouble keeping things properly lined up, use grid-ruled paper. You can see such a grid in figure 5. If you don’t have grid-ruled paper, you can always sketch in some guide lines. As mentioned in item 1, tidiness pays off.
You may omit the multiplication sign (×) if it is obvious from context that this is a multiplication problem (as opposed to an addition problem).
Tangential remark: Some people attempt to call one of these numbers the multiplier and the other the multiplicand, but since multiplication is commutative the distinction is meaningless. People often use the terms in ways inconsistent with the supposed definition. I call both of them multiplicands, which is more-or-less Latin for “thing being multiplied”. In figure 6 we have two things being multiplied. Note that since multiplication is associative, you could easily have many things being multiplied, as in 12×32×65×99, in which case it again makes sense to call each of them multiplicands, and it is obviously hopeless to attempt to distinguish “the” multiplier from “the” multiplicand. As a related issue, there are also holy wars as to whether 4567×321 means 4567 “times” 321, or 4567 “multiplied by” 321. Again the distinction is meaningless. Don’t worry about it.
If one of the multiplicands is longer than the other, it will usually be more convenient to place the longer one on top. That’s not mandatory, but it makes the calculation slightly more compact.
We now proceed digit by digit, starting with the rightmost digit in the bottom multiplicand, which in this case is a 1. We multiply this digit into each digit of the upper multiplicand, working in order right-to-left, which makes sense because it is the direction of increasing place value (even though it is opposite to the direction of reading normal text).
We place these results in order in row c, with due regard for place value. The 1×7 result goes in the ones’ place, the 1×6 result goes in the tens’ place, and the 1×5 result goes in the hundreds’ place, and so forth. Actually, multiplication by 1 is so easy that you could just copy the whole number 4567 into row c without thinking about it very hard.
You may wish to leave a little bit of space above the numbers in row c, for reasons that will become apparent later.
That is all we need to do with the low-order digit of the bottom multiplicand. We now move on to the next digit, working right-to-left. In this case it is a 2.
Again we multiply this digit into each digit of the upper multiplicand. The result of the first such multiplication is 2×7=14, which we place in row d. This is most clearly seen in the middle column of the figure 6. Alignment is crucial here. The 14 must be aligned under the 2 as shown. That’s because it “inherits” the place value of the 2.
Next we multiply 2×6=12. You might be tempted to write this in row d, but there is no room for it there, so it must go on row e, as shown in the middle column of the figure. Again alignment is critical. The 12 is shifted one place to the left of the 14, because it inherits additional place value. It inherits some from the 2 and some from the 6. Since we are working systematically right-to-left, you don’t need to think about this too hard; just remember that each of these short-division products must be shifted one place to the left of the previous one.
We have now more than half-way finished. We have reached the stage shown in figure 5.
Figure 6 shows all the steps.
The next step is the 2×5=10 multiplication. There is room for this on row d, which is a good place to put it. Next we do the 2×4=8 multiplication. There is room for this on row e, which is a good place to put it. Note the pattern of placing successive short-division results on alternating rows. This is guaranteed to work, because the product of two one-digit numbers can never have more than two digits.
At this point (or perhaps earlier), if you are not using grid-ruled paper, you should lightly sketch in some vertical guide lines, as shown by the dashed lines in figure 7. The tableau has become large enough that there is some risk of messing up the alignment, i.e. putting things into the wrong columns, if you don’t put in guide lines.
That’s all for the “2” digit in the bottom multiplicand. We now progress to the “3” digit. The work proceeds in the same fashion. All the short-multiplication results are put in rows f and g.
In the tableau, you can see where everything comes from. The color-coded background indicates which digit of the upper multiplicand was involved, and the row indicates which digit of the bottom multiplicand was involved.
At this point you can draw a line under row g as shown in the figure. All that remains is a big addition problem, adding up rows c through g inclusive. You can use the space above row c to keep track of carries if you wish, but this is not mandatory. (There are never very many carries, so keeping track of them is easy, no matter how you do it. Some people just count them on their fingers.)
The result of the addition is the result of the overall multiplication problem, as shown on row h.
Let’s do another example, as shown in figure 7, which illustrates one more wrinkle.
This example calls attention to the situation where some of the short-multiplication products have one digit, while others have two. You can see this on row c of the figure, where we have 3×3=9 and 3×8=24. In most cases it is safer to pretend they all have two digits, which is what we have done in the figure, writing 9 as 09. Similarly on line d we write 6 as 06. This makes the work fall into a nice reliable pattern. It helps you keep things lined up, and makes the work easier to check.
In some cases, such as 345×1 or 432×2, all the short-multiplication products have one digit, so you can write them all on a single line, if you wish. This saves a little bit of paper. On the other hand, remember the advice in item 3: paper is cheap. You may find it helpful to write the short-multiplication products as two digits even if you don’t have to.
Mathematically speaking, writing one-digit products as two digits is unconventional, but it is entirely correct. It has the advantage of making the algorithm more systematic, and therefore easier to check.
In any case, the result of the addition is the result of the overall multiplication problem, as shown on row g of figure 7. That’s all there is to it.
This algorithm uses two rows of intermediate results for each digit in the bottom multiplicand (except when the digit is zero or one). This has two advantages: First of all, you don’t need to do any adding or carrying as you go along; you just write down the short-multiplication results “as is”. Secondly, it makes it easy to check your work. Each of the short-multiplication results is sitting there in an obvious place, almost begging to be checked.
This differs from the old-fashioned “textbook” approach, which uses only one row per digit, as shown below. The old-fashioned approach supposedly uses less paper – but the advantage is slight at best, and if you allow room keeping track of “carries” throughout the tableau, the advantage becomes even more dubious.
What’s worse is that the old-fashioned approach is significantly more laborious. It may look more compact, but it involves more work. You have to do the same number of short multiplications, and a greater number of additions. It requires you to do additions (including carries) as you go along.
Last but not least, it makes it much harder to check your work.
The old-fashioned approach.
Remember, paper is cheap (item 3) and it is important to be able to check your work (item 7).
The usual “textbook” instructions for how to do long division are both unnecessarily laborious and unnecessarily hard to understand. There’s another way to organize the calculation that is much less mysterious and much less laborious (especially when long multi-digit numbers are involved).
Note that as discussed above, keeping things lined up in columns is critical. It may help to use grid-ruled paper, or at least to sketch in some guidelines.
Figure 8 shows an example. The assignment is to divide 7527 by 13.
After writing down the statement of the problem, and before doing any actual dividing, it helps to make a crib, as shown in the lower left of the figure. This is just a multiplication table, showing all multiples of 13 (or, more generally, all multiples of the assigned divisor). It is super-easy to construct such a table, since no multiplication is required. Successive addition will do the job. We need all the multiples from ×1 to ×9, but you might as well calculate the ×10 row, by adding 117+13, as a check on all the additions that have gone before.
The first step is to consider the leading digit of the dividend (which in this case is a 7). Since this is less than the divisor (13), there is no hope of progress here, so we proceed to the next step.
Now consider the first two digits together, namely the 7 and the 5. Look at the crib to find the largest entry less than or equal to 75. It is 65, as in 5×13=65. Write copy this entry to the division problem, on row b, directly under the 75. Since this came from row 5 of the crib, write a 5 on the answer line, aligned with the 75 and the 65, as shown. Check the work, to see that 5 (on the answer line) times 13 (the divisor, on line a), equals 65 (on line b).
Now do the subtraction, namely 75−65=10, and write the result on line c as shown.
We now shift attention from the first column to the middle column of figure 8. Bring down the 2 from the dividend, as shown by the red arrow in the middle column of the figure. So now the number we are working on is 102, on line c.
The steps from now on are a repeat of earlier steps.
Look at the crib to find the largest entry less than or equal to 102. It is 91, as in 7×13=91. Write copy this entry to the division problem, on row d, directly under the 102. Since this came from row 7 of the crib, write a 7 on the answer line, aligned with the 102 and the 91, as shown. Check the work, to see that 7 (on the answer line) times 13 (the divisor, on line a), equals 91 (on line d). Do the subtraction.
As a check on the work, when doing this subtraction, the result should never be less than zero, and should never be greater than or equal to the divisor. Otherwise you’ve used the wrong line from the crib, or made an arithmetic error.
We now shift attention to the rightmost column of figure 8. Bring down the 7, look in the crib to find the largest entry less than or equal to 117, which is in fact 117, as in 9×13=117. Since this came from line 9 of the crib, write a 9 on the answer line, properly aligned.
The final subtraction yields the remainder on line g. The remainder is zero in this example, because 13 divides 7527 evenly.
The crib plays several important roles.
Perhaps the crib’s most important advantage, especially when people are first learning long division, is that the crib removes the mystery and the guesswork from the long division process. This is in contrast to the “trial” method, where you have to guess a quotient digit, and you might guess wrong. Using the crib means we never need to do a short division or trial division; all we need to do is skim the table to find the desired row.
We have replaced trial division by multiplication and table-lookup. Actually we didn’t even need to do any multiplication, so it would be better to say we have replaced trial division by addition.
Another advantage is efficiency, especially when the dividend has many digits. That’s because you only need to construct the crib once (for any given divisor), but then you get to use it again and again, once for each digit if the dividend. For long dividends, this saves a tremendous amount of work. (This is not a good selling point when kids are just learning long division, because they are afraid of big multi-digit dividends.) Setting up the crib is so fast that you’ve got almost nothing to lose, even for small dividends.
Another advantage is that it is easy to check the correctness of the crib. It’s just sitting there begging to be checked.
When bringing down a digit, you may optionally bring down all the digits. For instance, in the middle column of figure 8, if you bring down all the digits you get 1027 on row c. One advantage is that 1027 is a meaningful number, formed by the expression 7527−13×5×102. This shows how the steps of the algorithm (and the intermediate results) actually have mathematical meaning; we are not not blindly following some mystical mumbo-jumbo incantation. I recommend that if you are trying to understand the algorithm, you should bring down all the digits a few times, at least until you see how everything works.
A small disadvantage is that bringing down all the digits requires more copying. The countervailing small advantage is that it may help keep the digits lined up in their proper columns. Whether the advantages outweigh the cost is open to question, and probably boils down to a question of personal preference.
Another remark: Division is the “inverse function” of multiplication. In a profound sense, for any function that can be tabulated, you can construct the inverse function – if it exists – by switching columns in the table. That is, we interchange abscissa and ordinate: (x,y)↔(y,x). That’s why we are able to perform division using what looks like a multiplication table; we just use the table backwards.
The modern numeral system is based on place value. As we understand it today, each numeral can be considered a polynomial in powers of b, where b is the base of the numeral system. For decimal numerals, b=10. As an example:
This allows us to understand long multiplication (section 4) in terms of the more general rule for multiplying polynomials.
Given two expressions such as (a+b+c) and (x+y), each of which has one or more terms, the systematic way to multiply the expressions is to make a table, where the rows correspond to terms in the first expression, and the rows correspond to terms in the second expression:
In the special case of multiplying a two-term expression by another two-term expression, the mnemonic FOIL applies. That stands for First, Outer, Inner, Last. As shown in figure 9, we start with the First contribution, i.e. we multiply the first term from in each of the factors. Then we add in the Outer contribution, i.e. the first term from the first factor times the last term from the last factor. Then we add in the Inner contribution, i.e. the last term from the first factor times the first term from the last factor. Finally we add in the Last contribution, i.e. we multiply the last terms from each of the factors.
If you can do long division, you can do square roots.
Most square roots are irrational, so they cannot be represented exactly in the decimal system. (Decimal numerals are, after all, rational numbers.) So the name of the game is to find a decimal representation that is a sufficiently-accurate approximation.
We start with the following idea: For any nonzero x we know that x÷√x is equal to √x. Furthermore, if s1 is greater than √x it means x/s1 is less than √x. If we take the average of these two things, s1 and x/s1, the average is very much closer to √x. So we set
and then iterate. The method is very powerful; the number of digits of precision doubles each time. It suffices to use a rough estimate for the starting point, s1. In particular, if you are seeking the square root of an 8-digit number, choose some 4-digit number as the s1-value.
This is a special case of a more general technique called Newton’s method, but if that doesn’t mean anything to you, don’t worry about it.
Note that the square of 1.01 is very nearly 1.02. Similarly, the square of 1.02 is very nearly 1.04. Turning this around, we find the general rule that if x gets bigger by two percent, then √x gets bigger by one percent ... to a good approximation.
We can illustrate this idea by finding the square root of 50. Since 50 is 2% bigger than 49, the square root of 50 is 1% bigger than 7 ... namely 7.07. This is a reasonably good result, accurate to better than 0.02%.
If we double this result, we get 14.14, which is the square root of 200. That is hardly surprising, since we remember that the square root of 2 is 1.414, accurate to within roundoff error.
Sine and cosine are transcendental functions. Evaluating them will never be super-easy, but it can be done, with reasonably decent accuracy, with relatively little effort, without a calculator.
The following facts serve to “anchor” our knowledge of the sine and cosine:
Actually, that hardly counts as “remembering” because if you ever forget any part of equation 4 you should be able to regenerate it from scratch. The 0∘ and 90∘ values are trivial. The 30∘ is a simple geometric construction. Then the 60∘ and 45∘ values are obtained via the Pythagorean theorem. The value for 45∘ should be particularly easy to remember, since √2 = 1.414 and √½ = ½√2.
The rest of this section is devoted to the Taylor series. A low-order expansion works well if the point of interest is not too far from the nearest anchor.
For most purposes, the best option is to use the Taylor[1,3] approximation anchored at zero. This requires a couple more multiplications, but the result is accurate to better than 0.07%.
If you really want to minimize the number of multiplications, we can start by noting that the Taylor extrapolation coming up from zero is better than the Taylor[0,1] extrapolation coming down from 30∘, so rather than using the closest anchor we use the 0∘ anchor all the way up to 20∘ and use the 30∘ anchor above that. This has the advantage of minimizing the number of multiplications. Disadvantages include having to remember an obscure fact, namely the need to put the crossover at 20∘ rather than halfway between the two anchors. The accuracy is better than 2.1%, which is not great, but good enough for some applications. The error is shown in figure 11.
There are many other options, but all the options I know of involve either more work or less accuracy.
The spreadsheet that produces these figures is given by reference 5.
Here are some additional facts that are needed in order to carry out the calculations discussed here.
Last but not least, we have the Pythagorean trig identity:
and the sum-of-angles formula:
If you can maintain even a vague memory of the form of equation 7, you can easily reconstruct the exact details. Use the fact that it has to be symmetric under exchange of a and b (since addition is commutative on the LHS). Also it has to behave correctly when b=0 and when b=π/2.
If we assume b is small and use the small-angle approximations from equation 5, then equation 7 reduces to the second-order Taylor series approximation to sin(a+b).
If we drop the second-order term, we are left with the first-order series, suitable for even smaller values of b:
You can use the Taylor series to interpolate between the values given in equation 4. Since every angle in the first quadrant is at least somewhat near one of these values, you can find the sine of any angle, to a good approximation, as shown in figure 10.
Copyright © 2007 jsd