Simple Arithmetic

Addition, division, subtraction and multiplica...
Addition, division, subtraction and multiplication symbols (Photo credit: Wikipedia)

There periodically appears on the Internet an arithmetic type of puzzle. Typically it will be a string of small natural numbers and a few arithmetic operations, such as “3 + 7 x 2 – 4” and the task is to work out the result.

The trick here is that people tend to perform such a series of calculations strictly from left to right, so the sequence goes:

3 + 7 = 10, 10 x 2 = 20, 20 – 4 = 16. Bingo!

Most mathematicians, and people who remember maths from school would disagree however. They would calculate as follows:

7 x 2 = 14, 3 + 14 = 17, 17 – 4 = 13. QED!

Why the difference? Well, mathematicians have a rule that states how such calculations are to be performed. Briefly the calculations is performed from left to right, but if a multiplication or division is found between two numbers, that calculation is performed before any additions or subtractions. In fact the rule is more complex than that, and a mnemonic often used to remember it is “BODMAS” or “BEDMAS” (which I’m not going to explain in detail here. See the link above).

This rule is only a convention and so is not followed everywhere, so there are various “correct” answers to the problem. Also, there are still ambiguities if the conventions are applied which could cause confusion. However, most people with some mathematical training would claim that 13 is the correct answer.

Interestingly, computer programming languages, which are much stricter about such things, codify the precedence of operations in a calculation exactly, so that there can be no ambiguity. It is the programmers task to understand the precedence rules that apply for a particular language.

example of Python language
example of Python language (Photo credit: Wikipedia)

In most cases the rules are very, very similar, but it is the documentation of the language which describes the rules of precedence, and wise programmers study the section on operator precedence very closely.

There are ways of specifying an arithmetic problem uniquely, and one of those (which is sometimes of interest to programmers) is “Reverse Polish Notation“. Using this my original puzzle becomes “3 7 2 x + 4 -” which looks odd until you understand what is going on here.

Illustration of postfix notation
Illustration of postfix notation (Photo credit: Wikipedia)

Imagine that you are traversing the above list from left to right. First you find the number “3”. This is not something you have to do, like “+”, “-“, “x” or “/”, so you just start a pile and put it on the bottom. The same goes for “7” and “2”, so the pile now has “3” on the bottom and “2” at the top and “7” in the middle.

Next we come across “x”. This tells us to do something, so we pull the last two things off the pile and multiply them (7 x 2 = 14) and stick the result, “14” back on the stack which now contains “3” and “14”. The next thing we find is “+” so we pluck the last two things off the pile “3” and “14” and add them, putting the result “17” back on the (empty) pile.

Next up is “4” which we put on the pile, and finally, we have “-“, so we pull the two last elements from the pile (“17” and “4”) and subtract the second from the first, giving “13” (Yay!) and that is the answer which we put back on the stack. The stack now contains nothing but the answer.

This looks confusing, but that may be because we are used to the conventional left to right way of doing things. It is actually easier for a computer to understand the RPN version of the puzzle and there are no ambiguities in it at all. Technically, it’s a lot simpler to parse than the conventional version.

Image for use in basic articles dealing with p...
Image for use in basic articles dealing with parse trees, nodes, branches, X-Bar theory, linguistic theory. (Photo credit: Wikipedia)

Parsing is what happens when you type a command into a computer, or you type something complex, such as a credit card number into the checkout section of a web site. The computer running the web site takes your input and breaks it up if necessary and checks it against rules that the programmer has set up.

So, if you type 15 numbers or 17 numbers into the field for the credit card number, or you type a letter into the field by mistake, the computer will inform you that something is wrong. Infuriatingly, it may be not be specific about what the trouble is!

Español: Un Guru meditation en una amiga
Español: Un Guru meditation en una amiga (Photo credit: Wikipedia)

Anyway, back to the arithmetic. It grates with me when people make simple arithmetical errors and then excuse themselves with the phrase “I never was much good at maths at school”! That may well be true, but to blame their problems with arithmetic of the whole diverse field of mathematics.

It’s like saying “I can’t add up a few numbers in my head or on paper because I missed the class on elliptic functions“! It’s way over the top. For some reason people (especially those who can’t get their head around algebra) equate the whole of mathematics with the bit that they do, which is the stuff about numbers, which is arithmetic.

English: Weierstrass p, Stylised letter p for ...
English: Weierstrass p, Stylised letter p for Weierstrass’s elliptic functions from Computer Modern font (obtained by TeX command \wp) Deutsch: Weierstrass p, stilisierter Buchstabe p für die elliptische Funktion von Weierstrass in der Computer-Modern-Schrift (generiert durch das TeX-Kommando \wp (Photo credit: Wikipedia)

As we evolved, we started counting things. It’s important to know if someone has got more beans than you or that you have enough beans to give everyone one of them. We invented names for numbers and names for the things (operations) we did on them.

We did this without much thought about what numbers actually are. We as a species have only relatively thought deeply about numbers fairly recently, and we only discovered such things as real numbers and geometry in the last couple of thousand years so it is not surprising that the average brain has yet to expand to cope with the more advanced mathematical concepts.

Graphic showing the relation between the arith...
Graphic showing the relation between the arithmetic mean and the geometric mean of two real numbers. (Photo credit: Wikipedia)

This could be why so many people these days equate fairly simple arithmetic with mathematics as a whole – our brains are only now coming to grips with the concept that there is more to maths than simply manipulating numbers with a very few simply operations.

It may be that the average human brain never will get to grips with more advanced maths. After all, people can survive and thrive in the modern world with on a rudimentary grasp of mathematics, the arithmetic part.

English: the arithmetic sequence a_n=n Deutsch...
English: the arithmetic sequence a_n=n Deutsch: die arithmetische Folge a_n=n (Photo credit: Wikipedia)

Some human brains however do proceed further and much of modern society is the result of mathematics in its wider sense applied to the things that we see around us. For instance,  we could not have sent men to the moon without advanced mathematics, and technology relies heavily on mathematics to produce all sorts of things. It’s a good things that some brains can tell the difference between the field of arithmetic and mathematics as a whole.

English: A .gif animation of the vibration cor...
English: A .gif animation of the vibration corresponding to the third smallest eigenvalue of the electric pylon truss problem from EML 4500 HW 6. (Photo credit: Wikipedia)

Numbers are fascinating

A little image of aleph_0, smallest infinite c...
A little image of aleph_0, smallest infinite cardinal (Photo credit: Wikipedia)

Numbers fascinate me. What the heck are they? They seem to have an intimate relationship with the “real world”, but are they part of it? If I heave a rock at you, I heave a physical object at you. If I heave two rocks at you, I heave real objects at you. It’s a different physical experience for you, though.

If I heave a third rock at you, again, it’s a different qualitative experience. It’s also a different qualitative experience from having one rock or two rocks thrown at you.

Glyder Fawr
Glyder Fawr (Photo credit: Wikipedia)

Numbers come in three “shapes”. There are cardinal numbers, which answer questions like “How many rocks did I throw at you?” There are ordinal numbers, which answer questions like “Which rock hit you on the shoulder?” Finally there are nominal numbers, which merely label things and answer questions like “What’s you phone number?”

As another example, in the recent 10km walk which I took part in, I came sixth (ordinal) in my age division. That sounds good until I admit that there were only seven (cardinal) entrants in that division. Incidentally, my bib number was 20179 (nominal).

Cardinal numbers include the natural numbers, the integers and the rational numbers and the real numbers (as well as more esoteric numbers). For instance the cardinal real number π is the answer to the question “How many times would the diameter fit around the circumference of a circle?”

It’s a bit more difficult to relate ordinal numbers with real numbers, but the real numbers can definitely be ordered – in other words a real number ‘x’ is either bigger than another real number ‘y’, or vice versa or they are equal. However, there are, loosely speaking, more real numbers than ordinals, so any relationship between ordinal numbers and real numbers must be a relationship between the ordinal numbers and a subset of the real numbers.

English: Example image of rendering of ordinal...
English: Example image of rendering of ordinal indicator º Italiano: Immagine esemplificativa della resa grafica dell’indicatore ordinale º (Photo credit: Wikipedia)

Subsets of the real numbers can have ordinal numbers associated with them in a simple way. If we have a function which generates real numbers from a parameter, and if we feed the function with a series of other numbers, then the series of other numbers is ordered by the way that we feed them to the function, and the resulting set of real numbers is also ordered.

So, we might have a random number generator from which we extract a number and feed it to the function. That becomes the first real number. Then we extract another number from the generator, feed it to the function and that becomes the second real number, and so on.

The random map generator provides a limitless ...
The random map generator provides a limitless supply of colourful terrains of various themes. Open island maps, like this one, allow players to use airstrikes. Cavern maps have an indestructible roof which cannot be passed. (Photo credit: Wikipedia)

What we end up doing is associating a series of integer ordinal numbers with the generated series of real numbers. These ordinal numbers are associated with the ordered set of real numbers that we create, but the real numbers don’t have to be ordered in terms of their size.

Nominal numbers such as my bib number are merely labels. They may be generated in an ordered way, though, as in the case of my bib number. If I had registered a split second earlier or later I would have received a different number. However, once allocated they only serve to show that I have registered, and they also show which event I registered for.

On the occasion that I took part there were two other events scheduled : a 6.5km walk and a half marathon. My bib number indicated to the marshals and officials which event I was taking in and which way to direct me to go.

I’m not a mathematician, but it seems to me that ordinal numbers are more closely aligned to the natural numbers, the positive integers, than to any other set of numbers. You don’t think of someone coming 37 and a half position in a race. Indeed if two people come in at the same time they are conventionally given the same position in the race and the next position is not given.

English: Selby Apartments, located on 37th Str...
English: Selby Apartments, located on 37th Street, 37th Avenue, and Marcy Street in Omaha, Nebraska. The view is from 37th Avenue and Marcy, looking northeast. At left is 825 S. 37th Ave; at right is 3710 Marcy. (Photo credit: Wikipedia)

There’s a fundamental difference between natural numbers or the integers, or for that matter the rational numbers and the real numbers. The real numbers are not countable : they can’t be mapped to the natural numbers or the integers. The rational numbers can, so can be considered countable. (Once again, I’m simplifying radically!)

Natural numbers and integers are related to discrete objects and other things. The number of dollars and cents in your bank account is a discrete amount, in spite of the fact that it is used as real number in the bank’s calculations of interest on your balance. If I toss two rocks at you that is a discrete amount.

English: Causal loop diagram (CLD) example: Ba...
English: Causal loop diagram (CLD) example: Bank balance and Earned interest, reinforced loop. Diagram created by contributor, with software TRUE (Temporal Reasoning Universal Elaboration) True-World (Photo credit: Wikipedia)

Even I tip a bucket of water over you, I douse you in a discrete number of water molecules (plus an uncertain number of other molecules, depending on how dirty the water is). However the distance that I have to throw the water is not a discrete number of metres. It’s 1.72142… metres, a real number.

At the level at which we normally measure distances distances don’t appear to be broken down into tiny bits. To cover a distance one first has to cover half the distance. To cover half the distance one must first cover one quarter of the distance. It is evident that this halving process can be continued indefinitely, although the times involved are also halved at each step.

This seems a little odd to me. Numbers are at the basis of things, and while numbers are not all that there is, as some Greek philosophers held, they are important, and, I think, show the shape of the Universe. If the Universe did not have real numbers, for example, then it would be unchanging or perhaps motion would be a discrete process, like movements on a chess board.

If the Universe did not have any integers, the concept of individual objects would not be possible, since if you could point at an object you would have effectively counted “one”. In other words we need the natural numbers so that we can identify objects and distinguish one from one another, and we need the real numbers so that we can ensure that the objects don’t all exists at the same spot and are, in fact separated from one another.

Visualisation of the (countable) field of alge...
Visualisation of the (countable) field of algebraic numbers in the complex plane. Colours indicate degree of the polynomial the number is a root of (red = linear, i.e. the rationals, green = quadratic, blue = cubic, yellow = quartic…). Points becomes smaller as the integer polynomial coefficients become larger. View shows integers 0,1 and 2 at bottom right, +i near top. (Photo credit: Wikipedia)