Numbers aren't simply numbers. They can be categorised and this always helps computer scientists and mathematicians to make sense of them. We are learning ...- About number systems
So that we can ...- Explain the features of different number systems ...
- Natural numbers - Integer numbers - Rational numbers - Irrational numbers - Ordinal numbers - Describe simple set theory
- Set notation - Finite / Infinite sets - Set comprehension (in Python) - Compact set representation - Set operations (cartesian product, membership, union, intersection, difference) - Subsets, proper subsets, countable sets - Permutations
There are 7 recognised set of numbers, some of which are given their own, special symbols ... - Natural numbers (ℕ)
- Integer numbers (ℤ)
- Real numbers (ℝ)
- Rational numbers (ℚ)
- Irrational numbers (no accepted symbol, but often ℚ \ ℝ or ℙ)
- Imaginary numbers (𝕀)
- Complex numbers (ℂ)
You may wish to go to the Maths is Fun website to find out more! We can also describe numbers in a set in terms of their ... - Ordinality (ordering)
- Cardinality (counting)
- Nominality (naming)
A set is a mathematical term used to represent a group of related 'things'.
Set comprehensionSo, a set is a collection of ordered values where each value appears only once in the set. The values in the set are sometimes referred to as elements, objects or members. Defining a set is called set comprehension or set building.For example ... A = { 𝑥 | 𝑥 ∈ ℕ ∧ 𝑥 ≥ 5 } where ... - A is the name of the set
- the curly braces { } represent the contents of the set
- 𝑥 represents the actual values of the set
- the pipe | means 'such that', meaning that the equation after the 𝑥 denotes the values of 𝑥
- ∈ means 'is a member of'
- ℕ is a set of all of the natural numbers, e.g. {0, 1, 2, 3, ...} (see below)
- ∧ means 'logical and'
- ≥ 5 means greater than or equal to 5.
So we could 'write' this set comprehension as 'The set A is defined in terms of 𝑥 such that 𝑥 is a member of the set of natural numbers, ℕ and 𝑥 is greater than or equal to 5'. The actual members of A (called the alphabet and given the symbol capital Greek sigma, Σ) are {5, 6, 7, 8, ...}. Notice the ellipsis (...) which indicates that the sequence continues, to infinity.
Finite and infinite setsThe ellipsis seen in the previous section indicates that the sequence of members continues for ever. This is called an infinite set. It is possible to define a finite set with a limited number of members. The first example in the previous exercise is a finite set since it only has 8 members.All finite sets have cardinality (see above) which means their elements can be counted using natural numbers (ℕ). The cardinality of a set can also refer to the size of the set and is given the symbol # or denoted using pipe symbols around the set name, for instance |A| (magnitude). These are also referred to as countable sets. Infinite sets do not have cardinality since we do not know the total size of the set. However, for some infinite sets, it's still possible to count the elements, even though you would never reach the end. These are described as countably infinite sets as their elements can be counted off against the natural (countable) numbers.Interesting note : The set of real numbers (ℝ) is not countable.
Empty sets and empty stringsThere is a special set known as the empty set which is represented by either { } or the symbol ∅. The empty set has no elements. - An empty set has a cardinality of zero. It does not contain zero. Consider ...
Records = { } # Records = 0 ... or ... |Records| = 0 - An empty set is
*not*the same as an**empty string**which is denoted using the lowercase epsilon, ε. A set can contain an empty string - it is a 'thing'. Quiet = {ε} # Quiet = 1 ... or ... |Quiet| = 1
Not really Compact set notationWhen defining potentially non-numeric sets, such as words in a language, things can get a little trickier. In this instance, This is a little theoretical, but read the examples s ... l ... o ... w ... l ... y and you'll be OK :) - Using alphabets
Ifis a formal language (a possibly infinite set of finite length strings), the alphabet of**L**, given by the Greek letter sigma (**L****Σ**), is the set containing all symbols which can occur in any string in. For any language, the set of all strings over the alphabet of length**L****n**is given by**Σ**^{n}. - For the binary 'language',**Σ**= {0,1} - All two symbol length words are given by**Σ**= {00,01,10,11}^{2} - All three symbols length words are given by**Σ**= {000,001,010,011,100,101,110,111} ... and so on^{3} Sets defined in this way are usually finite (although it is possible to define infinite sets using a special notation called a*Kleene Star*). - Using formal grammar
We've seen examples of this with sets containing numbers (usually denoted by 𝑥). However, what if the set comprehension operated on a symbol instead? Consider the following examples ... - The set { a^{n}| n ∈ ℕ } represents the infinite set { a, aa, aaa, aaaa, aaaaa, ...} - The set { a^{n}| n ≥ 0 } represents the infinite set { ε, a, aa, aaa, aaaa, aaaaa, ...} - The set { 0^{n}1^{n}| n ≥ 1 } represents the infinite set { 01, 0011, 000111, 00001111, ...}
Set operationsIt is possible to perform operations on sets. __Cartesian product__ The cartesian product of two sets is the set of all possible ordered pairs whose first component is a member of the first set and whose second component is a member of the second set. For instance ... A = {1, 2, 3} B = {A, B} A x B = {{1, A}, {1, B}, {2, A}, {2, B}, {3, A}, {3, B}} A x B = { 𝑥, 𝑦 | 𝑥 ∈ A ∧ 𝑦 ∈ B } The cardinality of the resulting set is the product of the cardinalities of the two individual sets.__Membership__ The symbol ∈ represents set membership. For instance 𝑥 ∈ A literally means '𝑥 is a member of set A'. Conversely, the symbol ∉ means 'not a member of'. A = {5, 6, 7}, 6 ∈ A, 4 ∉ A__Union__ This operation joins two sets together so that the new set is a combination of both original sets, i.e. which belong to one set**or**the other. The union operation is given the symbol ∪.*Be careful*, however, because 'each value in a set can only appear once', therefore, if there are common elements in the two sets, the union of those sets*will only contain the item once*. A = {0, 1, 3, 5, 7, 9} B = {0, 2, 4, 6, 8} A ∪ B = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} Notice that the element 0 appears only once in the union of A and B.__Intersection__ This operation joins two sets together so that the resulting set contains elements common to both, i.e. those which belong to one set**and**the other. Again, be aware that the resulting elements can appear only once in the new set. The intersection operation is given the symbol ∩. A = {1, 3, 4, 6, 7, 8} B = {0, 3, 5, 6, 7, 9} A ∩ B = {3, 6, 7}__Difference__ Bet you can guess this one! The difference operation joins two sets together so that the resulting set contains elements which are in either set but not in the intersection. Difference is given the symbol ∆ or ⊖. A = {1, 3, 4, 6, 7, 8} B = {0, 3, 5, 6, 7, 9} A ⊖ B = {0, 1, 4, 5, 8, 9}
SubsetsWhen all elements of one set are contained in another, it is said to be a subset, given the symbol ⊆ (notice the line at the bottom). If the subset has fewer elements than the other set, it can be further defined as a proper subset, given the symbol ⊂ (notice the absence of the line at the bottom). We can also declare sets as not being subsets (⊈) or not being proper subsets (⊄).
Take a moment to work through these statements to make sure you understand them. Note that if one set is a proper subset of another, it is also a subset. If one set is a subset of another but is not the same set then it must be a proper subset. (A ⊆ B) ∧ (A ≠ B) → A ⊂ B
Set comprehensions in PythonOK - how about getting Python to do some of the work for us? Python has some pretty powerful set comprehension operations which will perform many of the tasks we have looked at already. One odd thing about Python sets is that they are not ordered. The set data type is optimised for set operations not iterability. Use a list or a dictionary for that.Before you start these exercises, create a blank word processed document with a suitable header and footer. Record what you have done and what you have learnt using a combination of screenshots and written explanations.
Set permutationsA permutation is another word for modification, shift or transformation. Python can perform set permutation operation on lists. For instance, the complete set of permutations of `1` , `2` and `3` are ...`1, 2, 3` `1, 3, 2` `2, 1, 3` `2, 3, 1` `3, 1, 2` `3, 2, 1` This is easier to do in Python that it might first seem, by using our old friend the `itertools` module! Before you start these exercises, create a blank word processed document with a suitable header and footer. Record what you have done and what you have learnt using a combination of screenshots and written explanations.
How about these? - Choose one research area and write / draw / dance about it ...
a) Find out about the irrational numbers called 'Pi', 'e', ‘Euler’s number’ and ‘the Golden Ratio’. b) Apart from those of 2, 3 and 99, identify some other square roots that are irrational numbers. c) Find out which number types are supported as data types in Python. d) Why do programming languages often have several different data types for an integer? e) The Ancient Greeks did not recognise the number zero. How did their number systems work without it? - Write a Haiku about number systems or sets. Remember, a Haiku has three lines; 5 syllables, 7 syllables and 5 syllables. Often, the first two lines are upbeat and connected and the last line gives a little twist in the tale. The best ones will go on display.
- Two sets of numbers we haven't mentioned are the
**Algebraic Numbers**(𝔸) and the**Transcendental Numbers**. What are they? Give some real world examples. - The characters used to represent the sets are called "double struck characters" or "blackboard font". Read the Wikipedia article about this, for a bit of fun.
- Full(ish) list of set symbols.
- Great website which produces automatic set stuff.
END OF TOPIC ASSESSMENT |