---
# System prepended metadata

title: Using Computers

---

# Using Computers

([home](https://github.com/alexhkurz/introduction-to-numbers/blob/master/README.md) ... [previous](https://hackmd.io/@alexhkurz/SJZTQ9moL) ... [next](https://hackmd.io/@alexhkurz/Bk2c2C2oL))


## Introduction

In this and the coming sessions (see [here](https://hackmd.io/@alexhkurz/Bk2c2C2oL) and [here](https://hackmd.io/@alexhkurz/SkABF8ajI)) we will see how computer programs can help us to push our mathematical investigations. 

We will also use this opportunity to learn the beginnings of the Python programming language, which is one of the most popular languages in cutting edge applications of data science, machine learning and artificial intelligence. So well worth a detour.

In the [previous session](https://hackmd.io/@alexhkurz/SJZTQ9moL) we filled in the table

|+|0| 1| 2| 3|
|:---:|:---:|:---:|:---:|:---:|
| 0 | 0 |1 | 2|3 
| 1 | 1| | |
| 2 | 2|| |
| 3 | 3| | |

in different ways. 

We paid attention that all the different ways, while representing different rules of computation, respect the basic laws of arithmetic, namely that $0$ is the neutral element, that $+$ has inverses (ie there is a minus) and that $+$ is associative and commutative. In other words, we made sure that every table represents a [group]().

The laws of a group are important because they allow us to simplify computations in a familiar way. For example, the following computation with ordinary numbers is based on all of the group laws.
\begin{align}
9+89+7-89+8+3 &= 9+89-89+7+8+3\\
&= 9+7+8+3\\
&= 9+7+3+8\\
&= 9+10+8\\
&= 10-1+10+8\\
&= 10+10+8-1\\
&= 27
\end{align}

**Exercise:** Explain how each step uses one or more of the laws of neutral element, inverses, associativity and commutativity. [Hint: To properly explain associativity, you have to put in the parentheses, which we commonly drop because we are already so used to using associativity that we do not even notice it.]


## Checking equations

With the methods, we learned so far, this takes quite some work and it is difficult to know whether or not some mistakes crept in.

Also, it is difficult to get a handle on the following question.

**Question:** How many ways are there to define an addition on 4 numbers?

It is time to expand our methods of investigation. How can we make progress?

There are two obvious ways forward:

- We can use computers to help us navigate the growing amount of data.
- We can find patterns that drastically reduce the size of the space of possibilities.

While mathematicians prefer the second method, it is often good to combine both. In particular, the first may help with the second (and the other way round).

After [installing Python](https://www.python.org/downloads/) download from the folder [src](https://github.com/alexhkurz/introduction-to-numbers/tree/master/src) the program`check_group.py`. Run (in an IDE or from terminal)

    python check_group.py
    
(This program requires Python 3, which should be installed by default ... you can also try `python3 check_group.py`.) 

If you run the program you should get

	0 1 2 3
	1 2 3 0
	2 3 0 1
	3 0 1 2
	is associative

You can conclude from this that the table does constitute a valid definition of addition in the sense that it is associative, has a neutral element and inverses and is commutative.

**Activity:** Why is it obvious from the table that it has a neutral element and inverses and is commutative?

We will study the program in more detail in the [next session](https://hackmd.io/@alexhkurz/Bk2c2C2oL). For now it is enough to know that you can change the table

	table = [
	    [0,1,2,3],
	    [1,2,3,0],
	    [2,3,0,1],
	    [3,0,1,2]
	]

in the program. This should help with the following exercises.

**Exercise:** How many tables on 4 elements that are associative, have a neutral element and inverses and are commutative can you find? 

**Homework:** Can you organise your search for tables in a systematic enough way, so that you are sure you found all tables that exist?

