Category Archives: Rough Maths

Can’t Add Up

Rough Maths 6

cantaddup

When we last looked at arithmetic, we had found that we had to make 90 repayments, and we couldn’t get an exact answer to the question of how many years that would take if we paid it every fortnight. So let’s see:

90 ÷ 26 = 90/26

This fraction is both vulgar and improper: the former means that it is a simple ratio of a/b, the latter means that the number on top is greater than that on the bottom. It’s also a tautology, because our formula means “90 divided by 26 equals 90 divided by 26”.

(As an aside: Wittgenstein thought that all of mathematics was an endlessly elaborated tautology of this nature, which, in my opinion, makes Wittgenstein as wrong about maths as as any genius has been about anything. Which is very wrong indeed.)

A proper fraction – I don’t know why fractions terminology is so snooty: perhaps it was once used to sort out the sheep from the goats – shows a whole number, giving the number of times the dividing number can go into the divided, and a fraction showing the remainder:

90/26 = 3 12/26

This is a social step upward, with none of those top-heavy fractions. But we are still left with a remainder – 12/26 – which we can’t express in terms of our set of positive and negative numbers.

We can reduce it by dividing the top and the bottom by 2 (which is allowed: trust me) giving us 6/13: another division. I have a confession to make: the number line from Rough Maths 3 was slightly deceptive. Since we had only integers, our number line is not a line in the strictest sense: it is a set of points, each 1 unit away from its two neighbours.

The question “what sort of number is 6/13” should give us an intuitive hint as to what lies between the integers on the number line: something six thirteenths of the way along the gap between zero and one.

A way of making this intuition more concrete is to express our fraction as a decimal. Decimal fractions take the way in which a positional number system can express any integer as a sum of powers of ten:

1, 10, 100, 1000, 10000 …

And extend these backwards, into negative powers of ten (just trust me on that one for now):

0.1, 0.01, 0.001, 0.0001 …

Since we can represent any integer by choosing the right set of powers of ten, we should be able to use decimals to represent any of the numbers which lie between the integers.

Shouldn’t we?

If we follow this line of argument much further, we’ll get us into surprisingly deep water, and a fair chunk of the history of 19th century mathematics, before long.

For now, we just want 6/13 as a decimal fraction. Doing this from scratch requires a peculiar form of long division: but here’s one I prepared earlier.

6/13 = 0.461538 461538 461538 …

The peculiarity of the long division is that it is cyclical: the same digits, 4, 6, 1, 5, 3, 8 will continue for as long as we care to calculate them. But this gives us something: we can now say that 6/13 is a little shy of halfway along the gap between 0 and 1, or that our 90 ÷ 26 = 3.4615.

However, we’ve also lost something: a tiny amount of accuracy. The number 90 6/13 is, by definition, exactly 90 6/13. However, 3.4615 is not: it is around 0.00004 away from the exact value.

The only fractions which can be written as non-repeating decimals in our base-10 number system are those which have a common divisor with 10: all other fractions are repeating decimals. For example, 1/2 = 0.5 and 1/5 = 0.2, but 1/3 = 0.3333… and 1/7 = 0.142857…

This isn’t important if you’re trying to measure a piece of timber which is 3 and 6/13ths of a meter long, but it matters if you are trying to get a computer to perform arithmetic on numbers which aren’t integers.

Computers represent numbers in binary, or base 2: this means that the only fractions which have a finite number of digits are those where the denominator is a power of two: 4, 8, 16, 32 and so on. All other fractions will have an indefinite repeating expansion, like 6/13. As any computer is only going to have a finite number of bits to store a value, there will be a fudge factor between the actual value and the real digital value, and this fudge factor can cause weird, slightly wrong values when the binary number is converted back to base 10.

This is one reason for why, on the inside, any computer program dealing with monetary values will count it in cents, rather than dollars: storing 20.95 as 2095 removes the possibility of rounding errors.

Leaving computers aside, we now have a way of expressing any fraction a / b (tautologically) and representing the fraction as a decimal (usually with a small fudge factor which we can make as negligible as we like).

This gets us a fairly modern, up-to-date number system which was state-of-the art in roughly 800CE, and which will start to come adrift as soon as we try to do anything like calculate the diagonal of a square.

Computus 2011

Rough Maths 5

Last year I posted a rough versification of the computus, the algorithm used to calculate the date of Easter Sunday for a given year. Possibly influenced by the date of the post, or an underestimation of how far I’ll take a daft idea, at least one person thought I’d made it all up, when in fact I’d used Augustus De Morgan’s Easter chapter in his Budget of Paradoxes.

The computus is one of the earliest examples in European culture of an algorithm: a step-by-step set of instructions for performing a calculation. It’s a massive hack, by which I mean that it’s an inelegant and hairy solution to a fairly ridiculous problem posed by the untidy arrangements of the Earth, the Sun and the Moon.

Here is the table, with workings in the third column: this spoils the layout, which is clearer in the 2010 version.

In calculating the values for 2011, I found two errors in my first version. Programming is an exercise in humility.

I Add one to the year you are given. 2011 + 1 = 2012
II Divide the year by four, rounded down. 2011 / 4 = 502
III From the centuries, take sixteen (if you can) 20 – 16 = 4
IV And divide that by four, rounded down. 4 / 4 = 1
V Add I, II and IV, then take away III, 2011 + 502 + 1 – 4 = 2511
VI Then take that value modulo seven 2551 mod 7 = 5
(Divide by seven and keep the remainder)
Subtracting from seven again: 7 – 5 = 2
VII The year’s dominical letter. 2 = B
(We’ll use it as if it’s a number.)
VIII Take I mod nineteen (if it’s zero, nineteen) 2012 mod 19 = 17
This is the year’s golden number.
Now take seventeen from the centuries, 20 – 17 = 3
IX Over twenty-five (chuck the remainder) 3 / 5 = 0
Take IX and 15 from the centuries 20 – 0 – 15 = 5
X Over three (and chuck the remainder) 5 / 3 = 1
To VIII, add ten times (VIII minus one) 17 + 10 * 16 = 177
XI Take that sum modulo thirty 177 mod 30 = 27
Add XI, X and IV and then take away III, (27 + 1 + 1 – 4) = 25
(If it’s large enough, modulo thirty) 25 mod 30 = 25
If it be twenty-four, make it twenty-five;
If twenty-five, and if VIII is more than eleven (17 > 11)
Make it twenty-six instead; 25 = 26
If it’s zero, set it to thirty.
XII The result is the epact; a good Scrabble word, 26
The age of the moon on New Years’ Day.
If the epact is less than twenty-four, (no)
XIII(b) Subtract it from forty-five (write that down)
Then subtract the epact from twenty-seven
Divide that by seven and keep the remainder:
XIV(b) If it’s zero, change it to seven.
If the epact is higher than twenty-three, (26 > 23)
XIII(b) Subtract it from seventy-five instead 75 – 26 = 49
Then subtract the epact from fifty-seven, 57 – 26 = 31
Divide that by seven and keep the remainder: 31 mod 7 = 3
XIV(b) If it’s zero, change it to seven. = 3
Then add XIII to VII (the dominical number). 49 + 2 = 51
If XIV’s more than VII, add seven more. (3 > 2) 51 + 7 = 58
XV And then take away what you got for XIV. 58 – 3 = 55
If the result is below thirty-two, (no)
Easter Sunday’s in March, and that’s the date,
Otherwise, it’s in April – subtract thirty-one. 55 – 31 = 24 April

PS This one got in the way of the promised next post about division. It’s coming.

Negatives iii – plus and minus

Rough Maths 4

This series of posts started when someone said on Twitter that he’d asked three maths teachers to give a real world example of dividing a negative by another negative: and none of them had been able to answer.

As an example, we can use one of the earliest known application of negative numbers – to represent debts. The ancient Chinese represented debts in black ink and credits in red, the opposite of modern conventions.

Suppose that I owe $36,000, and that this is represented in my accounts by

-36,000.00

I’m tightening my budget and want to reduce my fortnightly repayments to $400. I’d like see how long it will take me to clear the debt. It’s an interest-free loan, to keep things simple.

In other words, if I have a single debt of $36,000, and divide it into smaller debts of $400 that I can afford to pay off once a fortnight, how many fortnights will it take me?

-36,000 / -400 = 90

Which is about three and a half years. (More on that later.)

This might seem arbitrary: couldn’t I have expressed the debts as positive numbers and arrived at the same result? We could, but in a truly real-world example, our convention would have to match our accounting software, the banks’, the tax office, and so on.

In an important sense, the signs with which we represent credits and debits – positive and negative, or black and red, or red and black – are labels for a particular logical structure. This structure has two states (A and B, say) and maps combinations of those states onto the states themselves, so that AA and BB can be represented by A, and AB or BA by B. In other words, the idea of “sameness” is associated with A, and “difference” with B.

ABBA

There is a more technical reason for two negatives to make a positive, which is the internal consistency of our arithmetic. Let’s start with a couple of results which follow from last week’s rule that a positive times a negative gives us another negative:

-1 * 36,000 = -36,000 and -1 * 400 = -400

Now let’s suppose that my neg / neg = pos example is wrong, and that the right answer is -90:

-36,000 / -400 = -90

This implies:

(-1 * 36,000 ) / (-1 * 400) = -90

The -1s in the left-hand side cancel out, and we have

36,000 / 400 = -90

Dividing the two positives gives

90 = -90

Which is not true. If we agree on every step of the way that led us here, it’s safe to say that the starting point was false.

This kind of reasoning – called proof by contradiction or the more splendid term reductio ad absurdum – is very common in maths. It’s based on the idea that a system of mathematical reasoning must be internally consistent. The fact that arithmetic and other mathematical structures are self-consistent is not important just because it makes mathematicians happy: it also makes physical science possible, because it turns out that this type of formal self-consistency is also a characteristic of the natural world.

About the three-and-a-half year payment plan: given what we’ve covered so far, we can’t give an answer to that yet, because so far, we only have whole numbers. Next post: fractions, decimals, and why your computer is crap at arithmetic.

Don’t you use no double negatives

We already know how to add and subtract negative numbers: to add a negative like −4, we subtract its positive counterpart, 4. And to subtract −4, we add 4. What about multiplication?

Multiplication is repeated addition: instead of writing “3 + 3 + 3 + 3”, we can write “4 × 3”. This isn’t just a useful shorthand: it’s another form of abstraction, where we defined a new operation in terms of a simpler one. (I should also note that our starting point when we add 3s is 0 – this will be important later – so our addition should be “0 + 3 + 3 + 3 + 3”.)

If we don’t know how multiplication works for negative numbers, we can try to work our way back down from multiplication to addition, going from an abstract operation to a simpler one which we already understand.

Let’s start with: 4 × −3. This tells us to do “add −3” four times. We know that “add −3” is the same as “subtract 3”, so our answer will be three subtracted from 0 four times:

0 − 3 − 3 − 3 − 3
= 0 − 12
= −12

That’s simple, but what if we want to do −4 × 3? It’s simple easy to imagine reducing something by three, but what does it mean to perform an action −4 times?

There are two ways to answer this question. The first and more annoying way would be for me to just tell you. Instead, here’s an old enemy from maths class: the number line.

One way of looking at negative numbers is that they allow us to specify direction as well as size: 4 is the same size as −4 but headed in the opposite direction. (The official term is that 4 and −4 have the same absolute value.)

So 4 × −3 means: move to the left by 3, and repeat this 4 times, giving −12:

numline1

Except that I’ve left something out of the descriptions. I just claimed that our current set of numbers – formally called the integers – have both size and direction, but  I haven’t said in what direction we are meant to ‘repeat this 4 times’. I’ve just repeated it in the same direction as the 3s, to the left.

This gives us a clue about perform an addition −4 times. If multiplication by a positive number repeats the addition in the same direction as the number we’re multiplying, multiplication by a negative number repeats that addition in the opposite direction. So doing the operation “add 3” −4 times means that we subtract 3 four times.

numline2

giving for −4 × 3 the same result we got for 4 × −3: −12

We can now get an answer for the remaining combination: what is −4 × −3?

We repeat “subtract 3” −4 times, which means that we flip it over to “add 3” and repeat 4 times, which gives us −3 × −4 = 3 × 4 = 12: the same answer for a double negative which we’d expect in grammar.

numline3

In the next post, I’ll deal with the question which started this series of posts: division. And as an apology for the all the dry drawings, here is the Number Feline:

catline

Negatives (i)

There is a long history behind the introduction of negative numbers, which I am not going to deal with here. Instead, I’ll use them to demonstrate one of the methods by which mathematicians extend the concepts of number.

So far, we’ve added zero to the numbers, giving this:

0, 1, 2, 3, 4, 5, 6, 7, 8, …

These are the natural numbers. Sometimes 0 is excluded from their company, but I’m going to include it for convenience.

It’s easy to see that when you add two of these numbers, the result is always another natural number:

1 + 1 = 2
3 + 4 = 7
89 + 1 = 90

However, if we try subtracting, we run into trouble:

1 – 1 = 0 (OK)
3 – 4 = ?
89 – 1 = 88

If the number subtracted is greater than the number we are subtracting from, we can’t answer the question with any of the numbers in the original set.

One way of describing this situation is that addition is closed over the natural
numbers, but subtraction is not. “Closed” means that the operation keeps you within the domain under question: this has an appealing symmetry and elegance, and can also lead to much greater generalisations than what we’re describing today.

So there are two options here: we can say that subtracting a greater amount from a lesser amount has no answer, so Don’t Do That.

The second and more productive way is to say: OK, so far, 3 – 4 has no answer. Let’s pretend that it does, and then see how that pretend number behaves.

We’ll invent an arcane notation with which to depict our pretend number: [3-4]. Let’s also pretend that it can add and subtract in the same way that our honest, god-fearing natural numbers do, although we have to make up a pretendy rule for this. In a sum, we can expand our pretend number [3-4] into 3 – 4, and see if we get anything sensible as a result.

[3-4] + 1 = 3 – 4 + 1 = 4 – 4 = 0

[3-4] + 2 = 3 – 4 + 2 = 5 – 4 = 1

[3-4] + 5 = 3 – 4 + 5 = 8 – 4 = 4

[3-4] + 10 = 3 – 4 + 10 = 13 – 4 = 9

[3-4] + 0 = 3 – 4 + 0 = [3-4]

It seems that if we add our pretend number to any number other than zero, we can get a natural number as an answer. The other pattern that stands out is the relation between the natural number we’re adding to [3-4] and the answer:

1 -> 0
2 -> 1
5 -> 4
10 -> 9

We could construct lots of other pretend numbers which will give exactly the same results in the above as [3-4]: [7-8], [5-6], [999999-1000000]. For reasons of economy, let’s take the smallest of these, which is [0-1], and allow it to come out from behind the curtain as:

–1

And once we’ve allowed a single negative number to take off its brackets, the rest follow. Every expression like 3 – 4 can be expressed by [3-4] and reduced to its lowest form:

[0-2] = –2
[0-3] = –3
[0-4] = –4
[0-5] = –5

Both addition and subtraction are now closed, since any expression X + Y or X – Y will have a value Z which is also from our set.

We could also say that subtraction of a number N is the same as addition of −N. This means that addition and subtraction are actually the same operation.

Negative apples

The idea of negative numbers met with resistance: if natural numbers refer to collections of Things, then what can a negative number stand for? Zero can mean “no apples”, but what could be represented by −1 or −2 apples? You can get around this by regarding −1 as an operation, so that it means “take one apple away”. This did not convince everyone, and there were still a few holdouts against negatives up until the 19th century.

The other way of looking at negative numbers, and the one which was really responsible for their adoption, was that they give a natural way to represent credits and debits.

The Invention of Zero

[Rough Maths 1 – a series of posts inspired by Sean M Elliott’s Rough Science. Note: I am not a mathematician. At best I’m a keen amateur.]

What is a number? This seems like a dumb question, as numbers are something we all learn about in pre-school. However, it’s a question which has had different answers over the last couple of thousand years, and looking at the different answers which mathematicians have given to it is a good way to introduce both the history of mathematics and at the same time, explain some fundamental ways in which mathematics works.

The history of mathematics is in itself a strange idea, as maths is thought of as the one subject where you can be definitely right or wrong. How can such a discipline have a history? When mathematicians – and maths teachers – are so certain of the truth of their results, what can change? The invention of zero is one of the earliest examples of this process.

Rough Maths 1

This guy’s wall is an example of the simplest way of recording numbers: tally marks. It’s not the most basic – he’s scratching every fifth mark across the preceding four, making bundles which are easier to count – but the idea is: one mark for each thing you’re counting. This method has two problems: you run out of room quickly, and there’s no convenient way to do arithmetic. There is no way to add two tallies apart from counting all the marks in both of them.

Unfortunately for school students ever since, Roman numerals were a way of solving the first problem which made the second problem much worse. It’s thought that they were based on shepherds’ tally sticks, with the addition of new signs – V, X, L, C, D, M – which behave like tally marks carrying higher values – 5, 10, 50, 100, 500 and 1000. They save space – the prisoner could write his sentence as CVI – but they make arithmetic extremely difficult.

The number systems which replaced systems like the Roman are called place-value systems. They were invented independently in many parts of the ancient world, but the version we use came from India to the Arabic world and then to Europe in the 12th century. In this place-value systems, the digits 1-9 represent different values according to the position in which they are found in the number. The leftmost column represents ones, the second represents tens, and so on.

This requires two big steps forward in our ideas of number. The first is that a symbol, such as 1, can represent different numeric values depending on where it appears.

If we break the prisoner’s tally into powers of ten, it can be written with two digits: 1, representing 100, and 6. It turns out that every round number can be broken into powers of ten in this way.

The problem with such a system us that if we write 1 hundreds and 6 ones as 16, it is impossible to then distinguish it from 1 tens and 6 ones. What we need is a placeholder to show that there are no tens.

That placeholder is zero. It might seem like it’s just a workaround to make place-value notation work, but it is the first of our additions to the numbers.

Numbers as tally marks are always counts of something: zero was a disquieting idea for philosophers because it seems to be making a something out of nothing. Zero is not “no sheep” or “no years” or “no bushels of grain”. Or, if it is, it is also none of an impossible encyclopaedic list: “no eels, no galaxies, no words, no hailstorms, …” This is the beginning of a process of abstraction which will continue for centuries.