Basic Mathematics - Number Sets and Operators

Words
871
Reading
4 min
10y
Listen to this post
~6 min

Numbers are the alphabet of Mathematics. Operators (+ - ÷ ×) manipulate numbers. The combination of numbers and operators derives abstract relationships that can be applied to any specific concept. 3 apples + 2 apples = 5 apples. Or bananas, or people, or planets. In what context you attach a meaning to the numbers is up to you. The underlying mathematical principles stay the same. Thus the beauty of mathematics.

Classification of Numbers

1. Natural Numbers
ℕ = {0, 1, 2, 3, 4...}

Also known as whole numbers. One can apply all operators (+ - ÷ × a2 √a) to all number sets, however Natural Numbers are most commonly associated with counting and addition.

2. Integers
ℤ = {...-2, -1, 0, 1, 2...}

One would assume that the abbreviation for Integers should be "I", however the great mathematicians Carl Gauss and Leonhard Euler popularised ℤ from 'Zahlen' (German for 'Numbers'). The convention has stuck around since.

In mathematics sometimes ℤ+ will be used to denote the set ℤ+ = {1, 2, 3, 4...} which is different than ℕ = {0, 1, 2..}. Difference being that 0 is included in the Natural number set.

When dealing with integers in programming I'm most comfortable using the addition (+), subtraction (-) and multiplication (*) operators knowing I won't run into trouble outside the number set.

In mathematics all numbers fall into sets. A set is defined as a collection of items of the same kind.

3. Rational Numbers
ℚ = {...-2, -1, -0.5, 0, 0.225, 1/3, 1, 2, 10/4, 2.55, 30/11, 4, 5...}

All numbers that can be expressed as a Quotient (thus the ℚ notation) or fraction between two integers are Rational Numbers. This includes all decimals that terminate. By termination I mean decimals which have no repeating pattern. For example 6.24, which can be written as 624/100.

4. Real Numbers

ℝ = {...-1, 0, 1, e, π, 22/6, 7.333333.., 8, 9, 10.11, ...}

Last set is "Rational" Numbers. This suggest that we have numbers that are "Irrational".
Logically if a Rational Number is a number that can be written as a fraction (quotient) between two integers, the definition of an Irrational Number is a number that can not be written as a fraction between two integers.

The most famous example of an irrational number is √2. Pythagoras proved the immortal right-angle triangle theorem: a2 + b2 = c2. From this it follows that the diagonal of a square with side 1 will be √2. Calculating √2 ≈ 1.414. But 1.1412 = 1.999396. When we reverse the process we don't get exactly 2 but an approximation.
π is the other famous example or an Irrational Number. π is the ratio (or quotient) of the circumference of a circle to its diameter. You can never carry out the division completely.

Putting all Irrational numbers in perspective the resulting set is: Real Numbers. It is the set of all rational and irrational numbers together.

Mnemonics
I have my own mnemonic to remember the ℕ, ℤ, ℚ, ℝ sequence. I imagine New Zealand. But when I look at the map I see a big QR code instead of the country. Thus NZQR.
Natural, Zahlen (Integers), Quotents (Rational), Real is another way to remember.

Further Number Sets
Of course there are more number sets such as Complex Numbers which introduces the imaginary unit i, such that i2 = -1 (or i = √-1) and also Quaternions defined as 3 Dimensional Imaginary numbers and introducing i, j and k as the fundamental Quaternions. All this goes way beyond basic mathematics so I'm not going deeper in that rabbit hole. Just worth noting that there's always more for the curious.

Operators and Precedence

The most fundamental operator is addition (+). From there multiplication (×) is just addition on steroids. (2 + 2 + 2 + 2 + 2 = 2*5) From there exponentiation (an) is just multiplication on steroids. (2 * 2 * 2 * 2 * 2 = 25)

Same applies for subtraction (-), division (÷), and rooting (n√a or a1/n). These are just addition, multiplication and exponentiation in reverse.

Precedence
When manipulating numbers in we have precedence laws. Exponentiation/rooting has precedence over multiplication/division which has precedence over addition/subtraction.

For example in this expression: 6×22 + 12. First we carry out the exponentiation: 6×4 + 12, then multiplication: 24 + 12, then addition: 36

One way to superimpose a different precedence is by putting in brackets (). The calculation in the brackets must always be carried out first.
Then (6×2)2 + 12 = 122 + 12 = 144 + 12 = 156

In short:
an >>> × >>> +
Exponent first, multiplication second, addition third.

Operational Laws

On top of precedence we have some operational wiggle room with addition and multiplication.

First the commutative law. It means that a + b = b + a [or a × b = b × a].
Second the associative law. There (a + b) + c = a + (b + c) [same for multiplication]

Conclusion
This sums up todays article. A good refresher of some math fundamentals and what it is all based on. How we can classify all numbers out there and what can we do to manipulate the numbers.

Have a great day everyone and don't forget to smile :D