## Wednesday, June 17, 2009

### Using Just Addition and Negation to Create All Mathematical Operations

Addition, Subtraction, Division, Multiplication, and Negation (Negative numbers); these are the basic operations we all learned in grade school. Truth be told you do not really need them. No, your grade school teacher did not lie to you or teach you something pointless (at least in this case). These operations make great short hand, but are not really needed.

You can create all of the operations you know from grade school to college level (including PhD level) with just simply using Addition and Negation. Given a set of numbers (Real or Complex), you can create out of the simple operation of Addition (+) and Negation (-x, where x is a number) any other operation you can thing of. For example, say you have set of 5 things and lose 2 of them, to find out how many of the set you still have you take 5 and Subtract 2 of them to get 3; but you could have taken 5 and Added the Negative value of 2 to them to get 3. You can think of Subtraction as simply the Addition of a Negative amount of something.

In more symbolic form:
x - y = x + -y
where x and y are members of a set of numbers

The same is true for Multiplication. Given 5 sets of 3 things, you have a total of 15 things (5 * 3 = 15). You could also say that given 5 sets of 3 things, you Add 5 to 5, 3 Times giving you 15 (5 + 5 + 5 = 15).

Again in more symbolic form:
x * y = x + ... + x
where ... represent y number of + x (I know the symbolic x + ... + x does not really look good for 0 or 1, but I do not want to introduce a function)

You may be thinking what about Negative numbers in Multiplication, well Negative numbers are not really any thing special. Say you owe 5 people 3 bucks and have no money, you have Negative 15 dollars (5 * -3 = -5 + -5 + -5 = -15). In the symbolic above either x or y can be Negative numbers.

Likewise, Division can be thought of as Multiple Subtraction, which is really just Multiple Addition of Negative numbers (as shown above). An example maybe needed, say you have 15 of something and need to give an equal number of the thing to 3 people (think of Pirates splitting up gold). Well, you need to give 1 of the thing to each person a number of times until you run out of them, meaning at the end you have give 5 of the thing to each of the 3 people (15 = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 3 + 3 + 3 + 3 + 3). In another way, you have 15 of something and Subtract 3 from the 15 until you have 0 left (15 - 3 - 3 - 3 - 3 - 3 = 0, or 3 + 3 + 3 + 3 + 3 = 15). Or you have 15 of something and Add Negative 3 to the 15 until you have 0 left (15 + -3 + -3 + -3 + -3 + -3 = 0). All of these ways of thinking give the same result, 5 sets of 3. That is what Division really is, finding how many equal sets (if you are working with whole numbers) can be made out of a number.

In more symbolic form:
x / y = z + ... + z
where z is a number from the same set as x and y and ... represent y number of + z (again I know the symbolic z + ... + z does not really look good for 0 or 1, but I am trying to not introduce any new functions)

So what about Dividing by 0? Well as we know Dividing by 0 is undefined and here is why. Say you have 15 of something and need to split it equal among 0 groups what are you really doing? You are saying that you can take 0 groups of something and Add them up to be 15 of something. This is impossible since 0 + 0 = 0 and likewise 0 + ... + 0 = 0, where ... can be any number of + 0. Also, we all know that x * 0 = 0, since 0 Added to 0 an x number of times would still be 0 (as shown above).

What does any of this have to do with Programming? Well there are CPUs called RISC CPUs, RISC stands for Reduced Instruction Set Computer. The goal of RISC to have as few instruction as possible. On the computation side I would argue that all you need is Addition and Negation. My argument would be based on this post, as I have shown all of the mathematical operations we know can be express with just Addition and Negation operations. Thus, for computations RISC would only need the ability to Add and Negate.