Weeks
Mathematics 1Week 1 · Sets, Relations and Functions
Week 1 Notes

Mathematics for
Data Science 1

Set theory: the number system, sets and their operations, relations and their types, and functions and their types.

11 chapters87 worked examples~105 min read
Number systemSets and operationsRelationsFunctions

Chapters

  1. 01Natural Numbers and IntegersCounting, operations, factors, primes
  2. 02Rational NumbersFractions, gcd, density
  3. 03Real and Complex NumbersIrrationals, the number family
  4. 04Sets: The BasicsMembership, subsets, power set
  5. 05Building Sets and Set OperationsComprehension, intervals, ∪ ∩ −
  6. 06Sets in ActionComprehension examples, Venn counting
  7. 07RelationsCartesian product, binary relations
  8. 08Types of RelationsReflexive, symmetric, transitive, equivalence
  9. 09FunctionsDomain, codomain, range, graphs
  10. 10Types of FunctionsInjective, surjective, bijective
  11. 11Week 1 Summary SheetAll topics
01
Number system · Part 1 of 3

Natural Numbers and Integers

Mathematics starts with counting. In this topic we build the first two number sets, N\mathbb{N} and Z\mathbb{Z}, and see what the four basic operations do to them. Along the way we meet quotients, remainders, factors and primes, which keep coming back through the course.

1.1Counting and the natural numbers

  • Numbers first arose to record a count of objects: 1, 2, 3, 4, … For "7 stones" or "7 pencils", the count is 7.
  • We also need a number for "no objects at all". That number is 0.
  • Put together, these give the natural numbers.
Definition: natural numbers

The set of natural numbers is

N={0,1,2,3,4,5,… }\mathbb{N} = \{0, 1, 2, 3, 4, 5, \dots\}

In this course N\mathbb{N} includes 0. Sometimes N0\mathbb{N}_0 is written to stress that 0 is in. Some other books start N\mathbb{N} at 1, so always check the convention a book uses.

1.2The four operations, and where subtraction fails

The four arithmetic operations are addition, subtraction, multiplication and division. A natural question is: which of them always give a natural number when we start with natural numbers?

OperationExampleAlways a natural number?
Addition ++5+2=75 + 2 = 7Yes
Multiplication ×\times3×4=123 \times 4 = 12Yes
Subtraction −-5−6=−15 - 6 = -1No: −1-1 is not in N\mathbb{N}
Division ÷\div19÷519 \div 5No: 5 does not go into 19 exactly

Since 5−65 - 6 is not a natural number, subtraction fails inside N\mathbb{N}. The fix is to extend the natural numbers with the negative numbers −1,−2,−3,…-1, -2, -3, \dots.

1.3The integers

Definition: integers

The set of integers is

Z={…,−3,−2,−1,0,1,2,3,… }\mathbb{Z} = \{\dots, -3, -2, -1, 0, 1, 2, 3, \dots\}

Every natural number is an integer, and now subtraction always works: the difference of two integers is again an integer.

We picture the integers on a number line. Moving right the numbers increase; moving left they decrease.

−5−4−3−2−1012345New: negatives −1, −2, −3, …Natural numbers ℕ = {0, 1, 2, 3, …}decreaseincreaseℤ
Figure 1. The integers on the number line: the natural numbers (amber) plus the negatives (blue)

1.4Multiplication is repeated addition

7×47 \times 4 means: make 4 groups of 7. In general, multiplying mm by nn means adding mm to itself nn times:

m×n=m+m+⋯+m⏟n timesm \times n = \underbrace{m + m + \cdots + m}_{n \text{ times}}
group 1+group 2+group 3+group 4= 28Each group holds 7 objects. Four groups: 7 × 4 = 7 + 7 + 7 + 7 = 28
Figure 2. Multiplication as groups: 7 × 4 is four groups of 7
Notation
Three ways to write it

m×nm \times n, m⋅nm \cdot n, mnmn all mean the same product.

Sign rules
Multiplying negative numbers

one negative: −m×n=−(m⋅n)-m \times n = -(m \cdot n)

two negatives: −m×−n=m⋅n-m \times -n = m \cdot n

1.5Exponentiation is repeated multiplication

Multiplying a number by itself again and again gets its own notation:

ExpressionWritten asRead as
m×mm \times mm2m^2"m squared"
m×m×mm \times m \times mm3m^3"m cubed"
m×m×⋯×m⏟k times\underbrace{m \times m \times \cdots \times m}_{k \text{ times}}mkm^k"m to the power k"
Additionm + m + m + mcombine countsMultiplicationm × n = m + m + … + mrepeated additionExponentiationmᵏ = m × m × … × mrepeated multiplicationn ×Each operation is the previous one, repeated
Figure 3. Each operation is the one before it, repeated
Remember

Multiplication is repeated addition. Exponentiation is repeated multiplication.

Careful. mkm^k multiplies mm by itself kk times; it is not m×km \times k. For example 25=322^5 = 32, whereas 2×5=102 \times 5 = 10.

1.6Division is repeated subtraction

You have 20 mangoes to share among 5 friends. Give each friend one per round: after round 1 you have 20−5=1520 - 5 = 15 left, then 15−5=1015 - 5 = 10, then 10−5=510 - 5 = 5, then 5−5=05 - 5 = 0. Four rounds, so 20÷5=420 \div 5 = 4.

What if you start with only 19 mangoes? After 3 full rounds, 4 are left and you cannot run another round. The quotient of 19÷519 \div 5 is 3 and the remainder is 4.

Start with 20 mangoes, give 1 to each of 5 friends per round20−5round 115−5round 210−5round 35−5round 404 rounds, nothing left: 20 ÷ 5 = 4Now start with only 19 mangoes19−5round 114−5round 29−5round 344 < 5: no 4th roundquotient 3, remainder 419 ÷ 5 gives quotient 3 and remainder 4, so 19 mod 5 = 4
Figure 4. Division as repeated subtraction, with and without a remainder
Definition: quotient, remainder and mod

When aa is divided by bb, the quotient is the number of full rounds of subtracting bb, and the remainder is what is left over (it is smaller than bb). The modulo operator gives the remainder:

19 mod 5=410 mod 3=120 mod 5=019 \bmod 5 = 4 \qquad 10 \bmod 3 = 1 \qquad 20 \bmod 5 = 0

Equivalently a=b×q+ra = b \times q + r with 0≤r<b0 \le r < b, where qq is the quotient and rr the remainder. Check: 19=5×3+419 = 5 \times 3 + 4.

Example 1Quotient and remainder

Find the quotient and remainder when 10 is divided by 3, and write the remainder using mod.

Solution
  • Subtract 3 repeatedly: 10−3=710 - 3 = 7, 7−3=47 - 3 = 4, 4−3=14 - 3 = 1.
  • Now 1<31 < 3, so no further round is possible. We made 3 full rounds.
  • Quotient = 3, remainder = 1. Check: 3×3+1=103 \times 3 + 1 = 10.

Answer: 10 mod 3=110 \bmod 3 = 1.

1.7Factors and divisibility

Definition: divides, factor, multiple

aa divides bb if b mod a=0b \bmod a = 0. We write a∣ba \mid b. Then aa is a factor of bb, and bb is a multiple of aa (bb is divisible by aa).

Divides
Remainder is 0

4∣20,  7∣63,  32∣1024,  2∣6,  5∣104 \mid 20,\; 7 \mid 63,\; 32 \mid 1024,\; 2 \mid 6,\; 5 \mid 10

Does not divide
Remainder is not 0

4∤194 \nmid 19 (since 19 mod 4=319 \bmod 4 = 3), 9∤1009 \nmid 100 (since 100 mod 9=1100 \bmod 9 = 1)

Factors occur in pairs. If a∣ba \mid b then b=a×cb = a \times c for some cc, and cc is a factor too. The factors of 12 are {1,12},{2,6},{3,4}\{1, 12\}, \{2, 6\}, \{3, 4\}. The only exception is a perfect square: the factors of 36 are {1,36},{2,18},{3,12},{4,9},{6}\{1, 36\}, \{2, 18\}, \{3, 12\}, \{4, 9\}, \{6\}, where 6 pairs with itself.

Factors of 12: three pairs1 × 122 × 63 × 41234612Factors of 36 (a perfect square)1 × 362 × 183 × 124 × 91234691218366 × 6: pairs with itself
Figure 5. Factors come in pairs; a perfect square has one factor that pairs with itself
Note. Every non-zero integer aa divides 0 (since 0 mod a=00 \bmod a = 0), and 1 divides every integer. So every number n>1n > 1 has at least the two factors 1 and nn.

1.8Prime numbers

Definition: prime number

A number pp is prime if it has exactly two factors, {1,p}\{1, p\}. 1 is not a prime: it has only one factor. The primes begin 2,3,5,7,11,13,…2, 3, 5, 7, 11, 13, \dots

The Sieve of Eratosthenes finds all primes up to a limit: start at 2, and each time you reach a number that has not been crossed out, it is prime, so remove all multiples of pp. Whatever survives is prime.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950prime: survivescrossed by 2by 3by 5by 7Take the next number still standing (it is prime) and cross out all its multiples
Figure 6. Sieve of Eratosthenes from 1 to 50: the 15 survivors are the primes
Why stop early? To test whether nn is prime you only need to try primes pp with p2≤np^2 \le n. If nn had no prime factor up to n\sqrt{n}, it could not have a larger one either, because factors come in pairs.

1.9Prime factorisation

Every number greater than 1 can be decomposed into prime factors, and this decomposition is unique (apart from the order of the factors). This is the prime factorisation of the number.

12=2×2×3=22×3126=2×3×3×7=2×32×712 = 2 \times 2 \times 3 = 2^2 \times 3 \qquad 126 = 2 \times 3 \times 3 \times 7 = 2 \times 3^2 \times 7
Factor tree of 12Factor tree of 12612262312 = 2 × 2 × 3 = 2² × 312626332137126 = 2 × 3 × 3 × 7 = 2 × 3² × 7
Figure 7. Factor trees: keep splitting until every leaf is prime
Example 2Prime factorisation of 126

Write 126 as a product of primes.

Solution
  1. 126 is even, so divide by 2: 126=2×63126 = 2 \times 63.
  2. 63 is not even. Its digits add to 9, so 3 divides it: 63=3×2163 = 3 \times 21.
  3. 21=3×721 = 3 \times 7, and 3 and 7 are both prime, so we stop.
  4. Collect the leaves: 126=2×3×3×7=2×32×7126 = 2 \times 3 \times 3 \times 7 = 2 \times 3^2 \times 7.
Example 3Using the sieve

Using the sieve, list the primes between 30 and 50.

Solution
  • Multiples of 2 remove all even numbers. Of the odd numbers 31 to 49, multiples of 3 remove 33, 39, 45; multiples of 5 remove 35 (and 45); multiples of 7 remove 49.
  • Survivors: 31,37,41,43,4731, 37, 41, 43, 47.
  • Check one: 47 is not divisible by 2, 3, 5 or 7, and 72=49>477^2 = 49 > 47, so no larger prime needs testing.
Digit-sum shortcut

A number is divisible by 3 (or by 9) exactly when the sum of its digits is divisible by 3 (or by 9). For 63: 6+3=96 + 3 = 9, so both 3 and 9 divide 63.

1.10Going deeper: why each number set was built

Each new set exists because an operation failed in the one before. An operation is closed in a set when the answer always stays inside the set.

OperationN\mathbb{N}Z\mathbb{Z}Q\mathbb{Q}
Additionclosedclosedclosed
Subtractionnot closedclosedclosed
Multiplicationclosedclosedclosed
Division (by non-zero)not closednot closedclosed
  • Quotient and remainder always satisfy a=b⋅q+ra = b \cdot q + r with 0≤r<b0 \le r < b. So the remainder is never as big as the divisor, and b∣ab \mid a exactly when r=0r = 0.
  • Quick divisibility tests. By 2: the last digit is even. By 5: the last digit is 0 or 5. By 3 (or 9): the digit sum is divisible by 3 (or 9). Example: 12341234 has digit sum 10, so 1234 mod 9=11234 \bmod 9 = 1.
  • Is n prime? Try only the primes pp with p2≤np^2 \le n. For 97: 102>9710^2 > 97, so test 2, 3, 5, 7. None divides 97, so 97 is prime.
  • Listing factors. Go in pairs up to n\sqrt{n}: for 36 the pairs are {1,36},{2,18},{3,12},{4,9}\{1, 36\}, \{2, 18\}, \{3, 12\}, \{4, 9\} and the self-pair {6}\{6\}, so 36 has 9 factors. A number has an odd number of factors exactly when it is a perfect square.
  • Extra shortcut (beyond the lecture). If n=paqb⋯n = p^a q^b \cdots, then the number of factors is (a+1)(b+1)⋯(a + 1)(b + 1) \cdots. For 126=2⋅32⋅7126 = 2 \cdot 3^2 \cdot 7 this gives 2⋅3⋅2=122 \cdot 3 \cdot 2 = 12 factors.

1.11LCM, Euclid's algorithm and divisibility tests

The notes so far cover the gcd and prime factorisation. Three more tools sit right next to them and appear constantly in exam questions: the LCM, Euclid's algorithm for finding a gcd without factorising, and the divisibility tests.

A. gcd and LCM from prime factorisations

The least common multiple lcm⁡(a,b)\operatorname{lcm}(a, b) is the smallest positive integer divisible by both aa and bb. Write each number as a product of prime powers. Then

  • gcd⁡\gcd takes each prime to the smaller exponent (a prime missing from one number counts as exponent 0),
  • lcm⁡\operatorname{lcm} takes each prime to the larger exponent.

Example: 12=22⋅312 = 2^2 \cdot 3 and 18=2⋅3218 = 2 \cdot 3^2. So gcd⁡=21⋅31=6\gcd = 2^1 \cdot 3^1 = 6 and lcm⁡=22⋅32=36\operatorname{lcm} = 2^2 \cdot 3^2 = 36. Notice gcd⁡⋅lcm⁡=6⋅36=216=12⋅18\gcd \cdot \operatorname{lcm} = 6 \cdot 36 = 216 = 12 \cdot 18.

Two numbers only
gcd⁡(a,b)⋅lcm⁡(a,b)=a⋅b\gcd(a, b) \cdot \operatorname{lcm}(a, b) = a \cdot b
  • This identity is for two numbers. For three numbers there is no such product rule: lcm⁡(8,12,18)\operatorname{lcm}(8, 12, 18) is found from the prime powers, 23⋅32=722^3 \cdot 3^2 = 72.
  • aa and bb are coprime when gcd⁡(a,b)=1\gcd(a, b) = 1 (for example, any two consecutive integers). Then lcm⁡(a,b)=ab\operatorname{lcm}(a, b) = ab: lcm⁡(4,9)=36\operatorname{lcm}(4, 9) = 36.
  • Any common multiple of aa and bb is a multiple of lcm⁡(a,b)\operatorname{lcm}(a, b), and any common divisor is a divisor of gcd⁡(a,b)\gcd(a, b).

B. Euclid's algorithm

Factorising big numbers is slow. Euclid's algorithm finds the gcd by repeated division with remainder:

gcd⁡(a,b)=gcd⁡(b, a mod b),gcd⁡(a,0)=a\gcd(a, b) = \gcd(b,\ a \bmod b), \qquad \gcd(a, 0) = a

Why it works. If a=qb+ra = qb + r, any number dividing both aa and bb also divides r=a−qbr = a - qb, and any number dividing both bb and rr also divides a=qb+ra = qb + r. So the pairs (a,b)(a, b) and (b,r)(b, r) have exactly the same common divisors, hence the same gcd.

Example: gcd⁡(252,105)\gcd(252, 105).

252=2⋅105+42,105=2⋅42+21,42=2⋅21+0252 = 2 \cdot 105 + 42, \qquad 105 = 2 \cdot 42 + 21, \qquad 42 = 2 \cdot 21 + 0

The last non-zero remainder is 2121, so gcd⁡(252,105)=21\gcd(252, 105) = 21. Check with factorisations: 252=22⋅32⋅7252 = 2^2 \cdot 3^2 \cdot 7, 105=3⋅5⋅7105 = 3 \cdot 5 \cdot 7, common part 3⋅7=213 \cdot 7 = 21 ✓. Then lcm⁡(252,105)=252⋅10521=1260\operatorname{lcm}(252, 105) = \dfrac{252 \cdot 105}{21} = 1260.

C. Divisibility tests

DivisorTest
2, 5, 10last digit is even / 0 or 5 / 0
4the number formed by the last two digits is divisible by 4
8the number formed by the last three digits is divisible by 8
3, 9the sum of the digits is divisible by 3 / by 9
11the alternating sum of the digits (from the right: +,−,+,…+, -, +, \dots) is divisible by 11 (zero counts)

Example: 75247524. Digit sum 7+5+2+4=187 + 5 + 2 + 4 = 18, divisible by 9 (and so by 3). Last two digits 2424, divisible by 4. Alternating sum 4−2+5−7=04 - 2 + 5 - 7 = 0, so divisible by 11. Last three digits 524524, and 524/8=65.5524 / 8 = 65.5, so it is not divisible by 8. Indeed 7524=22⋅32⋅11⋅197524 = 2^2 \cdot 3^2 \cdot 11 \cdot 19.

D. Counting divisors

If n=p1a1p2a2⋯pkakn = p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k}, a divisor chooses an exponent from 00 to aia_i for each prime, so the number of positive divisors is (a1+1)(a2+1)⋯(ak+1)(a_1 + 1)(a_2 + 1)\cdots(a_k + 1). For 360=23⋅32⋅5360 = 2^3 \cdot 3^2 \cdot 5: 4⋅3⋅2=244 \cdot 3 \cdot 2 = 24 divisors.

E. Word-problem translation

  • "Events repeating every aa, bb and cc minutes happen together again after..." →\to the lcm.
  • "Largest equal pieces / tiles / groups that fit both lengths exactly" →\to the gcd.

1.12Exam tips and common mistakes

Exam tips
  • Check any division with a=bq+ra = bq + r before you write the answer.
  • N\mathbb{N} includes 0 in this course, and 1 is not prime. 2 is the only even prime.
  • Factors: list in pairs and stop at n\sqrt{n} so none is missed.
Common mistakes
  • Calling 1 a prime, or saying 0 is not in N\mathbb{N} (here it is).
  • Confusing mkm^k with m×km \times k: 25=322^5 = 32, not 10.
  • Writing a remainder equal to or larger than the divisor.
  • Forgetting that every number n>1n > 1 has at least the factors 1 and nn.

Practice questions (graded-assignment style)

Q1Find the prime

Multiple Choice Question (MCQ): choose the one correct option.

Which of these numbers is prime?

1
1
2
51
3
57
4
59
Solution
Idea

A prime has exactly two factors, 1 and itself. Test small primes.

  • 1 has only one factor, so it is not prime.
  • 51=3×1751 = 3 \times 17 and 57=3×1957 = 3 \times 19, so both are composite.
  • 59: not divisible by 2, 3, 5 or 7, and 82=64>598^2 = 64 > 59, so 59 is prime.
  • Answer: option 4.
Q2Remainder using digit sum

Numerical Answer Type (NAT).

Find 1234 mod 91234 \bmod 9.

Solution
Idea

A number leaves the same remainder mod 9 as its digit sum.

  • Digit sum 1+2+3+4=101 + 2 + 3 + 4 = 10, and 10 mod 9=110 \bmod 9 = 1.
  • Check: 1234=9×137+11234 = 9 \times 137 + 1.
  • Answer: 1
Q3Counting factors

Numerical Answer Type (NAT).

How many factors does 36 have?

Solution
Idea

Factors come in pairs, and a perfect square has one self-pair.

  • Pairs: {1,36},{2,18},{3,12},{4,9}\{1, 36\}, \{2, 18\}, \{3, 12\}, \{4, 9\}, that is 8 factors.
  • The self-pair {6}\{6\} adds 1 more: 8+1=98 + 1 = 9.
  • Answer: 9
Q4Facts of this course

Multiple Select Question (MSQ): select all that apply.

Choose the correct statements.

1
0∈N0 \in \mathbb{N}
2
5−6∈N5 - 6 \in \mathbb{N}
3
1 is not a prime number.
4
If a∣ba \mid b then b mod a=0b \bmod a = 0.
Solution
Idea

Use the conventions of the course: N\mathbb{N} includes 0, and a∣ba \mid b means remainder 0.

  • Option 1 is correct (this course includes 0).
  • Option 2 is wrong: 5−6=−15 - 6 = -1 is not natural.
  • Option 3 is correct: 1 has only one factor.
  • Option 4 is the definition of divides.
  • Answer: options 1, 3 and 4.
N1An LCM from a gcd

Numerical Answer Type (NAT).

Find lcm⁡(84,36)\operatorname{lcm}(84, 36).

Solution
Idea

gcd⁡⋅lcm⁡=ab\gcd \cdot \operatorname{lcm} = ab for two numbers.

  • 84=22⋅3⋅784 = 2^2 \cdot 3 \cdot 7 and 36=22⋅3236 = 2^2 \cdot 3^2. gcd⁡=22⋅3=12\gcd = 2^2 \cdot 3 = 12.
  • lcm⁡=84⋅3612=252\operatorname{lcm} = \dfrac{84 \cdot 36}{12} = 252. Check with prime powers: 22⋅32⋅7=2522^2 \cdot 3^2 \cdot 7 = 252 ✓.
  • Answer: 252
N2Euclid's algorithm

Numerical Answer Type (NAT).

Use Euclid's algorithm to find gcd⁡(252,105)\gcd(252, 105).

Solution
Idea

Replace (a,b)(a, b) by (b,a mod b)(b, a \bmod b) until the remainder is 00.

  • 252 mod 105=42252 \bmod 105 = 42, so gcd⁡(252,105)=gcd⁡(105,42)\gcd(252, 105) = \gcd(105, 42).
  • 105 mod 42=21105 \bmod 42 = 21, so it equals gcd⁡(42,21)\gcd(42, 21).
  • 42 mod 21=042 \bmod 21 = 0, so the answer is the last non-zero remainder, 2121.
  • Answer: 21
N3Divisibility tests

Multiple Select Question (MSQ): select all that apply.

The number 75247524 is divisible by which of the following?

1
44
2
99
3
1111
4
55
5
88
Solution
Idea

Apply the test for each divisor.

  • 4 ✓ The last two digits 2424 are divisible by 4.
  • 9 ✓ Digit sum 1818 is divisible by 9.
  • 11 ✓ Alternating sum 4−2+5−7=04 - 2 + 5 - 7 = 0.
  • 5 ✗ The last digit is 4, not 0 or 5.
  • 8 ✗ The last three digits 524=8⋅65+4524 = 8 \cdot 65 + 4.
  • Answer: options 1, 2 and 3.
N4Number of divisors

Numerical Answer Type (NAT).

How many positive divisors does 360360 have?

Solution
Idea

Factorise, add 1 to each exponent, multiply.

  • 360=23⋅32⋅51360 = 2^3 \cdot 3^2 \cdot 5^1.
  • (3+1)(2+1)(1+1)=4⋅3⋅2=24(3 + 1)(2 + 1)(1 + 1) = 4 \cdot 3 \cdot 2 = 24.
  • Answer: 24
N5Three bells

Numerical Answer Type (NAT).

Three bells ring together at 9:00. After that they ring every 8, 12 and 18 minutes respectively. After how many minutes do they next ring together?

Solution
Idea

"Together again" means a common multiple; "next" means the least one.

  • 8=238 = 2^3, 12=22⋅312 = 2^2 \cdot 3, 18=2⋅3218 = 2 \cdot 3^2. Take the larger exponent of each prime: 23⋅32=722^3 \cdot 3^2 = 72.
  • Check: 72=9⋅8=6⋅12=4⋅1872 = 9 \cdot 8 = 6 \cdot 12 = 4 \cdot 18 ✓, and no smaller number works (it must be a multiple of 88 and of 99, so of 7272).
  • Answer: 72 (the next common ring is at 10:12).
Revision overview
Natural numbers ℕℕ = {0, 1, 2, 3, …}, includes 0
Numbers count objects; 0 is "none"
+ and × always stay inside ℕ
Integers ℤ5 − 6 is not natural
Add negatives: …, −2, −1, 0, 1, 2, …
Number line: right increases
Repeated operationsm × n: add m, n times
mᵏ: multiply m, k times
Division: subtract repeatedly
Natural Numbers & IntegersWeek 1 · Number system
Quotient & remainder19 ÷ 5: quotient 3, remainder 4
19 mod 5 = 4
a | b when b mod a = 0
FactorsFactors occur in pairs
Factors of 12: {1,12}, {2,6}, {3,4}
Perfect square: one self-pair (6 × 6)
PrimesExactly two factors: 1 and p
1 is not prime
Sieve: cross out multiples
Prime factorisation is unique
Revision: natural numbers and integers on one page
Next · Number system · Part 2 of 3Rational Numbers
02
Number system · Part 2 of 3

Rational Numbers

Division is the operation integers cannot always handle: 19÷519 \div 5 is not an integer. To fix this we extend the integers once more, to fractions. This topic covers rational numbers, their many representations, the reduced form, the greatest common divisor, and a new property called density.

2.1From division to fractions

  • We cannot represent 19÷519 \div 5 as an integer: 5 does not divide 19.
  • A fraction can: 19÷5=195=34519 \div 5 = \frac{19}{5} = 3\frac{4}{5}, which is the quotient 3 and the remainder 4 out of 5.
Definition: rational numbers

A rational number is a number of the form pq\frac{p}{q}, where pp and qq are integers and q≠0q \neq 0.

  • pp is the numerator and qq is the denominator.
  • The set of rational numbers is written Q\mathbb{Q}.
  • Rationals extend the integers: every integer mm is the rational number m1\frac{m}{1}.
Why q≠0q \neq 0? Dividing by zero is not defined, so a fraction with denominator 0 is not a number at all.

2.2The same number, many names

The representation of a rational number is not unique. Multiplying numerator and denominator by the same non-zero number gives another name for the same number:

35=610=3050=⋯12=24=1020=⋯\frac{3}{5} = \frac{6}{10} = \frac{30}{50} = \cdots \qquad \frac{1}{2} = \frac{2}{4} = \frac{10}{20} = \cdots
3/53 of 5 parts6/106 of 10 parts30/5030 of 50 partsall three shade the same length: the same number
Figure 8. Three names for the same rational number

2.3Adding and comparing

Having many names is actually useful: to add, subtract or compare two fractions, rewrite both with a common denominator first.

35+34=1220+1520=272035<34 because 1220<1520\frac{3}{5} + \frac{3}{4} = \frac{12}{20} + \frac{15}{20} = \frac{27}{20} \qquad \frac{3}{5} < \frac{3}{4} \text{ because } \frac{12}{20} < \frac{15}{20}
3/5 = 12/2012 parts3/4 = 15/2015 partsCompare: 12/20 < 15/20, so 3/5 < 3/4sum = 27/20one whole+ 7/20
Figure 9. Twentieths make 3/5 and 3/4 easy to add and compare

2.4Reduced form and the gcd

Definition: reduced form

pq\frac{p}{q} is in reduced form when pp and qq have no common factors other than 1. For example, the reduced form of 1860\frac{18}{60} is 310\frac{3}{10}.

Definition: greatest common divisor

The greatest common divisor gcd⁡(p,q)\gcd(p, q) of two non-zero integers is the greatest positive integer kk that divides both pp and qq. A fraction pq\frac{p}{q} is in reduced form exactly when gcd⁡(p,q)=1\gcd(p, q) = 1.

To find the gcd, recall prime factorisation: 18=2⋅3⋅318 = 2 \cdot 3 \cdot 3 and 60=2⋅2⋅3⋅560 = 2 \cdot 2 \cdot 3 \cdot 5. The common prime factors are 2⋅32 \cdot 3, so gcd⁡(18,60)=6\gcd(18, 60) = 6. (Later in the course you will see more efficient ways to find gcd⁡(m,n)\gcd(m, n).)

18 = 2 · 3 · 360 = 2 · 2 · 3 · 532325only in 18only in 60Shared part: 2 · 3, so gcd(18, 60) = 6
Figure 10. The gcd is the product of the shared prime factors
PairgcdWhy
gcd⁡(9,12)\gcd(9, 12)3Factors of 9: 1, 3, 9. Factors of 12: 1, 2, 3, 4, 6, 12. Largest common: 3
gcd⁡(15,45)\gcd(15, 45)1515 divides 45, so 15 itself is the largest common divisor
gcd⁡(0,q)\gcd(0, q)qq0 is a multiple of every integer, so every divisor of qq divides 0 (here qq is a positive integer)
gcd⁡(1,q)\gcd(1, q)11 has no factors other than itself
Example 4Reducing a fraction

Write 1860\frac{18}{60} in reduced form.

Solution
  1. Prime factorise: 18=2⋅3⋅318 = 2 \cdot 3 \cdot 3, 60=2⋅2⋅3⋅560 = 2 \cdot 2 \cdot 3 \cdot 5.
  2. Common factors: 2⋅32 \cdot 3, so gcd⁡(18,60)=6\gcd(18, 60) = 6.
  3. Divide top and bottom by the gcd: 18÷660÷6=310\frac{18 \div 6}{60 \div 6} = \frac{3}{10}.
  4. Check: gcd⁡(3,10)=1\gcd(3, 10) = 1, so 310\frac{3}{10} is reduced.

2.5Density: integers are discrete, rationals are dense

Every integer has a next and a previous integer: for mm they are m+1m + 1 and m−1m - 1. There is no integer between mm and m+1m + 1.

This is not possible for rationals. Between any two rationals we can always find another one. Suppose mn<pq\frac{m}{n} < \frac{p}{q}. Their average

12(mn+pq)\frac{1}{2}\left(\frac{m}{n} + \frac{p}{q}\right)

is again a rational number and lies between them. Repeat with the new pair and you get yet another rational, forever. So it makes no sense to talk about the "next" or "previous" rational.

Integers: every integer has a next and a previous onem − 1mm + 1no integer in hereno integer in hereRationals: between any two, their average sits in between, again and again01average = 1/201/2average = 1/401/4average = 1/8zoom in
Figure 11. No integer between m and m + 1, but always another rational in between
Remember

Rationals are dense; integers are discrete.

Example 5A rational in between

Find a rational number between 35\frac{3}{5} and 34\frac{3}{4}.

Solution
  1. Common denominator: 35=1220\frac{3}{5} = \frac{12}{20} and 34=1520\frac{3}{4} = \frac{15}{20}.
  2. Average: 12(1220+1520)=12⋅2720=2740\frac{1}{2}\left(\frac{12}{20} + \frac{15}{20}\right) = \frac{1}{2} \cdot \frac{27}{20} = \frac{27}{40}.
  3. Check with denominator 40: 2440<2740<3040\frac{24}{40} < \frac{27}{40} < \frac{30}{40}. So 2740\frac{27}{40} lies between them.

2.6Going deeper: fractions, equality and decimals

  • Equality test. For positive denominators, pq=rs\frac{p}{q} = \frac{r}{s} exactly when ps=qrps = qr. So 35=610\frac{3}{5} = \frac{6}{10} because 3⋅10=5⋅63 \cdot 10 = 5 \cdot 6. The same cross-multiplication compares: 35<34\frac{3}{5} < \frac{3}{4} because 3⋅4<5⋅33 \cdot 4 < 5 \cdot 3 is 12<1512 < 15.
  • Never add the denominators. 35+34≠69\frac{3}{5} + \frac{3}{4} \neq \frac{6}{9}. First rewrite with a common denominator: 1220+1520=2720\frac{12}{20} + \frac{15}{20} = \frac{27}{20}.
  • Reduced form is the standard name. Divide top and bottom by gcd⁡(p,q)\gcd(p, q). Keep the denominator positive and put any minus sign on the numerator: −6−9=23\frac{-6}{-9} = \frac{2}{3}, and 6−9=−23\frac{6}{-9} = \frac{-2}{3}.
  • Decimals (extra). A decimal is rational if it stops (0.75=340.75 = \frac{3}{4}) or repeats (0.333…=130.333\ldots = \frac{1}{3}). Irrational decimals never stop and never repeat, as for π\pi.
  • Density has consequences. There is no smallest positive rational and no "next" rational, and there are infinitely many rationals between any two. Averaging two rationals gives a new one in between.
  • gcd facts to memorise. gcd⁡(1,q)=1\gcd(1, q) = 1, gcd⁡(0,q)=q\gcd(0, q) = q, and if p∣qp \mid q then gcd⁡(p,q)=p\gcd(p, q) = p.

2.7Exam tips and common mistakes

Exam tips
  • Always reduce the final fraction and say that you checked gcd⁡=1\gcd = 1.
  • To compare or add fractions, use a common denominator or cross-multiply.
  • For "find a rational between", use the average and verify with a common denominator.
Common mistakes
  • Adding numerators and denominators separately: 35+34=69\frac{3}{5} + \frac{3}{4} = \frac{6}{9} is wrong.
  • Leaving a fraction unreduced, or with a zero denominator.
  • Believing a "next" rational exists after a given rational.
  • Treating 227\frac{22}{7} as π\pi. It is only an approximation, and π\pi is irrational.

Practice questions (graded-assignment style)

Q1Add the fractions

Multiple Choice Question (MCQ): choose the one correct option.

What is 35+34\frac{3}{5} + \frac{3}{4}?

1
69\frac{6}{9}
2
2720\frac{27}{20}
3
920\frac{9}{20}
4
310\frac{3}{10}
Solution
Idea

Use the common denominator 20.

  • 35=1220\frac{3}{5} = \frac{12}{20} and 34=1520\frac{3}{4} = \frac{15}{20}.
  • 1220+1520=2720\frac{12}{20} + \frac{15}{20} = \frac{27}{20}.
  • Option 1 wrongly adds the numerators and the denominators.
  • Answer: option 2.
Q2Find the gcd

Numerical Answer Type (NAT).

Find gcd⁡(84,36)\gcd(84, 36).

Solution
Idea

Take the shared prime factors.

  • 84=22⋅3⋅784 = 2^2 \cdot 3 \cdot 7 and 36=22⋅3236 = 2^2 \cdot 3^2.
  • Common part: 22⋅3=122^2 \cdot 3 = 12.
  • Answer: 12
Q3Which is not rational?

Multiple Choice Question (MCQ): choose the one correct option.

Which of these numbers is not rational?

1
0.75
2
916\sqrt{\frac{9}{16}}
3
7
4
7\sqrt{7}
Solution
Idea

The square root of a non-negative integer is irrational unless the integer is a perfect square.

  • 0.75=340.75 = \frac{3}{4} is rational.
  • 916=34\sqrt{\frac{9}{16}} = \frac{3}{4} is rational.
  • 7 is an integer, hence rational.
  • 7 is not a perfect square, so 7\sqrt{7} is irrational.
  • Answer: option 4.
Q4Properties of rationals

Multiple Select Question (MSQ): select all that apply.

Choose the correct statements.

1
Between any two rationals there is another rational.
2
There is a smallest positive rational.
3
Every integer mm is the rational number m1\frac{m}{1}.
4
The reduced form of 1860\frac{18}{60} is 310\frac{3}{10}.
Solution
Idea

Rationals are dense and extend the integers.

  • Option 1: true, the average lies in between.
  • Option 2: false. Halving any positive rational gives a smaller positive rational.
  • Option 3: true by definition.
  • Option 4: true, since gcd⁡(18,60)=6\gcd(18, 60) = 6 and gcd⁡(3,10)=1\gcd(3, 10) = 1.
  • Answer: options 1, 3 and 4.
Revision overview
Definitionℚ: numbers p/q with p, q integers
q ≠ 0; numerator p, denominator q
Extends ℤ: m = m/1
Many names3/5 = 6/10 = 30/50
Representation is not unique
Use a common denominator
Add and compare3/5 + 3/4 = 12/20 + 15/20 = 27/20
3/5 < 3/4 since 12/20 < 15/20
Rational NumbersWeek 1 · Number system
Reduced formp, q share no common factor
gcd(p, q) = 1
18/60 reduces to 3/10
gcdShared prime factors
gcd(18, 60) = 2 · 3 = 6
gcd(0, q) = q, gcd(1, q) = 1
DensityIntegers: next is m+1, previous m−1
Rationals: average lies between
No "next" rational exists
Revision: rational numbers on one page
Next · Number system · Part 3 of 3Real and Complex Numbers
03
Number system · Part 3 of 3

Real and Complex Numbers

The rationals are dense, so it is tempting to think they fill the whole number line. They do not. This topic shows a point the rationals miss, builds the real numbers R\mathbb{R}, and then goes one step further to the complex numbers C\mathbb{C}.

3.1Squares and square roots

Rationals are dense: between any two there is another. So, is every point on the number line a rational number? To answer this we need squares and square roots.

Square
Square of mm

For an integer mm, its square is m2=m⋅mm^2 = m \cdot m.

Square root
Square root of mm

m\sqrt{m} is a number rr such that r⋅r=mr \cdot r = m.

Perfect square1491625364964…256
Square root12345678…16

What about integers that are not perfect squares, such as 2?

3.2Root 2 is irrational

  • 2\sqrt{2} cannot be written as pq\frac{p}{q} with integers p,qp, q.
  • Yet we can draw a line of length 2\sqrt{2}: it is the diagonal of a square whose sides have length 1, because 12+12=21^2 + 1^2 = 2.
  • So 2\sqrt{2} is a genuine point on the number line that is not rational. It is irrational.
012311√2√2 ≈ 1.414…Diagonal of a square with side 1:1² + 1² = 2, so the length is √2Swing it down onto the number line:a real point that no fraction p/q names
Figure 12. The diagonal of a unit square lands exactly at √2 on the number line
Definition: irrational numbers

Numbers that cannot be written in the form pq\frac{p}{q} with p,qp, q integers are called irrational. Simply: the numbers that are not rational. Examples: 2,3,π,e\sqrt{2}, \sqrt{3}, \pi, e. Typical irrationals are square roots of integers that are not perfect squares.

Not every square root is irrational. 16=4\sqrt{16} = 4 and 916=34\sqrt{\frac{9}{16}} = \frac{3}{4} are rational. The square root of a non-negative integer is irrational exactly when the integer is not a perfect square.

3.3The real numbers

Definition: real numbers

The real numbers R\mathbb{R} are all the rational numbers together with all the irrational numbers. Real numbers extend the rationals.

  • Some well-known irrationals: π=3.1415927…\pi = 3.1415927\ldots and e=2.7182818…e = 2.7182818\ldots
  • Like the rationals, the reals are dense: if r<r′r < r', then r+r′2\frac{r + r'}{2} lies between rr and r′r'.
01234rational1/21.414…√2√31.732…5/2rational2.718…eπ3.141…
Figure 13. Rationals (blue) and irrationals (amber) share the same number line

3.4Beyond the reals: complex numbers

Can we stop with the real numbers? What about −1\sqrt{-1}? For any real number rr, the square r2r^2 can never be negative, because of the law of signs for multiplication ((+)(+)=+(+)(+) = + and (−)(−)=+(-)(-) = +). So no real number squares to −1-1.

Complex numbers

−1\sqrt{-1} is a complex number. The complex numbers C\mathbb{C} extend the real numbers, just as each earlier set extended the one before.

3.5The whole family

Each new set was built to fix something the previous one could not do, and each one contains the one before it:

N⊂Z⊂Q⊂R⊂C\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}
ℂ Complex√−1ℝ Real√2πeℚ Rational3/5−1/227/20ℤ Integers−1−7−36ℕ Natural0, 1, 2,3, 19, …
Figure 14. Every natural number is an integer, every integer is rational, every rational is real, and the complex numbers extend the reals
SetBuilt to fixExample of a new member
N\mathbb{N}Counting objects, including none0,70, 7
Z\mathbb{Z}5−65 - 6 is not natural−1-1
Q\mathbb{Q}19÷519 \div 5 is not an integer195\frac{19}{5}
R\mathbb{R}2\sqrt{2} is not rational2,π,e\sqrt{2}, \pi, e
C\mathbb{C}No real number squares to −1-1−1\sqrt{-1}
Example 6Smallest home of a number

For each number, name the smallest of N,Z,Q,R,C\mathbb{N}, \mathbb{Z}, \mathbb{Q}, \mathbb{R}, \mathbb{C} that contains it: 7, −3, 610, 16, 3, π, −17,\ -3,\ \frac{6}{10},\ \sqrt{16},\ \sqrt{3},\ \pi,\ \sqrt{-1}.

Solution
NumberReasoningSmallest set
77A count of objectsN\mathbb{N}
−3-3Negative, so not natural; but an integerZ\mathbb{Z}
610\frac{6}{10}Reduces to 35\frac{3}{5}, not an integerQ\mathbb{Q}
16\sqrt{16}16 is a perfect square: 16=4\sqrt{16} = 4N\mathbb{N}
3\sqrt{3}3 is not a perfect square, so 3\sqrt{3} is irrationalR\mathbb{R}
π\piA well-known irrationalR\mathbb{R}
−1\sqrt{-1}No real number squares to −1-1C\mathbb{C}
Example 7A real number in between

Find a real number between 2\sqrt{2} and 3\sqrt{3}, and say whether your answer is rational.

Solution
  1. Use density: the average 2+32\frac{\sqrt{2} + \sqrt{3}}{2} lies between them. Numerically 1.414…+1.732…2≈1.573\frac{1.414\ldots + 1.732\ldots}{2} \approx 1.573.
  2. A simpler choice also works: 2≈1.414\sqrt{2} \approx 1.414 and 3≈1.732\sqrt{3} \approx 1.732, so 1.5=321.5 = \frac{3}{2} lies between them.
  3. 32\frac{3}{2} is rational, which shows that even between two irrationals there are rationals.

3.6Going deeper: rational or irrational?

  • Test for square roots. n\sqrt{n} for a non-negative integer nn: if nn is a perfect square it is an integer (49=7\sqrt{49} = 7); otherwise it is irrational (12\sqrt{12}). For a fraction, take the root of top and bottom: 254=52\sqrt{\frac{25}{4}} = \frac{5}{2}.
  • Smallest set. To name the smallest set holding a number, try N,Z,Q,R,C\mathbb{N}, \mathbb{Z}, \mathbb{Q}, \mathbb{R}, \mathbb{C} in that order and stop at the first that fits. Simplify first: 63=2∈N\frac{6}{3} = 2 \in \mathbb{N}, and 16=4∈N\sqrt{16} = 4 \in \mathbb{N}.
  • Mixing rational and irrational (extra). A rational plus an irrational is irrational (1+21 + \sqrt{2}). But two irrationals can give a rational: 2⋅2=2\sqrt{2} \cdot \sqrt{2} = 2 and 2+(−2)=0\sqrt{2} + (-\sqrt{2}) = 0.
  • Why 2\sqrt{2} is irrational (optional proof). Suppose 2=pq\sqrt{2} = \frac{p}{q} in reduced form. Then p2=2q2p^2 = 2q^2, so p2p^2 is even, hence pp is even, say p=2kp = 2k. Then 4k2=2q24k^2 = 2q^2, so q2=2k2q^2 = 2k^2 and qq is even too. Both even contradicts gcd⁡(p,q)=1\gcd(p, q) = 1.
  • The chain only goes one way. N⊂Z⊂Q⊂R⊂C\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}. Every integer is rational, but not every rational is an integer.

3.7Absolute value, floor and ceiling, and arithmetic with complex numbers

A. Absolute value

The absolute value (or modulus) of a real number is its distance from 00: ∣x∣=x|x| = x if x≥0x \ge 0 and ∣x∣=−x|x| = -x if x<0x < 0. So ∣−5∣=5|-5| = 5 and ∣x∣≥0|x| \ge 0 always.

  • ∣ab∣=∣a∣∣b∣|ab| = |a||b|, but ∣a+b∣≤∣a∣+∣b∣|a + b| \le |a| + |b| (the triangle inequality; equality exactly when aa and bb do not have opposite signs). Example: ∣3+(−5)∣=2≤3+5=8|3 + (-5)| = 2 \le 3 + 5 = 8.
  • ∣x−a∣|x - a| is the distance between xx and aa. So ∣x−a∣<r|x - a| < r means a−r<x<a+ra - r < x < a + r, the open interval (a−r,a+r)(a - r, a + r), and ∣x−a∣≤r|x - a| \le r gives the closed interval [a−r,a+r][a - r, a + r].
  • ∣x∣>r|x| > r means x<−rx < -r or x>rx > r (two pieces, joined by union).

Example: ∣2x−1∣≤3  ⟺  −3≤2x−1≤3  ⟺  −2≤2x≤4  ⟺  −1≤x≤2|2x - 1| \le 3 \iff -3 \le 2x - 1 \le 3 \iff -2 \le 2x \le 4 \iff -1 \le x \le 2, the interval [−1,2][-1, 2]. Its integer solutions are −1,0,1,2-1, 0, 1, 2.

B. Floor and ceiling

⌊x⌋\lfloor x \rfloor is the greatest integer ≤x\le x (round down), and ⌈x⌉\lceil x \rceil is the least integer ≥x\ge x (round up).

xx⌊x⌋\lfloor x \rfloor⌈x⌉\lceil x \rceil
2.72.72233
−2.3-2.3−3-3−2-2
−3-3−3-3−3-3
  • ⌊x⌋≤x<⌊x⌋+1\lfloor x \rfloor \le x < \lfloor x \rfloor + 1. For an integer xx, floor and ceiling both equal xx; otherwise ⌈x⌉=⌊x⌋+1\lceil x \rceil = \lfloor x \rfloor + 1.
  • For negative numbers, floor is not "drop the decimals": ⌊−2.3⌋=−3\lfloor -2.3 \rfloor = -3, not −2-2. Also ⌊−x⌋=−⌈x⌉\lfloor -x \rfloor = -\lceil x \rceil.

C. Complex numbers: the arithmetic

A complex number is z=a+biz = a + bi with a,b∈Ra, b \in \mathbb{R} and i2=−1i^2 = -1. aa is the real part Re⁡(z)\operatorname{Re}(z) and bb is the imaginary part Im⁡(z)\operatorname{Im}(z) (a real number, without the ii).

  • Add / subtract: real and imaginary parts separately. (2+3i)+(1−i)=3+2i(2 + 3i) + (1 - i) = 3 + 2i.
  • Multiply: expand and use i2=−1i^2 = -1: (a+bi)(c+di)=(ac−bd)+(ad+bc)i(a + bi)(c + di) = (ac - bd) + (ad + bc)i. Example: (2+3i)(1−i)=2−2i+3i−3i2=2+i+3=5+i(2 + 3i)(1 - i) = 2 - 2i + 3i - 3i^2 = 2 + i + 3 = 5 + i.
  • Conjugate zˉ=a−bi\bar z = a - bi, and the modulus ∣z∣=a2+b2|z| = \sqrt{a^2 + b^2}. They are linked by zzˉ=a2+b2=∣z∣2z\bar z = a^2 + b^2 = |z|^2, a real number. Example: (2−i)(2+i)=4+1=5(2 - i)(2 + i) = 4 + 1 = 5, and ∣3+4i∣=5|3 + 4i| = 5.
  • Divide: multiply top and bottom by the conjugate of the denominator. 3+4i1−2i=(3+4i)(1+2i)(1−2i)(1+2i)=3+6i+4i+8i25=−5+10i5=−1+2i\dfrac{3 + 4i}{1 - 2i} = \dfrac{(3 + 4i)(1 + 2i)}{(1 - 2i)(1 + 2i)} = \dfrac{3 + 6i + 4i + 8i^2}{5} = \dfrac{-5 + 10i}{5} = -1 + 2i.
  • Powers of ii repeat every four steps: i,−1,−i,1,i,…i, -1, -i, 1, i, \dots. So ini^n depends only on n mod 4n \bmod 4. i23i^{23}: 23=4⋅5+323 = 4 \cdot 5 + 3, so i23=i3=−ii^{23} = i^3 = -i.
  • Every real number is complex (b=0b = 0), so R⊂C\mathbb{R} \subset \mathbb{C}. Unlike the reals, complex numbers are not ordered: "i>0i > 0" and "i<0i < 0" both make no sense.

3.8Exam tips and common mistakes

Exam tips
  • Simplify the number first (cancel fractions, evaluate perfect-square roots), then pick the smallest set.
  • Remember that π\pi and ee are irrational, while 227\frac{22}{7} is only an approximation of π\pi.
  • Always give a reason: "perfect square, so integer" or "not a perfect square, so irrational".
Common mistakes
  • Calling 16\sqrt{16} or 916\sqrt{\frac{9}{16}} irrational. They are 44 and 34\frac{3}{4}.
  • Saying every number with a square root sign is irrational, or that 0.333…0.333\ldots is irrational (it is 13\frac{1}{3}).
  • Writing the chain in the wrong direction, like R⊂Q\mathbb{R} \subset \mathbb{Q}.
  • Claiming real numbers are not dense because they include irrationals. They are dense.

Practice questions (graded-assignment style)

Q1Smallest set

Multiple Choice Question (MCQ): choose the one correct option.

What is the smallest of N,Z,Q,R\mathbb{N}, \mathbb{Z}, \mathbb{Q}, \mathbb{R} that contains 49\sqrt{49}?

1
N\mathbb{N}
2
Z\mathbb{Z}
3
Q\mathbb{Q}
4
R\mathbb{R}
Solution
Idea

Evaluate the root first.

  • 49 is a perfect square, so 49=7\sqrt{49} = 7.
  • 7 is a count, so it already lies in N\mathbb{N}.
  • Answer: option 1.
Q2Irrational numbers

Multiple Select Question (MSQ): select all that apply.

Choose all the irrational numbers.

1
12\sqrt{12}
2
94\sqrt{\frac{9}{4}}
3
π\pi
4
227\frac{22}{7}
Solution
Idea

Simplify, then ask whether the number can be written as a ratio of integers.

  • 12\sqrt{12}: 12 is not a perfect square, so it is irrational.
  • 94=32\sqrt{\frac{9}{4}} = \frac{3}{2} is rational.
  • π\pi is a well-known irrational.
  • 227\frac{22}{7} is a ratio of integers, so it is rational (only close to π\pi).
  • Answer: options 1 and 3.
Q3The chain of sets

Multiple Choice Question (MCQ): choose the one correct option.

Which chain of sets is correct?

1
N⊂Z⊂Q⊂R⊂C\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}
2
R⊂Q⊂Z⊂N\mathbb{R} \subset \mathbb{Q} \subset \mathbb{Z} \subset \mathbb{N}
3
Z⊂N⊂Q⊂R\mathbb{Z} \subset \mathbb{N} \subset \mathbb{Q} \subset \mathbb{R}
4
Q⊂Z⊂R⊂C\mathbb{Q} \subset \mathbb{Z} \subset \mathbb{R} \subset \mathbb{C}
Solution
Idea

Each set extends the previous one.

  • Naturals sit inside integers, integers inside rationals, rationals inside reals, and reals inside complex numbers.
  • The other options reverse or skip a step.
  • Answer: option 1.
Q4Why complex numbers?

Multiple Choice Question (MCQ): choose the one correct option.

Why is −1\sqrt{-1} not a real number?

1
It is irrational.
2
The square of a real number is never negative.
3
It is a fraction.
4
Real numbers are not dense.
Solution
Idea

Use the law of signs.

  • (+)(+)=+(+)(+) = + and (−)(−)=+(-)(-) = +, so r2≥0r^2 \ge 0 for every real rr.
  • So no real number squares to −1-1, and we need C\mathbb{C}.
  • Answer: option 2.
R1An absolute-value inequality

Numerical Answer Type (NAT).

How many integers xx satisfy ∣2x−1∣≤3|2x - 1| \le 3?

Solution
Idea

∣u∣≤3|u| \le 3 means −3≤u≤3-3 \le u \le 3.

  • −3≤2x−1≤3⇒−2≤2x≤4⇒−1≤x≤2-3 \le 2x - 1 \le 3 \Rightarrow -2 \le 2x \le 4 \Rightarrow -1 \le x \le 2.
  • Integers: −1,0,1,2-1, 0, 1, 2. Check the endpoints: ∣2(−1)−1∣=3|2(-1) - 1| = 3 ✓ and ∣2(2)−1∣=3|2(2) - 1| = 3 ✓; x=3x = 3 gives 55 ✗.
  • Answer: 4
R2Floor and ceiling of a negative number

Numerical Answer Type (NAT).

Find ⌊−2.3⌋+⌈−2.3⌉\lfloor -2.3 \rfloor + \lceil -2.3 \rceil.

Solution
Idea

On the number line, floor goes left to the next integer and ceiling goes right.

  • −2.3-2.3 lies between −3-3 and −2-2. Floor is the one on the left: −3-3. Ceiling is the one on the right: −2-2.
  • Sum =−3+(−2)=−5= -3 + (-2) = -5.
  • Answer: -5
R3Product of complex numbers

Numerical Answer Type (NAT).

If (2+3i)(1−i)=a+bi(2 + 3i)(1 - i) = a + bi with a,ba, b real, find a+ba + b.

Solution
Idea

Expand and replace i2i^2 by −1-1.

  • (2+3i)(1−i)=2−2i+3i−3i2=2+i+3=5+i(2 + 3i)(1 - i) = 2 - 2i + 3i - 3i^2 = 2 + i + 3 = 5 + i.
  • So a=5a = 5, b=1b = 1, and a+b=6a + b = 6.
  • Answer: 6
R4A power of ii and a quotient

Multiple Select Question (MSQ): select all that apply.

Choose the correct statements.

1
i23=−ii^{23} = -i
2
3+4i1−2i=−1+2i\dfrac{3 + 4i}{1 - 2i} = -1 + 2i
3
∣3+4i∣=7|3 + 4i| = 7
4
(2−i)(2+i)=5(2 - i)(2 + i) = 5
Solution
Idea

Reduce the exponent modulo 4, use the conjugate for division, and remember zzˉ=∣z∣2z\bar z = |z|^2.

  • 1 ✓ 23 mod 4=323 \bmod 4 = 3 and i3=−ii^3 = -i.
  • 2 ✓ (3+4i)(1+2i)5=−5+10i5=−1+2i\dfrac{(3 + 4i)(1 + 2i)}{5} = \dfrac{-5 + 10i}{5} = -1 + 2i. Check: (−1+2i)(1−2i)=−1+2i+2i−4i2=3+4i(-1 + 2i)(1 - 2i) = -1 + 2i + 2i - 4i^2 = 3 + 4i ✓.
  • 3 ✗ ∣3+4i∣=9+16=5|3 + 4i| = \sqrt{9 + 16} = 5, not 3+43 + 4.
  • 4 ✓ 4−i2=54 - i^2 = 5, real, equal to ∣2−i∣2|2 - i|^2.
  • Answer: options 1, 2 and 4.
Revision overview
Squares & rootsm² = m · m; √m = r with r · r = m
Perfect squares: 1, 4, 9, 16, …, 256
Irrationals√2 is not p/q
But √2 = diagonal of a unit square
Also √3, π = 3.14159…, e = 2.71828…
Real numbers ℝAll rationals + all irrationals
Dense: if r < s, (r + s)/2 is between
Real numbers extend rationals
Real & Complex NumbersWeek 1 · Number system
Complex numbers ℂr² is never negative for real r
√−1 is a complex number
Complex numbers extend reals
The familyℕ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ
Each set fixes a gap in the last
Revision: real and complex numbers on one page
Next · Sets · Part 1 of 3Sets: The Basics
04
Sets · Part 1 of 3

Sets: The Basics

With the number system in place, we step back and look at the idea that holds all those collections together: the set. This topic covers what a set is, how to describe one, when one set sits inside another, and how many subsets a set has.

4.1What is a set?

Definition: set

A set is a collection of (well-defined) items. The items in a set are called its elements.

Days of the week

{Sun,Mon,Tue,Wed,Thu,Fri,Sat}\{\text{Sun}, \text{Mon}, \text{Tue}, \text{Wed}, \text{Thu}, \text{Fri}, \text{Sat}\}

Factors of 24

{1,2,3,4,6,8,12,24}\{1, 2, 3, 4, 6, 8, 12, 24\}

Primes below 15

{2,3,5,7,11,13}\{2, 3, 5, 7, 11, 13\}

  • Sets may be finite (like the three above, or the months of a year) or infinite: the number sets N,Z,Q,R\mathbb{N}, \mathbb{Z}, \mathbb{Q}, \mathbb{R} are all infinite, and so is the set of even natural numbers {0,2,4,6,… }\{0, 2, 4, 6, \dots\}.
  • There is no requirement that the members of a set have a uniform type. The set of objects in a painting, or in a room, is a perfectly good set.

4.2Order, duplicates and cardinality

  • Sets are unordered: {Kohli,Dhoni,Pujara}={Pujara,Kohli,Dhoni}\{\text{Kohli}, \text{Dhoni}, \text{Pujara}\} = \{\text{Pujara}, \text{Kohli}, \text{Dhoni}\}.
  • Duplicates do not matter: {Kohli,Dhoni,Pujara,Dhoni}\{\text{Kohli}, \text{Dhoni}, \text{Pujara}, \text{Dhoni}\} is the same set again.
KohliDhoniPujara{Kohli, Dhoni, Pujara}PujaraKohliDhoni{Pujara, Kohli, Dhoni}KohliDhoniPujaraDhoni{Kohli, Dhoni, Pujara, Dhoni}==the second Dhoni (red) adds nothingAll three are the same set, with cardinality 3
Figure 15. Three ways of writing one set
Definition: cardinality

The cardinality of a set SS, written ∣S∣|S|, is the number of elements in SS. For finite sets, just count the items: {1,2,3,4,6,8,12,24}\{1, 2, 3, 4, 6, 8, 12, 24\} has cardinality 8, and S={1,2,5,7,9,300}S = \{1, 2, 5, 7, 9, 300\} has cardinality 6.

What about infinite sets? Is Q\mathbb{Q} bigger than Z\mathbb{Z}? Is R\mathbb{R} bigger than Q\mathbb{Q}? Counting does not work here. The tool for comparing sizes of sets without counting is a bijection, which appears in the chapter on types of functions.

4.3Describing sets and membership

Finite sets
List them explicitly

{Kohli,Dhoni,Pujara}\{\text{Kohli}, \text{Dhoni}, \text{Pujara}\}

{1,2,3,4,6,8,12,24}\{1, 2, 3, 4, 6, 8, 12, 24\}

Infinite sets
Cannot be listed out

N={0,1,2,… }\mathbb{N} = \{0, 1, 2, \dots\} is a helpful picture, but the "…\dots" is not formal notation. Section 5.1 gives the formal way.

Careful

Not every collection of items is a set. For example, the collection of all sets is not a set. This is shown by Russell's paradox.

Notation: membership

x∈Xx \in X means "xx is an element of XX", and x∉Xx \notin X means it is not. For example:

−5∈Z2∉Q-5 \in \mathbb{Z} \qquad \sqrt{2} \notin \mathbb{Q}

4.4Subsets

Definition: subset

XX is a subset of YY if every element of XX is also an element of YY. Notation: X⊆YX \subseteq Y.

  • {Kohli,Pujara}⊆{Kohli,Pujara,Dhoni}\{\text{Kohli}, \text{Pujara}\} \subseteq \{\text{Kohli}, \text{Pujara}, \text{Dhoni}\}
  • Primes⊆N\text{Primes} \subseteq \mathbb{N}, and N⊆Z, Z⊆Q, Q⊆R\mathbb{N} \subseteq \mathbb{Z},\ \mathbb{Z} \subseteq \mathbb{Q},\ \mathbb{Q} \subseteq \mathbb{R}
  • Every set is a subset of itself: X⊆XX \subseteq X.
  • X=YX = Y if and only if X⊆YX \subseteq Y and Y⊆XY \subseteq X. This is how we prove two sets are equal.
Definition: proper subset

XX is a proper subset of YY if X⊆YX \subseteq Y but X≠YX \neq Y. Notation: X⊂YX \subset Y or X⊊YX \subsetneq Y. For example N⊊Z, Z⊊Q, Q⊊R\mathbb{N} \subsetneq \mathbb{Z},\ \mathbb{Z} \subsetneq \mathbb{Q},\ \mathbb{Q} \subsetneq \mathbb{R}.

Y040170X12579300X ⊂ Y: all of X is in Y, and Y has moreX = {4, 16, 32, 64}Y = {64, 16, 32, 4}same elements, different orderX ⊆ Y and Y ⊆ X, so X = Y: not proper
Figure 16. Left: X is a proper subset of Y. Right: X and Y have the same elements, so they are equal
∈\in versus ⊆\subseteq. ∈\in relates an element to a set; ⊆\subseteq relates a set to a set. For X={a,b}X = \{a, b\}: a∈Xa \in X is true, but a⊆Xa \subseteq X is not (aa is not a set); {a}⊆X\{a\} \subseteq X is true, but {a}∈X\{a\} \in X is false.

4.5The empty set and the power set

Definition: empty set

The empty set has no elements. It is written ∅\emptyset. ∅⊆X\emptyset \subseteq X for every set XX: every element of ∅\emptyset is also in XX, simply because ∅\emptyset has no elements to check.

A set can contain other sets as elements. The most important example is the power set.

Definition: power set

The power set of XX is the set of all subsets of XX. For X={a,b}X = \{a, b\}:

Power set of X={∅,{a},{b},{a,b}}\text{Power set of } X = \{\emptyset, \{a\}, \{b\}, \{a, b\}\}

A set with nn elements has 2n2^n subsets. Take X={x1,x2,…,xn}X = \{x_1, x_2, \dots, x_n\}. To build a subset, go through the elements one by one and either include or exclude each xix_i. That is 2 choices per element, so the number of subsets is

2⋅2⋅2⋯2⏟n times=2n\underbrace{2 \cdot 2 \cdot 2 \cdots 2}_{n \text{ times}} = 2^n
+a−a+b−b+b−b+c−c+c−c+c−c+c−c{a, b, c}111{a, b}110{a, c}101{a}100{b, c}011{b}010{c}001∅000startdecide adecide bdecide c2 choices per element: 2 × 2 × 2 = 8 subsets
Figure 17. Every path of include (+) / exclude (−) choices gives one subset of {a, b, c}
{a, b, c}{a, b}{a, c}{b, c}{a}{b}{c}∅size 3: 1 subsetsize 2: 3 subsetssize 1: 3 subsetssize 0: 1 subseta line joins two subsetsthat differ by one element1 + 3 + 3 + 1 = 8 = 2³
Figure 18. The 8 subsets of {a, b, c}, arranged by size
Notation. The power set of XX is often written P(X)\mathcal{P}(X), so ∣P(X)∣=2∣X∣|\mathcal{P}(X)| = 2^{|X|}. Note that ∅∈P(X)\emptyset \in \mathcal{P}(X) and ∅⊆X\emptyset \subseteq X, but ∅∉X\emptyset \notin X unless XX itself has ∅\emptyset as an element.

4.6Subsets and binary numbers

The include/exclude choice is exactly a bit. List the elements of X={x1,x2,…,xn}X = \{x_1, x_2, \dots, x_n\} in order and use an nn-bit binary number: digit ii says whether xix_i is included in the subset. With 3 bits the numbers are 000,001,010,011,100,101,110,111000, 001, 010, 011, 100, 101, 110, 111, one for each subset.

elementabcdsubsetbits 01010101{b, d}bits 00000000∅ (empty set)bits 11111111{a, b, c, d} = Xbits 11001100{a, b}bits 10101010{a, c}Digit i says whether element i is included (1) or not (0)
Figure 19. For X = {a, b, c, d}: 0101 is {b, d}, 0000 is ∅, and 1111 is X
The same count, another way

There are 2n2^n different nn-bit binary numbers, and each one names exactly one subset. So a set with nn elements has 2n2^n subsets.

Example 8Power set of a 3-element set

List the power set of X={a,b,c}X = \{a, b, c\} and check the count.

Solution
  1. Size 0: ∅\emptyset.
  2. Size 1: {a},{b},{c}\{a\}, \{b\}, \{c\}.
  3. Size 2: {a,b},{a,c},{b,c}\{a, b\}, \{a, c\}, \{b, c\}.
  4. Size 3: {a,b,c}\{a, b, c\}.
  5. Total 1+3+3+1=8=231 + 3 + 3 + 1 = 8 = 2^3. The power set is {∅,{a},{b},{c},{a,b},{a,c},{b,c},{a,b,c}}\{\emptyset, \{a\}, \{b\}, \{c\}, \{a, b\}, \{a, c\}, \{b, c\}, \{a, b, c\}\}.
Example 9Counting subsets

A set SS has 5 elements. How many subsets does it have? How many of them are proper subsets?

Solution
  1. Each of the 5 elements is either in or out: 25=322^5 = 32 subsets.
  2. A proper subset must not equal SS. Exactly one subset equals SS itself (all bits 1).
  3. Proper subsets: 32−1=3132 - 1 = 31. (This count includes ∅\emptyset.)
Example 10Subset or not?

Let X={1,2,5,7,9,300}X = \{1, 2, 5, 7, 9, 300\} and Y={0,1,2,5,7,9,40,170,300}Y = \{0, 1, 2, 5, 7, 9, 40, 170, 300\}. Is X⊆YX \subseteq Y? Is X⊂YX \subset Y?

Solution
  1. Check each element of XX: 1, 2, 5, 7, 9 and 300 all appear in YY. So X⊆YX \subseteq Y.
  2. YY has elements not in XX (for example 0), so X≠YX \neq Y.
  3. Therefore XX is a proper subset: X⊂YX \subset Y.

4.7Going deeper: ∈\in versus ⊆\subseteq, and sets inside sets

Most mistakes in this chapter come from mixing up elements and subsets. For X={a,b}X = \{a, b\}:

StatementTrue?Reason
a∈Xa \in Xtruea is an element of X
{a}⊆X\{a\} \subseteq Xtrueevery element of {a} is in X
a⊆Xa \subseteq Xfalsea is not a set
{a}∈X\{a\} \in Xfalsethe elements of X are a and b, not {a}
∅⊆X\emptyset \subseteq Xtruethe empty set is a subset of every set
∅∈X\emptyset \in XfalseX does not list ∅\emptyset as an element
X⊆XX \subseteq Xtrueevery set is a subset of itself
X∈XX \in XfalseX is not one of its own elements
  • A set can contain sets. Let Y={∅,{a}}Y = \{\emptyset, \{a\}\}. Its elements are ∅\emptyset and {a}\{a\}, so ∣Y∣=2|Y| = 2, ∅∈Y\emptyset \in Y is true, {a}∈Y\{a\} \in Y is true, but a∈Ya \in Y is false.
  • ∅\emptyset versus {∅}\{\emptyset\}. ∣∅∣=0|\emptyset| = 0 but ∣{∅}∣=1|\{\emptyset\}| = 1: it is a set holding one element, the empty set.
  • Cardinality ignores repeats. {1,2,2,3,3,3}={1,2,3}\{1, 2, 2, 3, 3, 3\} = \{1, 2, 3\}, so its cardinality is 3.
  • Counting subsets. nn elements give 2n2^n subsets. Of these, 2n−12^n - 1 are proper (all except the set itself), and 2n−12^{n-1} contain any one chosen element.

4.8Exam tips and common mistakes

Exam tips
  • Ask first: "is the left side an element or a set?" Use ∈\in for elements and ⊆\subseteq for sets.
  • When counting subsets include both ∅\emptyset and the set itself.
  • To show X=YX = Y, prove X⊆YX \subseteq Y and Y⊆XY \subseteq X.
Common mistakes
  • Writing a⊆Xa \subseteq X for an element, or {a}∈X\{a\} \in X when {a}\{a\} is not listed in XX.
  • Forgetting that ∅\emptyset is a subset of every set, and so is in every power set.
  • Counting duplicates when finding cardinality.
  • Treating ∅\emptyset and {∅}\{\emptyset\} as the same.

Practice questions (graded-assignment style)

Q1Cardinality

Numerical Answer Type (NAT).

What is the cardinality of {1,2,2,3,3,3}\{1, 2, 2, 3, 3, 3\}?

Solution
Idea

Duplicates do not matter in a set.

  • The set is {1,2,3}\{1, 2, 3\}.
  • It has 3 distinct elements.
  • Answer: 3
Q2Proper subsets

Numerical Answer Type (NAT).

A set has 4 elements. How many proper subsets does it have?

Solution
Idea

Total subsets are 2n2^n; remove the set itself.

  • Subsets: 24=162^4 = 16.
  • Only the set itself is not proper, so 16−1=1516 - 1 = 15 (this includes ∅\emptyset).
  • Answer: 15
Q3Sets inside a set

Multiple Select Question (MSQ): select all that apply.

Let Y={∅,{a}}Y = \{\emptyset, \{a\}\}. Choose the correct statements.

1
∅∈Y\emptyset \in Y
2
a∈Ya \in Y
3
{a}∈Y\{a\} \in Y
4
{a}⊆Y\{a\} \subseteq Y
Solution
Idea

List the elements of YY first: they are ∅\emptyset and {a}\{a\}.

  • Option 1 is true: ∅\emptyset is listed.
  • Option 2 is false: aa alone is not listed.
  • Option 3 is true: {a}\{a\} is listed.
  • Option 4 is false: it would need a∈Ya \in Y.
  • Answer: options 1 and 3.
Q4Element or subset?

Multiple Choice Question (MCQ): choose the one correct option.

Let X={a,b}X = \{a, b\}. Which statement is true?

1
a⊆Xa \subseteq X
2
{a}∈X\{a\} \in X
3
{a}⊆X\{a\} \subseteq X
4
X∈XX \in X
Solution
Idea

∈\in is for elements and ⊆\subseteq is for sets.

  • aa is an element, not a set, so option 1 is false.
  • XX lists aa and bb, not {a}\{a\}, so option 2 is false.
  • Option 3 is true: a∈Xa \in X.
  • Option 4 is false.
  • Answer: option 3.
Q5Binary code of a subset

Multiple Choice Question (MCQ): choose the one correct option.

For X={a,b,c,d}X = \{a, b, c, d\} the bit string 10101010 names which subset?

1
{a,c}\{a, c\}
2
{b,d}\{b, d\}
3
{a,b}\{a, b\}
4
{c,d}\{c, d\}
Solution
Idea

Bit i says whether the i-th element is included.

  • Bits 1 and 3 are 1, so aa and cc are included.
  • (Compare 01010101, which is {b,d}\{b, d\}.)
  • Answer: option 1.
Revision overview
SetsA collection of items (elements)
Finite or infinite
Items need not be the same type
Order & duplicatesSets are unordered
Duplicates do not matter
Cardinality |S| = number of items
Describing setsFinite: list explicitly
Infinite: cannot list; "…" is informal
Not every collection is a set
Sets: The BasicsWeek 1 · Sets
Membership & subsetsx ∈ X: x is an element of X
X ⊆ Y: all of X is in Y
X = Y iff X ⊆ Y and Y ⊆ X
Empty & power set∅ has no elements; ∅ ⊆ every set
Power set = set of all subsets
n elements give 2ⁿ subsets
Binary viewBit i: is element i included?
0101 ↔ {b, d} for {a, b, c, d}
2ⁿ bit strings ↔ 2ⁿ subsets
Revision: the basics of sets on one page
Next · Sets · Part 2 of 3Building Sets and Set Operations
05
Sets · Part 2 of 3

Building Sets and Set Operations

Listing elements only works for small finite sets. This topic shows the formal way to build a set from an existing one, how to describe ranges of real numbers as intervals, and how to combine sets with union, intersection, difference and complement.

5.1Set comprehension (set-builder form)

To describe an infinite set formally, start from a set we already have and keep only the elements that satisfy a condition. For example, the subset of even integers is

{x∣x∈Z, x mod 2=0}\{x \mid x \in \mathbb{Z},\ x \bmod 2 = 0\}
  1. Begin with an existing set, here Z\mathbb{Z}.
  2. Apply a condition to each element: x∈Zx \in \mathbb{Z} such that x mod 2=0x \bmod 2 = 0.
  3. Collect all the elements that match the condition.
Definition: set comprehension

Set comprehension constructs a subset from an existing set such as N,Z,R\mathbb{N}, \mathbb{Z}, \mathbb{R} by applying a filter to every element. It has three main components: a generator, a filter and a transformer.

Squares of the even integers{x²|x ∈ ℤ,x mod 2 = 0}Transformmodify eachkept elementGeneratedraw elementsfrom a setFilterkeep only thosethat pass
Figure 20. Reading a comprehension: what to output | where elements come from, which ones to keep
Generateevery x in ℤ−3−2−1012345Filterx mod 2 = 0✕−24✕00✕24✕416✕Transformx ↦ x²Collect the results: {0, 4, 16, 36, 64, …} (4 from −2 and from 2 counts once)
Figure 21. The squares of the even integers, built step by step
Perfect squares

{m∣m∈N, m∈N}\{m \mid m \in \mathbb{N},\ \sqrt{m} \in \mathbb{N}\}

Rationals in reduced form

{pq∣p,q∈Z, q≠0, gcd⁡(p,q)=1}\{\frac{p}{q} \mid p, q \in \mathbb{Z},\ q \neq 0,\ \gcd(p, q) = 1\}

5.2Intervals

Comprehension also describes ranges of numbers. The integers from −6-6 to 66 are {z∣z∈Z, −6≤z≤6}\{z \mid z \in \mathbb{Z},\ -6 \le z \le 6\}. For real numbers between 0 and 1 we must decide whether the endpoints are included, which gives four kinds of interval.

Closed interval{x | x ∈ ℝ, 0 ≤ x ≤ 1}[0, 1]01Open interval{x | x ∈ ℝ, 0 < x < 1}(0, 1)01Left open{x | x ∈ ℝ, 0 < x ≤ 1}(0, 1]01Right open{x | x ∈ ℝ, 0 ≤ x < 1}[0, 1)01filled dot: endpoint included · hollow dot: endpoint excluded
Figure 22. Square bracket: endpoint included. Round bracket: endpoint excluded
NameNotationSet comprehensionEndpoints
Closed interval[0,1][0, 1]{x∣x∈R, 0≤x≤1}\{x \mid x \in \mathbb{R},\ 0 \le x \le 1\}both included
Open interval(0,1)(0, 1){x∣x∈R, 0<x<1}\{x \mid x \in \mathbb{R},\ 0 < x < 1\}both excluded
Left open(0,1](0, 1]{x∣x∈R, 0<x≤1}\{x \mid x \in \mathbb{R},\ 0 < x \le 1\}only 1 included
Right open[0,1)[0, 1){x∣x∈R, 0≤x<1}\{x \mid x \in \mathbb{R},\ 0 \le x < 1\}only 0 included
Infinite ends. For unbounded ranges we write ∞\infty with a round bracket, never a square one, since ∞\infty is not a real number you can include. For example [0,∞)[0, \infty) is the set of non-negative reals.

5.3Union, intersection and difference

OperationMeaningNotationExample
Unioncombine XX and YYX∪YX \cup Y{a,b,c}∪{c,d,e}={a,b,c,d,e}\{a, b, c\} \cup \{c, d, e\} = \{a, b, c, d, e\}
Intersectionelements common to XX and YYX∩YX \cap Y{a,b,c,d}∩{a,d,e,f}={a,d}\{a, b, c, d\} \cap \{a, d, e, f\} = \{a, d\}
Set differenceelements in XX that are not in YYX−YX - Y or X∖YX \setminus Y{a,b,c,d}−{a,d,e,f}={b,c}\{a, b, c, d\} - \{a, d, e, f\} = \{b, c\}
In a union, an element that is in both sets (like cc above) is written once, because duplicates do not matter.

5.4Complement

Definition: complement

The complement of XX is the set of elements not in XX, written X‾\overline{X} or XcX^c. It only makes sense relative to a larger set, called the universe UU: Xc=U−XX^c = U - X.

  • Inside N\mathbb{N}, the complement of the set of primes is the set of composite numbers, together with 0 and 1 (which are neither prime nor composite).
  • Inside Z\mathbb{Z}, the complement of the even integers is the odd integers.
X ∪ YUXYin X or in Y (or both)X ∩ YUXYin both X and YX − Y or X \ YUXYin X but not in YXᶜ (complement)UXYnot in X (inside U)
Figure 23. The four operations as shaded regions (U is the universe)
Example 11All four operations

Let U={a,b,c,d,e,f,g,h}U = \{a, b, c, d, e, f, g, h\}, X={a,b,c,d}X = \{a, b, c, d\} and Y={a,d,e,f}Y = \{a, d, e, f\}. Find X∪YX \cup Y, X∩YX \cap Y, X−YX - Y, Y−XY - X and XcX^c.

Solution
UXYbcadefghX only: b, c= X − YY only: e, f= Y − Xmiddle: a, d = X ∩ Youtside both: g, h
Figure 24. Place each element in its region first; every answer can then be read off
SetRead from the diagramAnswer
X∪YX \cup Yeverything inside either circle{a,b,c,d,e,f}\{a, b, c, d, e, f\}
X∩YX \cap Ythe middle region{a,d}\{a, d\}
X−YX - Ythe left-only region{b,c}\{b, c\}
Y−XY - Xthe right-only region{e,f}\{e, f\}
XcX^ceverything in UU outside the XX circle{e,f,g,h}\{e, f, g, h\}

Notice X−Y≠Y−XX - Y \neq Y - X: set difference depends on the order.

Example 12Intervals with comprehension

Write "the real numbers from −1-1 to 2, including −1-1 but not 2" as an interval and as a set comprehension. Is 2 in it? Is −1-1?

Solution
  1. −1-1 is included (square bracket) and 2 is excluded (round bracket): [−1,2)[-1, 2).
  2. As a comprehension: {r∣r∈R, −1≤r<2}\{r \mid r \in \mathbb{R},\ -1 \le r < 2\}.
  3. −1∈[−1,2)-1 \in [-1, 2) because −1≤−1-1 \le -1. But 2∉[−1,2)2 \notin [-1, 2) because 2<22 < 2 is false.

5.5Going deeper: reading comprehensions and intervals

  • Read a comprehension like a loop. For {x2∣x∈Z, x mod 2=0}\{x^2 \mid x \in \mathbb{Z},\ x \bmod 2 = 0\}: take each xx from Z\mathbb{Z}, keep it if xx is even, then output x2x^2. Result: {0,4,16,36,… }\{0, 4, 16, 36, \dots\}.
  • The filter acts before the transform. {x2∣x∈{1,2,3,4}, x>2}={9,16}\{x^2 \mid x \in \{1, 2, 3, 4\},\ x > 2\} = \{9, 16\}, because only 3 and 4 pass the filter and are then squared.
  • Interval algebra. Draw both intervals on a number line and watch the endpoints.
ExpressionResultWhy
[0,2)∪[1,3][0, 2) \cup [1, 3][0,3][0, 3]together they cover 0 up to 3, both ends included
[0,2)∩[1,3][0, 2) \cap [1, 3][1,2)[1, 2)1 is in both; 2 is excluded from the first
[0,3]−(1,2)[0, 3] - (1, 2)[0,1]∪[2,3][0, 1] \cup [2, 3]removing the open middle keeps 1 and 2
complement of [0,1)[0, 1) in R\mathbb{R}(−∞,0)∪[1,∞)(-\infty, 0) \cup [1, \infty)everything outside; 1 is now included
  • Difference as intersection. X−Y=X∩YcX - Y = X \cap Y^c: "in XX and not in YY". And X−Y≠Y−XX - Y \neq Y - X in general.
  • Words to symbols. "or" means union, "and" means intersection, "not in" means difference or complement.

5.6Exam tips and common mistakes

Exam tips
  • Draw a quick number line for interval questions and mark open and closed ends.
  • Place each element of the universe in its region first, then read off every answer.
  • For a complement, always say which universe UU you are using.
Common mistakes
  • Using a square bracket next to ∞\infty. It is always (…,∞)(\ldots, \infty).
  • Confusing ∪\cup (or) with ∩\cap (and).
  • Assuming X−Y=Y−XX - Y = Y - X.
  • Writing a complement with no universe.

Practice questions (graded-assignment style)

Q1Intersect intervals

Multiple Choice Question (MCQ): choose the one correct option.

What is [1,5)∩(3,8][1, 5) \cap (3, 8]?

1
[3,5)[3, 5)
2
(3,5)(3, 5)
3
(3,5](3, 5]
4
[1,8][1, 8]
Solution
Idea

Take the larger left end and the smaller right end, and keep each end only if both intervals keep it.

  • xx must satisfy 1≤x<51 \le x < 5 and 3<x≤83 < x \le 8, so 3<x<53 < x < 5.
  • Neither end is included: the answer is the open interval (3, 5).
  • Answer: option 2.
Q2Size of a comprehension

Numerical Answer Type (NAT).

How many elements does {x2∣x∈Z, −3≤x≤3}\{x^2 \mid x \in \mathbb{Z},\ -3 \le x \le 3\} have?

Solution
Idea

List the squares, and remember that duplicates count once.

  • x=−3,…,3x = -3, \dots, 3 gives 9,4,1,0,1,4,99, 4, 1, 0, 1, 4, 9.
  • As a set this is {0,1,4,9}\{0, 1, 4, 9\}, which has 4 elements.
  • Answer: 4
Q3Set operations

Multiple Select Question (MSQ): select all that apply.

Let U={1,…,8}U = \{1, \dots, 8\}, X={1,2,3,4}X = \{1, 2, 3, 4\} and Y={3,4,5,6}Y = \{3, 4, 5, 6\}. Choose the correct statements.

1
X∩Y={3,4}X \cap Y = \{3, 4\}
2
X−Y={1,2}X - Y = \{1, 2\}
3
Y−X={1,2}Y - X = \{1, 2\}
4
Xc={5,6}X^c = \{5, 6\}
Solution
Idea

Place each element in its region first.

  • Options 1 and 2 are correct.
  • Option 3: Y−X={5,6}Y - X = \{5, 6\}.
  • Option 4: Xc=U−X={5,6,7,8}X^c = U - X = \{5, 6, 7, 8\}.
  • Answer: options 1 and 2.
Q4Read the interval

Multiple Choice Question (MCQ): choose the one correct option.

Which set is [0,1)[0, 1)?

1
{x∈R∣0<x≤1}\{x \in \mathbb{R} \mid 0 < x \le 1\}
2
{x∈R∣0≤x<1}\{x \in \mathbb{R} \mid 0 \le x < 1\}
3
{x∈R∣0<x<1}\{x \in \mathbb{R} \mid 0 < x < 1\}
4
{x∈R∣0≤x≤1}\{x \in \mathbb{R} \mid 0 \le x \le 1\}
Solution
Idea

Square bracket includes the end, round excludes it.

  • 0 is included and 1 is excluded.
  • That is 0≤x<10 \le x < 1.
  • Answer: option 2.
Revision overview
Set comprehension{ x | x ∈ ℤ, x mod 2 = 0 }
Begin with an existing set
Filter, then collect
Three partsGenerator: where elements come from
Filter: which ones to keep
Transform: modify kept ones
Intervals[0, 1] closed: ends included
(0, 1) open: ends excluded
(0, 1] left open, [0, 1) right open
Building Sets & OperationsWeek 1 · Sets
Union & intersectionX ∪ Y: in X or Y
X ∩ Y: in both
Shared elements written once
DifferenceX − Y = X \ Y: in X, not Y
{a,b,c,d} − {a,d,e,f} = {b,c}
X − Y ≠ Y − X in general
ComplementXᶜ: elements not in X
Relative to a universe U
Primes in ℕ → composites, 0, 1
Revision: building and combining sets on one page
Next · Sets · Part 3 of 3Sets in Action
06
Sets · Part 3 of 3

Sets in Action

This topic puts set comprehension to work on a set of examples, and then uses Venn diagrams to solve counting problems. The aim is fluency: reading and writing comprehensions quickly, and picking the right region of a Venn diagram.

6.1Generator, filter, transform: more examples

SetSet comprehensionGeneratorFilterTransform
Squares of even integers{x2∣x∈Z, x mod 2=0}\{x^2 \mid x \in \mathbb{Z},\ x \bmod 2 = 0\}x∈Zx \in \mathbb{Z}x mod 2=0x \bmod 2 = 0x2x^2
Rationals in reduced form{pq∣pq∈Q, gcd⁡(p,q)=1}\{\frac{p}{q} \mid \frac{p}{q} \in \mathbb{Q},\ \gcd(p, q) = 1\}pq∈Q\frac{p}{q} \in \mathbb{Q}gcd⁡(p,q)=1\gcd(p, q) = 1none
Reals in [−1,2)[-1, 2){r∣r∈R, −1≤r<2}\{r \mid r \in \mathbb{R},\ -1 \le r < 2\}r∈Rr \in \mathbb{R}−1≤r<2-1 \le r < 2none
Cubes of first 5 naturals{n3∣n∈{0,1,2,3,4}}\{n^3 \mid n \in \{0, 1, 2, 3, 4\}\}n∈{0,…,4}n \in \{0, \dots, 4\}nonen3n^3
A comprehension does not need all three parts. With no filter, every generated element is kept; with no transform, kept elements are output unchanged.
Example 13Cubes of the first 500 natural numbers

Use set comprehension to describe the set of cubes of the first 500 natural numbers, in a readable way.

Solution
  1. Listing the generator is clumsy: Y={n3∣n∈{0,1,2,3,…,498,499}}Y = \{n^3 \mid n \in \{0, 1, 2, 3, \dots, 498, 499\}\}.
  2. First use comprehension to define the first 500 natural numbers: X={n∣n∈N, n<500}X = \{n \mid n \in \mathbb{N},\ n < 500\}.
  3. Now generate from XX: Y={n3∣n∈X}Y = \{n^3 \mid n \in X\}. This is the more readable version.
  4. Check the small case: with {0,1,2,3,4}\{0, 1, 2, 3, 4\} as generator we get {0,1,8,27,64}\{0, 1, 8, 27, 64\}.

6.2Perfect squares, three ways

  • Integers whose square root is also an integer: {z∣z∈Z, z∈Z}\{z \mid z \in \mathbb{Z},\ \sqrt{z} \in \mathbb{Z}\}.
  • All squares are non-negative, so this is the same as {n∣n∈N, n∈N}\{n \mid n \in \mathbb{N},\ \sqrt{n} \in \mathbb{N}\} (a filter).
  • Alternatively, generate all the perfect squares directly: {n2∣n∈N}\{n^2 \mid n \in \mathbb{N}\} (a transform).
Filter{n | n ∈ ℕ, √n ∈ ℕ}0123456789…Generate{n² | n ∈ ℕ}00112439…Both give the same set: {0, 1, 4, 9, 16, 25, …}
Figure 25. Filtering ℕ and transforming ℕ reach the same set
Extending the definition to rationals

916=(34)2\frac{9}{16} = \left(\frac{3}{4}\right)^2 is a square of a rational, but 12≠(pq)2\frac{1}{2} \neq \left(\frac{p}{q}\right)^2 for any p,qp, q. The squares of rationals are {q∣q∈Q, q∈Q}\{q \mid q \in \mathbb{Q},\ \sqrt{q} \in \mathbb{Q}\} or, generating them, {q2∣q∈Q}\{q^2 \mid q \in \mathbb{Q}\}.

6.3Counting with Venn diagrams

When two sets overlap, adding their sizes counts the overlap twice. Subtracting it once gives the size of the union:

n(P∪B)=n(P)+n(B)−n(P∩B)n(P \cup B) = n(P) + n(B) - n(P \cap B)

Here n(X)n(X) is the number of elements of XX (the same as ∣X∣|X|). A Venn diagram splits the class into four regions: P only, both, B only, and neither. Fill in the region you know best (usually "both") first, then work outwards.

Regions add up. With a universe UU (the whole class): n(U)=n(P only)+n(both)+n(B only)+n(neither)n(U) = n(P \text{ only}) + n(\text{both}) + n(B \text{ only}) + n(\text{neither}), and n(neither)=n(U)−n(P∪B)n(\text{neither}) = n(U) - n(P \cup B).
Example 14How many students in the class?

In a class, 30 students took Physics, 25 took Biology, 10 took both, and 5 took neither. How many students are there in the class?

Solution
Physics (P)Biology (B)20P only10both15B onlyClassneither 5
Figure 26. Start from the middle: 10 took both
  1. Draw sets for Physics (PP) and Biology (BB). 10 students are in P∩BP \cap B.
  2. This leaves 30−10=2030 - 10 = 20 students in P∖BP \setminus B (took Physics but not Biology).
  3. Likewise 25−10=1525 - 10 = 15 students in B∖PB \setminus P (took Biology but not Physics).
  4. 5 students are outside P∪BP \cup B: in the class but took neither.
  5. Class strength: 20+10+15+5=5020 + 10 + 15 + 5 = 50.
Example 15Biology but not Physics

In a class of 55 students, 32 took Physics, 11 took both Physics and Biology, and 7 took neither. How many took Biology but not Physics?

Solution
Physics (P)Biology (B)21P only11bothxB onlyU = 55 studentsneither 7
Figure 27. The unknown region is B only
  1. Physics only: 32−11=2132 - 11 = 21.
  2. Let xx = number who took Biology but not Physics. The four regions add up to the class: 55=x+11+21+755 = x + 11 + 21 + 7.
  3. So 55=x+3955 = x + 39, giving x=55−39=16x = 55 - 39 = 16.
  4. 16 students took Biology but not Physics.
Example 16Both subjects

In a class of 60 students, 35 took Physics, 30 took Biology, and 10 took neither. How many took both Physics and Biology?

Solution
Physics (P)Biology (B)?P only?both?B only60 studentsneither 10
Figure 28. Here the middle is the unknown, so use the formula
  1. Students who took at least one subject: n(P∪B)=60−10=50n(P \cup B) = 60 - 10 = 50.
  2. n(P)=35n(P) = 35 and n(B)=30n(B) = 30, so n(P)+n(B)=35+30=65n(P) + n(B) = 35 + 30 = 65.
  3. From n(P∪B)=n(P)+n(B)−n(P∩B)n(P \cup B) = n(P) + n(B) - n(P \cap B): 50=65−n(P∩B)50 = 65 - n(P \cap B).
  4. Thus n(P∩B)=65−50=15n(P \cap B) = 65 - 50 = 15. (Then Physics only = 20 and Biology only = 15; check: 20+15+15+10=6020 + 15 + 15 + 10 = 60.)

6.4Summary

  • Set notation is a useful way to concisely describe collections of objects.
  • Set comprehension combines generators, filters and transformations to produce new sets from old.
  • Venn diagrams are useful to work out problems involving sets.

6.5Going deeper: a method for Venn problems

Every two-set counting problem uses the same four regions. Follow this order:

  1. Write the total n(U)n(U), the two set sizes, the overlap n(P∩B)n(P \cap B) and the "neither" count, marking which ones are unknown.
  2. Find the union: n(P∪B)=n(U)−n(neither)n(P \cup B) = n(U) - n(\text{neither}).
  3. Use n(P∪B)=n(P)+n(B)−n(P∩B)n(P \cup B) = n(P) + n(B) - n(P \cap B) to find whichever of the three is missing.
  4. Fill the regions: P only =n(P)−n(both)= n(P) - n(\text{both}), B only =n(B)−n(both)= n(B) - n(\text{both}).
  5. Check that the four regions add up to the total.
Question wordingFormula
At least one subjectn(P∪B)n(P \cup B)
Both subjectsn(P∩B)n(P \cap B)
Only Physicsn(P)−n(P∩B)n(P) - n(P \cap B)
Exactly one subjectn(P)+n(B)−2 n(P∩B)n(P) + n(B) - 2\,n(P \cap B)
At most one subjectn(U)−n(P∩B)n(U) - n(P \cap B)
Neithern(U)−n(P∪B)n(U) - n(P \cup B)
  • Filter or generate. The perfect squares can be written by filtering {n∈N∣n∈N}\{n \in \mathbb{N} \mid \sqrt{n} \in \mathbb{N}\} or by generating {n2∣n∈N}\{n^2 \mid n \in \mathbb{N}\}. Both give {0,1,4,9,… }\{0, 1, 4, 9, \dots\}.

6.6Laws of set operations, De Morgan's laws and counting with three sets

The operations ∪\cup, ∩\cap, −- and complement obey a short list of laws. Knowing them lets you simplify a set expression instead of testing it element by element.

A. The laws (for subsets of a universal set UU)

LawStatement
CommutativeA∪B=B∪AA \cup B = B \cup A, A∩B=B∩AA \cap B = B \cap A
Associative(A∪B)∪C=A∪(B∪C)(A \cup B) \cup C = A \cup (B \cup C), same for ∩\cap
DistributiveA∩(B∪C)=(A∩B)∪(A∩C)A \cap (B \cup C) = (A \cap B) \cup (A \cap C) and A∪(B∩C)=(A∪B)∩(A∪C)A \cup (B \cap C) = (A \cup B) \cap (A \cup C)
Identity and dominationA∪∅=AA \cup \emptyset = A, A∩U=AA \cap U = A, A∪U=UA \cup U = U, A∩∅=∅A \cap \emptyset = \emptyset
ComplementA∪Ac=UA \cup A^c = U, A∩Ac=∅A \cap A^c = \emptyset, (Ac)c=A(A^c)^c = A
De Morgan(A∪B)c=Ac∩Bc(A \cup B)^c = A^c \cap B^c and (A∩B)c=Ac∪Bc(A \cap B)^c = A^c \cup B^c
DifferenceA−B=A∩BcA - B = A \cap B^c
Subset equivalencesA⊆B  ⟺  A∪B=B  ⟺  A∩B=A  ⟺  Bc⊆AcA \subseteq B \iff A \cup B = B \iff A \cap B = A \iff B^c \subseteq A^c

De Morgan in words. "Not (in AA or in BB)" means "not in AA and not in BB". "Not (in AA and in BB)" means "not in AA or not in BB". The complement swaps ∪\cup and ∩\cap.

Proof of the first law. x∈(A∪B)c  ⟺  x∉A∪B  ⟺  (x∉A and x∉B)  ⟺  x∈Ac∩Bcx \in (A \cup B)^c \iff x \notin A \cup B \iff (x \notin A \text{ and } x \notin B) \iff x \in A^c \cap B^c. ■\blacksquare

Numeric check. U={1,…,10}U = \{1, \dots, 10\}, A={1,2,3,4}A = \{1, 2, 3, 4\}, B={3,4,5,6}B = \{3, 4, 5, 6\}. Then A∪B={1,…,6}A \cup B = \{1, \dots, 6\}, so (A∪B)c={7,8,9,10}(A \cup B)^c = \{7, 8, 9, 10\}. Also Ac={5,…,10}A^c = \{5, \dots, 10\} and Bc={1,2,7,8,9,10}B^c = \{1, 2, 7, 8, 9, 10\}, so Ac∩Bc={7,8,9,10}A^c \cap B^c = \{7, 8, 9, 10\} ✓.

B. Symmetric difference

A△BA \triangle B is the set of elements in exactly one of AA and BB: A△B=(A−B)∪(B−A)=(A∪B)−(A∩B)A \triangle B = (A - B) \cup (B - A) = (A \cup B) - (A \cap B). Its size is

∣A△B∣=∣A∣+∣B∣−2∣A∩B∣|A \triangle B| = |A| + |B| - 2|A \cap B|

(the overlap is removed from both). For AA and BB above: A△B={1,2,5,6}A \triangle B = \{1, 2, 5, 6\}, and 4+4−2⋅2=44 + 4 - 2 \cdot 2 = 4 ✓.

C. Counting with three sets

Inclusion–exclusion for three sets
∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|

Add the singles, subtract the pairwise overlaps (each pair was counted twice), and add back the triple overlap (it was added three times and subtracted three times, so it vanished).

Example. Of 100 students, 60 take Maths (M), 50 Physics (P), 40 Chemistry (C); 30 take M and P, 20 take M and C, 15 take P and C, and 10 take all three.

  • At least one subject: 60+50+40−30−20−15+10=9560 + 50 + 40 - 30 - 20 - 15 + 10 = 95. So 100−95=5100 - 95 = 5 take none.
  • Only Maths: 60−30−20+10=2060 - 30 - 20 + 10 = 20. Only Physics: 50−30−15+10=1550 - 30 - 15 + 10 = 15. Only Chemistry: 40−20−15+10=1540 - 20 - 15 + 10 = 15. Exactly one subject: 20+15+15=5020 + 15 + 15 = 50.
  • Exactly two subjects: (30−10)+(20−10)+(15−10)=35(30 - 10) + (20 - 10) + (15 - 10) = 35. All three: 1010.
  • Check: 50+35+10+5=10050 + 35 + 10 + 5 = 100 ✓.
"At least" versus "exactly". The pair counts ∣M∩P∣|M \cap P| etc. include the students who take all three. To get "exactly two", subtract the triple count from each pair first.

6.7Exam tips and common mistakes

Exam tips
  • Always draw the diagram, even when the formula looks easy.
  • Start from the region you know best, usually "both".
  • Finish by checking that all four regions sum to the class strength.
Common mistakes
  • Treating n(P)n(P) as "Physics only". It includes the students who took both.
  • Adding n(P)+n(B)n(P) + n(B) and forgetting to subtract the overlap, so the middle is counted twice.
  • Forgetting the "neither" region when computing the class total.

Practice questions (graded-assignment style)

Q1Both subjects

Numerical Answer Type (NAT).

In a class of 80, 50 took Physics, 45 took Biology and 15 took neither. How many took both?

Solution
Idea

Find the union first.

  • n(P∪B)=80−15=65n(P \cup B) = 80 - 15 = 65.
  • 65=50+45−n(P∩B)65 = 50 + 45 - n(P \cap B), so n(P∩B)=95−65=30n(P \cap B) = 95 - 65 = 30.
  • Answer: 30
Q2Exactly one subject

Numerical Answer Type (NAT).

In a class of 40, 22 took Maths, 18 took Computer Science and 8 took both. How many took exactly one of the two?

Solution
Idea

Remove the overlap from each side.

  • Maths only: 22−8=1422 - 8 = 14. CS only: 18−8=1018 - 8 = 10.
  • Exactly one: 14+10=2414 + 10 = 24.
  • (Neither would be 40−(14+8+10)=840 - (14 + 8 + 10) = 8.)
  • Answer: 24
Q3The union formula

Multiple Choice Question (MCQ): choose the one correct option.

Which formula gives n(P∪B)n(P \cup B)?

1
n(P)+n(B)n(P) + n(B)
2
n(P)+n(B)−n(P∩B)n(P) + n(B) - n(P \cap B)
3
n(P)⋅n(B)n(P) \cdot n(B)
4
n(P)−n(B)n(P) - n(B)
Solution
Idea

Adding both sizes counts the overlap twice.

  • Subtract the overlap once to count it once.
  • Answer: option 2.
Q4Equal sets

Multiple Choice Question (MCQ): choose the one correct option.

Which set equals {n2∣n∈N}\{n^2 \mid n \in \mathbb{N}\}?

1
{n∈N∣n∈N}\{n \in \mathbb{N} \mid \sqrt{n} \in \mathbb{N}\}
2
{2n∣n∈N}\{2n \mid n \in \mathbb{N}\}
3
{n3∣n∈N}\{n^3 \mid n \in \mathbb{N}\}
4
{n∈N∣n>0}\{n \in \mathbb{N} \mid n > 0\}
Solution
Idea

Squares can be generated or filtered.

  • A natural number has a natural square root exactly when it is a perfect square.
  • Options 2, 3 and 4 give evens, cubes and positives.
  • Answer: option 1.
S1De Morgan

Multiple Choice Question (MCQ): choose the one correct option.

Which set equals (A∪B)c(A \cup B)^c?

1
Ac∪BcA^c \cup B^c
2
Ac∩BcA^c \cap B^c
3
Ac−BcA^c - B^c
4
(A∩B)c(A \cap B)^c
Solution
Idea

Not in the union means in neither set.

  • x∉A∪Bx \notin A \cup B means x∉Ax \notin A and x∉Bx \notin B, i.e. x∈Ac∩Bcx \in A^c \cap B^c.
  • Option 1 is (A∩B)c(A \cap B)^c, the other De Morgan law, which equals option 4. Check with A={1}A = \{1\}, B={2}B = \{2\}, U={1,2,3}U = \{1, 2, 3\}: (A∪B)c={3}(A \cup B)^c = \{3\}, while Ac∪Bc={1,2,3}A^c \cup B^c = \{1, 2, 3\}.
  • Answer: option 2.
S2Students taking none of three subjects

Numerical Answer Type (NAT).

Of 100 students, 60 take Maths, 50 Physics and 40 Chemistry; 30 take Maths and Physics, 20 take Maths and Chemistry, 15 take Physics and Chemistry, and 10 take all three. How many take none of the three?

Solution
Idea

Count the union by inclusion–exclusion, then subtract from the total.

  • ∣M∪P∪C∣=60+50+40−30−20−15+10=95|M \cup P \cup C| = 60 + 50 + 40 - 30 - 20 - 15 + 10 = 95.
  • None =100−95=5= 100 - 95 = 5.
  • Answer: 5
S3Exactly one subject

Numerical Answer Type (NAT).

In the same class, how many students take exactly one of the three subjects?

Solution
Idea

For "only Maths", remove from 60 everyone who also takes Physics or Chemistry, and add back the triple overlap that was removed twice.

  • Only Maths: 60−30−20+10=2060 - 30 - 20 + 10 = 20.
  • Only Physics: 50−30−15+10=1550 - 30 - 15 + 10 = 15. Only Chemistry: 40−20−15+10=1540 - 20 - 15 + 10 = 15.
  • Total =20+15+15=50= 20 + 15 + 15 = 50. Check: exactly two =20+10+5=35= 20 + 10 + 5 = 35, all three =10= 10, none =5= 5; 50+35+10+5=10050 + 35 + 10 + 5 = 100 ✓.
  • Answer: 50
S4True or false: set identities

Multiple Select Question (MSQ): select all that apply.

Choose the correct statements for subsets A,B,CA, B, C of a universal set UU.

1
A−B=A∩BcA - B = A \cap B^c
2
(A∩B)c=Ac∩Bc(A \cap B)^c = A^c \cap B^c
3
A∪(B∩C)=(A∪B)∩(A∪C)A \cup (B \cap C) = (A \cup B) \cap (A \cup C)
4
A⊆BA \subseteq B if and only if Bc⊆AcB^c \subseteq A^c
5
∣A△B∣=∣A∣+∣B∣−∣A∩B∣|A \triangle B| = |A| + |B| - |A \cap B|
Solution
Idea

Match each with the laws, and test a false-looking one on a tiny example.

  • 1 ✓ x∈A−Bx \in A - B means x∈Ax \in A and x∉Bx \notin B.
  • 2 ✗ De Morgan gives (A∩B)c=Ac∪Bc(A \cap B)^c = A^c \cup B^c. With A={1}A = \{1\}, B={2}B = \{2\}, U={1,2}U = \{1, 2\}: (A∩B)c=U(A \cap B)^c = U, but Ac∩Bc={2}∩{1}=∅A^c \cap B^c = \{2\} \cap \{1\} = \emptyset.
  • 3 ✓ The second distributive law.
  • 4 ✓ The contrapositive form: anything outside BB is outside AA.
  • 5 ✗ It is ∣A∣+∣B∣−2∣A∩B∣|A| + |B| - 2|A \cap B|; the formula in the option is ∣A∪B∣|A \cup B|.
  • Answer: options 1, 3 and 4.
S5Size of a symmetric difference

Numerical Answer Type (NAT).

A={1,2,3,4}A = \{1, 2, 3, 4\} and B={3,4,5,6}B = \{3, 4, 5, 6\}. Find ∣A△B∣|A \triangle B|.

Solution
Idea

Elements in exactly one of the two sets.

  • A∩B={3,4}A \cap B = \{3, 4\}, so ∣A∩B∣=2|A \cap B| = 2. ∣A△B∣=4+4−2⋅2=4|A \triangle B| = 4 + 4 - 2 \cdot 2 = 4.
  • Direct: A−B={1,2}A - B = \{1, 2\} and B−A={5,6}B - A = \{5, 6\}, so A△B={1,2,5,6}A \triangle B = \{1, 2, 5, 6\} ✓.
  • Answer: 4
Revision overview
Comprehension practiceSquares of evens: {x² | x ∈ ℤ, x mod 2 = 0}
Reals in [−1, 2): −1 ≤ r < 2
Not every part is needed
Readable definitionsX = {n | n ∈ ℕ, n < 500}
Y = {n³ | n ∈ X}
Name a set, then reuse it
Perfect squaresFilter: {n | √n ∈ ℕ}
Generate: {n² | n ∈ ℕ}
Rationals: 9/16 = (3/4)², but not 1/2
Sets in ActionWeek 1 · Sets
Venn regionsP only, both, B only, neither
Fill "both" first, work outwards
All four regions add up to the total
Union formulan(P ∪ B) = n(P) + n(B) − n(P ∩ B)
Overlap is counted twice otherwise
Neither = total − n(P ∪ B)
Revision: set examples and counting on one page
Next · Relations · Part 1 of 2Relations
07
Relations · Part 1 of 2

Relations

Sets on their own just collect objects. To talk about how objects are connected (one number dividing another, a student taking a course, a point lying on a circle) we pair elements up. Pairs come from the Cartesian product, and a relation is simply a chosen collection of pairs.

7.1Cartesian product

Definition: Cartesian product

The Cartesian product of sets AA and BB is the set of all ordered pairs with the first element from AA and the second from BB:

A×B={(a,b)∣a∈A, b∈B}A \times B = \{(a, b) \mid a \in A,\ b \in B\}
  • Pair up elements from AA and BB: if A={0,1}A = \{0, 1\} and B={2,3}B = \{2, 3\}, then A×B={(0,2),(0,3),(1,2),(1,3)}A \times B = \{(0, 2), (0, 3), (1, 2), (1, 3)\}.
  • In a pair, the order is important: (0,1)≠(1,0)(0, 1) \neq (1, 0).
  • For sets of numbers, visualise the product as two-dimensional space: N×N\mathbb{N} \times \mathbb{N} is a grid of points.
  • For finite sets, ∣A×B∣=∣A∣⋅∣B∣|A \times B| = |A| \cdot |B|: each of the ∣A∣|A| choices of first entry pairs with each of the ∣B∣|B| choices of the second.
A × B123a(a, 1)(a, 2)(a, 3)b(b, 1)(b, 2)(b, 3)row from A, column from B: every pair appears onceSize of the product|A × B| = 2 × 3 = 6Order matters(a, 1) ≠ (1, a)
Figure 29. A × B for A = {a, b} and B = {1, 2, 3}: six ordered pairs

7.2Binary relations

A relation selects some pairs from the Cartesian product. The natural way to do that is to combine the Cartesian product with set comprehension:

{(m,n)∣(m,n)∈N×N, n=m+1}={(0,1),(1,2),(2,3),…,(17,18),… }\{(m, n) \mid (m, n) \in \mathbb{N} \times \mathbb{N},\ n = m + 1\} = \{(0, 1), (1, 2), (2, 3), \dots, (17, 18), \dots\}
{(d,n)∣(d,n)∈N×N, d∣n}={(1,1),…,(2,82),…,(14,56),… }\{(d, n) \mid (d, n) \in \mathbb{N} \times \mathbb{N},\ d \mid n\} = \{(1, 1), \dots, (2, 82), \dots, (14, 56), \dots\}
Definition: binary relation

A binary relation from AA to BB is a subset of the Cartesian product: R⊆A×BR \subseteq A \times B. If (a,b)∈R(a, b) \in R we also write a R ba\,R\,b and say "aa is related to bb".

{(m, n) | n = m + 1}1122334455667788mn{(d, n) | d divides n}, d ≥ 11122334455667788mnEach grid point is a pair in ℕ × ℕ; the coloured points are the pairs the relation selects
Figure 30. Two relations on ℕ × ℕ, seen as chosen points of the grid

With A={a,b}A = \{a, b\} and B={1,2,3}B = \{1, 2, 3\}, each of these is a relation from AA to BB, because each is a subset of A×BA \times B:

RelationPairsNote
R1R_1{(a,1),(b,2),(b,3)}\{(a, 1), (b, 2), (b, 3)\}bb is related to two elements
R2R_2{(a,2),(b,1)}\{(a, 2), (b, 1)\}
R3R_3{(b,3)}\{(b, 3)\}aa is related to nothing
R4R_4{(a,1),(a,2),(a,3),(b,1),(b,2),(b,3)}\{(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)\}all of A×BA \times B
ABab123R₁ = {(a,1), (b,2), (b,3)}ABab123R₂ = {(a,2), (b,1)}
Figure 31. A relation drawn as arrows from A to B
Two extreme relations. The empty set ∅\emptyset is a relation (nothing is related), and A×BA \times B itself is a relation (everything is related). A relation is any subset, so there are 2∣A∣⋅∣B∣2^{|A| \cdot |B|} relations from AA to BB when both are finite.

7.3More relations

Points at distance 5 from (0,0)(0, 0). The distance from (0,0)(0, 0) to (a,b)(a, b) is a2+b2\sqrt{a^2 + b^2}, so the relation is

{(a,b)∣(a,b)∈R×R, a2+b2=5}={(0,5),(5,0),(3,4),(−3,−4),… }\{(a, b) \mid (a, b) \in \mathbb{R} \times \mathbb{R},\ \sqrt{a^2 + b^2} = 5\} = \{(0, 5), (5, 0), (3, 4), (-3, -4), \dots\}
−6−6−4−4−2−2224466ab5(0, 5)(3, 4)(5, 0)(−3, −4)Relation on ℝ × ℝ:√(a² + b²) = 5The related pairs form acircle with centre (0, 0)and radius 5
Figure 32. The related pairs form a circle with centre (0, 0)

Rationals in reduced form. This set is a subset of Q\mathbb{Q}: {pq∣(p,q)∈Z×Z, q≠0, gcd⁡(p,q)=1}\{\frac{p}{q} \mid (p, q) \in \mathbb{Z} \times \mathbb{Z},\ q \neq 0,\ \gcd(p, q) = 1\}. But it is also a relation on Z×Z\mathbb{Z} \times \mathbb{Z}: {(p,q)∣(p,q)∈Z×Z, gcd⁡(p,q)=1}\{(p, q) \mid (p, q) \in \mathbb{Z} \times \mathbb{Z},\ \gcd(p, q) = 1\}.

7.4Beyond binary relations

We can take Cartesian products of more than two sets. A product of nn sets generates nn-tuples: (x1,x2,…,xn)∈X1×X2×⋯×Xn(x_1, x_2, \dots, x_n) \in X_1 \times X_2 \times \cdots \times X_n, and a relation can pick out some of them.

Pythagorean triples
A relation on three sets

The square on the hypotenuse is the sum of the squares on the other two sides:

{(a,b,c)∣(a,b,c)∈N3, a,b,c>0, a2+b2=c2}\{(a, b, c) \mid (a, b, c) \in \mathbb{N}^3,\ a, b, c > 0,\ a^2 + b^2 = c^2\}
Corners of squares
A relation on four sets

A corner is a point (x,y)∈R×R(x, y) \in \mathbb{R} \times \mathbb{R}. Four points ((x1,y1),(x2,y2),(x3,y3),(x4,y4))((x_1, y_1), (x_2, y_2), (x_3, y_3), (x_4, y_4)) are related if they are the four corners of a square:

Sq⊆R2×R2×R2×R2Sq \subseteq \mathbb{R}^2 \times \mathbb{R}^2 \times \mathbb{R}^2 \times \mathbb{R}^2
0.50.5111.51.5222.52.5xy(0, 0), (0, 2), (2, 2), (2, 0)an upright square of side 2(0.5, 0), (0, 0.5), (0.5, 1), (1, 0.5)a tilted square: still four cornersA 4-ary relationSq ⊆ ℝ² × ℝ² × ℝ² × ℝ²
Figure 33. Two members of the relation Sq
Example 17Cartesian product and order

Let A={0,1}A = \{0, 1\} and B={2,3}B = \{2, 3\}. List A×BA \times B and B×AB \times A. Are they equal? Is (1,0)∈A×B(1, 0) \in A \times B?

Solution
  1. Pair each element of AA with each element of BB: A×B={(0,2),(0,3),(1,2),(1,3)}A \times B = \{(0, 2), (0, 3), (1, 2), (1, 3)\}, which has 2×2=42 \times 2 = 4 pairs.
  2. Swap roles: B×A={(2,0),(2,1),(3,0),(3,1)}B \times A = \{(2, 0), (2, 1), (3, 0), (3, 1)\}.
  3. No pair appears in both lists, because order matters. So A×B≠B×AA \times B \neq B \times A.
  4. (1,0)∉A×B(1, 0) \notin A \times B: its second entry 0 is not in BB.
Example 18Testing membership in a relation

Which of (3,4,5)(3, 4, 5), (5,12,13)(5, 12, 13), (2,3,4)(2, 3, 4) are Pythagorean triples? Which of (3,−4)(3, -4), (4,4)(4, 4), (−5,0)(-5, 0) are at distance 5 from the origin?

Solution
TupleCheckIn the relation?
(3,4,5)(3, 4, 5)9+16=25=529 + 16 = 25 = 5^2Yes
(5,12,13)(5, 12, 13)25+144=169=13225 + 144 = 169 = 13^2Yes
(2,3,4)(2, 3, 4)4+9=13≠164 + 9 = 13 \neq 16No
(3,−4)(3, -4)9+16=25=5\sqrt{9 + 16} = \sqrt{25} = 5Yes
(4,4)(4, 4)16+16=32≠5\sqrt{16 + 16} = \sqrt{32} \neq 5No
(−5,0)(-5, 0)25+0=5\sqrt{25 + 0} = 5Yes

7.5Going deeper: counting pairs and relations

  • Three views of one relation. A list of pairs, arrows from AA to BB, and chosen points of a grid describe the same subset of A×BA \times B.
  • Counting. ∣A×B∣=∣A∣⋅∣B∣|A \times B| = |A| \cdot |B|. A relation is any subset of A×BA \times B, so there are 2∣A∣⋅∣B∣2^{|A| \cdot |B|} relations from AA to BB. For ∣A∣=2|A| = 2 and ∣B∣=3|B| = 3 that is 26=642^6 = 64.
  • Relations on one set. A relation on AA is a subset of A×AA \times A. With ∣A∣=3|A| = 3 there are 29=5122^9 = 512 of them.
  • Order matters in a pair, not in a set. (1,2)≠(2,1)(1, 2) \neq (2, 1) but {1,2}={2,1}\{1, 2\} = \{2, 1\}. A pair may repeat an element: (a,a)(a, a) is allowed.
  • Testing a pair. To see if (a,b)(a, b) is in a relation, first check that aa and bb belong to the right sets, then plug into the condition (for example n=m+1n = m + 1 or a2+b2=5\sqrt{a^2 + b^2} = 5).
  • Also relations. ∅\emptyset and A×BA \times B itself are both relations.

7.6Exam tips and common mistakes

Exam tips
  • First check the coordinates against the sets, then test the condition.
  • Count pairs with ∣A∣⋅∣B∣|A| \cdot |B|, and count relations with 2∣A∣∣B∣2^{|A||B|}.
  • Write pairs with parentheses and sets with braces.
Common mistakes
  • Assuming A×B=B×AA \times B = B \times A.
  • Writing (b,a)(b, a) when the relation says (a,b)(a, b).
  • Mixing up the number of pairs, ∣A∣∣B∣|A||B|, with the number of relations, 2∣A∣∣B∣2^{|A||B|}.
  • Forgetting that the empty relation counts.

Practice questions (graded-assignment style)

Q1Size of a product

Numerical Answer Type (NAT).

A={1,2,3}A = \{1, 2, 3\} and B={x,y}B = \{x, y\}. What is ∣A×B∣|A \times B|?

Solution
Idea

Multiply the sizes.

  • ∣A∣=3|A| = 3 and ∣B∣=2|B| = 2, so ∣A×B∣=3⋅2=6|A \times B| = 3 \cdot 2 = 6.
  • Answer: 6
Q2Number of relations

Numerical Answer Type (NAT).

How many relations are there from AA to BB when ∣A∣=2|A| = 2 and ∣B∣=3|B| = 3?

Solution
Idea

A relation is any subset of A × B.

  • ∣A×B∣=6|A \times B| = 6.
  • Each of the 6 pairs is in or out: 26=642^6 = 64 subsets, so 64 relations.
  • Answer: 64
Q3Members of A × B

Multiple Select Question (MSQ): select all that apply.

Let A={0,1}A = \{0, 1\} and B={2,3}B = \{2, 3\}. Which pairs belong to A×BA \times B?

1
(0,3)(0, 3)
2
(3,0)(3, 0)
3
(1,2)(1, 2)
4
(1,1)(1, 1)
Solution
Idea

The first entry must be from A and the second from B.

  • (0,3)(0, 3): 0 is in A, 3 is in B, yes.
  • (3,0)(3, 0): 3 is not in A, no.
  • (1,2)(1, 2): yes.
  • (1,1)(1, 1): 1 is not in B, no.
  • Answer: options 1 and 3.
Q4A relation by rule

Multiple Choice Question (MCQ): choose the one correct option.

The relation {(a,b)∣b=a+1}\{(a, b) \mid b = a + 1\} on N\mathbb{N}. Which pair belongs to it?

1
(4,3)(4, 3)
2
(3,4)(3, 4)
3
(3,3)(3, 3)
4
(5,7)(5, 7)
Solution
Idea

Put the pair into the condition.

  • (3,4)(3, 4): 4=3+14 = 3 + 1, yes.
  • (4,3)(4, 3): 3≠53 \neq 5; (3,3)(3, 3): 3≠43 \neq 4; (5,7)(5, 7): 7≠67 \neq 6.
  • Answer: option 2.
Revision overview
Cartesian productA × B = {(a, b) | a ∈ A, b ∈ B}
Order matters: (0, 1) ≠ (1, 0)
|A × B| = |A| · |B|
Binary relationR ⊆ A × B: some chosen pairs
Notation (a, b) ∈ R or aRb
Product + comprehension
Examples on ℕ × ℕn = m + 1: (0,1), (1,2), …
d divides n: (2, 82), (14, 56)
Visualise as points of a grid
RelationsWeek 1 · Relations
Geometric relations√(a² + b²) = 5: a circle
gcd(p, q) = 1 on ℤ × ℤ
Beyond binaryn sets give n-tuples
Pythagorean triples ⊆ ℕ × ℕ × ℕ
Corners of squares: 4-tuples of points
Revision: relations on one page
Next · Relations · Part 2 of 2Types of Relations
08
Relations · Part 2 of 2

Types of Relations

Most interesting relations connect a set to itself: R⊆A×AR \subseteq A \times A. Such relations can have special properties, and one combination of properties, the equivalence relation, groups the elements of a set into classes.

8.1The identity relation

Definition: identity relation

The identity relation on AA relates each element to itself and nothing else:

I={(a,b)∣(a,b)∈A×A, a=b}={(a,a)∣a∈A}I = \{(a, b) \mid (a, b) \in A \times A,\ a = b\} = \{(a, a) \mid a \in A\}

For S={1,2,3,4}S = \{1, 2, 3, 4\} the identity relation is {(1,1),(2,2),(3,3),(4,4)}\{(1, 1), (2, 2), (3, 3), (4, 4)\}.

8.2Reflexive relations

Definition: reflexive

A relation R⊆A×AR \subseteq A \times A is reflexive if I⊆RI \subseteq R: for every x∈Ax \in A, (x,x)∈R(x, x) \in R.

  • {(a,b)∣(a,b)∈N×N, a,b>0, a∣b}\{(a, b) \mid (a, b) \in \mathbb{N} \times \mathbb{N},\ a, b > 0,\ a \mid b\} is reflexive, since a∣aa \mid a for all a>0a > 0.
  • On S={1,2,3,4}S = \{1, 2, 3, 4\}: R1={(1,1),(2,2),(3,3),(4,4)}R_1 = \{(1, 1), (2, 2), (3, 3), (4, 4)\} (the identity) and R3={(1,1),(2,2),(3,3),(4,4),(2,4),(4,1)}R_3 = \{(1, 1), (2, 2), (3, 3), (4, 4), (2, 4), (4, 1)\} are reflexive. R2={(1,1),(2,3),(2,2),(4,4),(3,4)}R_2 = \{(1, 1), (2, 3), (2, 2), (4, 4), (3, 4)\} is not, because (3,3)∉R2(3, 3) \notin R_2.

8.3Symmetric relations

Definition: symmetric

RR is symmetric if (a,b)∈R(a, b) \in R if and only if (b,a)∈R(b, a) \in R: every pair comes with its reverse.

  • {(a,b)∣gcd⁡(a,b)=1}\{(a, b) \mid \gcd(a, b) = 1\} and {(a,b)∣∣a−b∣=2}\{(a, b) \mid |a - b| = 2\} on N×N\mathbb{N} \times \mathbb{N} are symmetric: swapping aa and bb does not change the condition.
  • {(1,2),(2,1),(3,4),(4,3),(2,2)}\{(1, 2), (2, 1), (3, 4), (4, 3), (2, 2)\} and {(1,2),(2,3),(2,1),(3,2),(4,3),(3,4)}\{(1, 2), (2, 3), (2, 1), (3, 2), (4, 3), (3, 4)\} are symmetric. {(2,1),(1,2),(3,4),(2,4),(4,2)}\{(2, 1), (1, 2), (3, 4), (2, 4), (4, 2)\} is not: (3,4)(3, 4) is in it but (4,3)(4, 3) is not.

8.4Transitive relations

Definition: transitive

RR is transitive if whenever (a,b)∈R(a, b) \in R and (b,c)∈R(b, c) \in R, also (a,c)∈R(a, c) \in R.

  • {(a,b)∣a∣b}\{(a, b) \mid a \mid b\} on N×N\mathbb{N} \times \mathbb{N} is transitive: if a∣ba \mid b and b∣cb \mid c then a∣ca \mid c.
  • {(a,b)∣(a,b)∈R×R, a<b}\{(a, b) \mid (a, b) \in \mathbb{R} \times \mathbb{R},\ a < b\} is transitive: if a<ba < b and b<cb < c then a<ca < c.
  • On {1,2,3,4}\{1, 2, 3, 4\}: {(1,2),(2,3),(1,3)}\{(1, 2), (2, 3), (1, 3)\}, {(1,4)}\{(1, 4)\} and {(1,3),(1,4)}\{(1, 3), (1, 4)\} are transitive. {(1,2),(2,1),(1,1),(2,3)}\{(1, 2), (2, 1), (1, 1), (2, 3)\} is not: (1,2)(1, 2) and (2,3)(2, 3) are in it, but (1,3)(1, 3) is not.
Vacuous truth. {(1,4)}\{(1, 4)\} has no chain (a,b),(b,c)(a, b), (b, c) at all, so there is nothing that could fail. A condition with no cases to check is automatically true.

8.5Antisymmetric relations

Definition: antisymmetric

RR is antisymmetric if whenever (a,b)∈R(a, b) \in R and a≠ba \neq b, then (b,a)∉R(b, a) \notin R: no two different elements are related both ways.

  • {(a,b)∣(a,b)∈R×R, a<b}\{(a, b) \mid (a, b) \in \mathbb{R} \times \mathbb{R},\ a < b\}: if a<ba < b then b≮ab \not< a.
  • M⊆P×PM \subseteq P \times P relating mothers to children: if (p,c)∈M(p, c) \in M then (c,p)∉M(c, p) \notin M.
Not opposites. "Symmetric" and "antisymmetric" are not opposites. The identity relation is both; {(1,2),(2,1),(2,3)}\{(1, 2), (2, 1), (2, 3)\} is neither (it has the two-way pair 1↔21 \leftrightarrow 2, so not antisymmetric, but (2,3)(2, 3) has no return, so not symmetric).
Reflexive1243loop onevery elementSymmetric1243every arrowhas a returnTransitive12431→2→3 hasthe shortcut 1→3Not transitive×12431→2→3 butno 1→3
Figure 34. Arrow diagrams on S = {1, 2, 3, 4}: a loop is a pair (x, x)

8.6Equivalence relations

Definition: equivalence relation

A relation that is reflexive, symmetric and transitive is an equivalence relation.

Same remainder modulo 5. 7 mod 5=27 \bmod 5 = 2 and 22 mod 5=222 \bmod 5 = 2. If a mod 5=b mod 5a \bmod 5 = b \bmod 5, then b−ab - a is a multiple of 5. So define

Z mod 5={(a,b)∣a,b∈Z, (b−a) mod 5=0}\mathbb{Z} \bmod 5 = \{(a, b) \mid a, b \in \mathbb{Z},\ (b - a) \bmod 5 = 0\}
  • Reflexive: a−a=0a - a = 0 is a multiple of 5.
  • Symmetric: if b−ab - a is a multiple of 5, so is a−b=−(b−a)a - b = -(b - a).
  • Transitive: if b−ab - a and c−bc - b are multiples of 5, so is their sum c−ac - a.

This relation divides the integers into 5 groups, based on the remainder when divided by 5.

remainder 0⋮−505101520⋮remainder 1⋮−416111621⋮remainder 2⋮−327121722⋮remainder 3⋮−238131823⋮remainder 4⋮−149141924⋮7 mod 5 = 2 and 22 mod 5 = 2, so 7 and 22 sit in the same class; 22 − 7 = 15 is a multiple of 5
Figure 35. Same remainder modulo 5 splits ℤ into five classes
Partitions and classes

An equivalence relation partitions a set: every element lands in exactly one group, and the groups do not overlap. The groups of equivalent elements are called equivalence classes.

Measuring time. A clock displays hours modulo 12. 2:00 am is equivalent to 2:00 pm, and 4 hours after 9 o\'clock the clock shows 1.

12369123699 o'clock1 o'clock+4 hours9 + 4 = 13, and 13 mod 12 = 1Same position2:00 am and 2:00 pmare equivalent:hours modulo 12
Figure 36. A clock works with equivalence classes of hours modulo 12

On S={1,2,3,4}S = \{1, 2, 3, 4\}, R1={(1,1),(2,2),(3,3),(4,4),(2,3),(3,2),(4,1),(1,4)}R_1 = \{(1, 1), (2, 2), (3, 3), (4, 4), (2, 3), (3, 2), (4, 1), (1, 4)\} is an equivalence relation. Its classes are {1,4}\{1, 4\} and {2,3}\{2, 3\}.

1423the relation R₁ on {1, 2, 3, 4}groupsS1 4class {1, 4}2 3class {2, 3}
Figure 37. The equivalence relation R₁ splits S into two classes
Reflexive?every x in Shas (x, x)Symmetric?each (x, y) hasits partner (y, x)Transitive?(x, y), (y, z) give(x, z) every timeEquivalenceall three: yespartitions SOne missing pair is enough to break a property. Check every chain (x, y), (y, z),including chains through loops and two-way pairs.
Figure 38. The checklist for any relation on a set
Example 19Match the relations with their properties

On S={1,2,3}S = \{1, 2, 3\}, match each relation with a property: reflexive, symmetric, transitive, equivalence.

R1={(1,3),(3,2),(1,1),(2,3),(3,1)}R_1 = \{(1, 3), (3, 2), (1, 1), (2, 3), (3, 1)\}
R2={(1,1),(2,3),(3,2),(2,2),(3,3)}R_2 = \{(1, 1), (2, 3), (3, 2), (2, 2), (3, 3)\}
R3={(3,1),(1,1),(2,1),(2,3),(3,3),(2,2)}R_3 = \{(3, 1), (1, 1), (2, 1), (2, 3), (3, 3), (2, 2)\}
R4={(3,2),(3,1),(2,1)}R_4 = \{(3, 2), (3, 1), (2, 1)\}

Solution
ReflexiveSymmetricTransitiveMatch
R1R_1No: no (2,2)Yes: (1,3)↔(3,1), (3,2)↔(2,3)No: (1,3), (3,2) but no (1,2)Symmetric
R2R_2Yes: (1,1), (2,2), (3,3)Yes: (2,3)↔(3,2)Yes: (2,3), (3,2) give (2,2) ✓Equivalence
R3R_3Yes: (1,1), (2,2), (3,3)No: (3,1) but no (1,3)Yes: (2,3), (3,1) give (2,1) ✓Reflexive
R4R_4No: no loopsNo: (3,2) but no (2,3)Yes: (3,2), (2,1) give (3,1) ✓Transitive

R2R_2 is reflexive, symmetric and transitive, so it is the equivalence relation (classes {1}\{1\} and {2,3}\{2, 3\}). R3R_3 is reflexive (and also transitive), and R4R_4 is only transitive.

Example 20A transitivity trap

On S={1,2,3,4}S = \{1, 2, 3, 4\}, is R={(2,4),(1,2),(1,4),(4,1),(1,1),(2,1)}R = \{(2, 4), (1, 2), (1, 4), (4, 1), (1, 1), (2, 1)\} transitive?

Solution
  1. Many chains work: (1,2),(2,4)(1, 2), (2, 4) gives (1,4)(1, 4) ✓; (2,4),(4,1)(2, 4), (4, 1) gives (2,1)(2, 1) ✓; (1,4),(4,1)(1, 4), (4, 1) gives (1,1)(1, 1) ✓.
  2. But take (4,1)∈R(4, 1) \in R and (1,2)∈R(1, 2) \in R. Transitivity needs (4,2)(4, 2).
  3. (4,2)∉R(4, 2) \notin R, so RR is not transitive. (Also (4,1),(1,4)(4, 1), (1, 4) would need (4,4)(4, 4), which is missing too.)
  4. Lesson: check every chain, including ones that start from the second element of a two-way pair.
BonusSymmetric, antisymmetric, both or neither?

On S={1,2,3}S = \{1, 2, 3\}, classify each relation as symmetric and/or antisymmetric: A1={(1,1),(2,2)}A_1 = \{(1, 1), (2, 2)\}, A2={(1,2),(2,1)}A_2 = \{(1, 2), (2, 1)\}, A3={(1,2),(2,3)}A_3 = \{(1, 2), (2, 3)\}, A4={(1,2),(2,1),(2,3)}A_4 = \{(1, 2), (2, 1), (2, 3)\}.

Solution
Symmetric?Antisymmetric?Verdict
A1A_1Yes: only loopsYes: no pair of different elementsboth
A2A_2YesNo: (1,2) and (2,1)symmetric only
A3A_3No: (1,2) has no (2,1)Yesantisymmetric only
A4A_4No: (2,3) has no (3,2)No: (1,2) and (2,1)neither

8.7Summary of relations

PropertyConditionExampleNon-example
Reflexiveevery (x,x)∈R\text{every } (x, x) \in Ra∣ba \mid b on positive naturalsa<ba < b
Symmetric(a,b)∈R⇒(b,a)∈R(a, b) \in R \Rightarrow (b, a) \in R∣a−b∣=2|a - b| = 2a<ba < b
Transitive(a,b),(b,c)∈R⇒(a,c)∈R(a, b), (b, c) \in R \Rightarrow (a, c) \in Ra∣b, a<ba \mid b,\ a < b{(1,2),(2,1),(1,1),(2,3)}\{(1, 2), (2, 1), (1, 1), (2, 3)\}
Antisymmetric(a,b)∈R, a≠b⇒(b,a)∉R(a, b) \in R,\ a \neq b \Rightarrow (b, a) \notin Ra<ba < b, "mother of"∣a−b∣=2|a - b| = 2
Equivalencereflexive + symmetric + transitivesame remainder mod 5a∣ba \mid b
  • Cartesian products generate nn-tuples from nn sets.
  • A relation picks out a subset of a Cartesian product.
  • Properties of relations: reflexive, symmetric, transitive, antisymmetric.
  • An equivalence relation partitions a set.

8.8Going deeper: checking properties systematically

  • Reflexive: go through every element of SS, even those that never appear in a pair, and look for its loop (x,x)(x, x). One missing loop is enough to fail.
  • Symmetric: for each pair (a,b)(a, b) look for (b,a)(b, a). Loops (x,x)(x, x) are their own reverse, so they never cause a failure.
  • Transitive: for each pair (a,b)(a, b) and each pair starting at bb, check that (a,c)(a, c) is present. Include chains through loops and chains that start from the second element of a two-way pair.
  • Antisymmetric: look for two-way pairs (a,b),(b,a)(a, b), (b, a) with a≠ba \neq b. If you find one, it fails.
  • Proving versus disproving. To prove a property you need a general argument. To disprove it a single counterexample is enough.

Properties of common relations

RelationReflexiveSymmetricTransitiveAntisymmetricEquivalence?
a=ba = byesyesyesyesequivalence
a≤ba \le byesnoyesyesnone
a<ba < bnonoyesyesnone
a∣ba \mid b (positive)yesnoyesyesnone
∣a−b∣=2|a - b| = 2noyesnononone
same remainder mod 5yesyesyesnoequivalence
  • Reflexive and symmetric do not give transitive. On {1,2,3}\{1, 2, 3\}, {(1,1),(2,2),(3,3),(1,2),(2,1),(2,3),(3,2)}\{(1,1),(2,2),(3,3),(1,2),(2,1),(2,3),(3,2)\} is reflexive and symmetric, but (1,2),(2,3)(1, 2), (2, 3) need (1,3)(1, 3), which is missing.
  • Classes. "Same remainder mod nn" splits Z\mathbb{Z} into exactly nn classes, which do not overlap and together cover Z\mathbb{Z}.

8.9Exam tips and common mistakes

Exam tips
  • Check all four properties for every relation in a table, one at a time.
  • Always quote the exact missing pair when a property fails.
  • For an equivalence relation, finish by listing the classes.
Common mistakes
  • Treating "symmetric" and "antisymmetric" as opposites. The identity is both, and some relations are neither.
  • Missing a loop for an element that appears in no pair.
  • Checking only the obvious chains for transitivity.
  • Assuming reflexive plus symmetric is enough for an equivalence.

Practice questions (graded-assignment style)

Q1Classify a relation

Multiple Choice Question (MCQ): choose the one correct option.

On S={1,2,3}S = \{1, 2, 3\} let R={(1,1),(2,2)}R = \{(1, 1), (2, 2)\}. Which statement is true?

1
RR is reflexive.
2
RR is not reflexive, but it is symmetric, transitive and antisymmetric.
3
RR is an equivalence relation.
4
RR is not symmetric.
Solution
Idea

Reflexive needs a loop for every element of SS, including 3.

  • (3,3)∉R(3, 3) \notin R, so RR is not reflexive (options 1 and 3 are false).
  • The only pairs are loops, so RR is symmetric, antisymmetric and transitive.
  • Answer: option 2.
Q2Less than

Multiple Select Question (MSQ): select all that apply.

Consider {(a,b)∣a<b}\{(a, b) \mid a < b\} on R\mathbb{R}. Choose the correct statements.

1
Reflexive
2
Symmetric
3
Transitive
4
Antisymmetric
Solution
Idea

Test each property with a number or two.

  • Reflexive: a<aa < a is false.
  • Symmetric: 1<21 < 2 but 2<12 < 1 is false.
  • Transitive: a<ba < b and b<cb < c give a<ca < c.
  • Antisymmetric: a<ba < b means b<ab < a fails.
  • Answer: options 3 and 4.
Q3Number of classes

Numerical Answer Type (NAT).

How many equivalence classes does "same remainder mod 7" create on Z\mathbb{Z}?

Solution
Idea

One class for each possible remainder.

  • Remainders are 0,1,…,60, 1, \dots, 6, which is 7 values.
  • Answer: 7
Q4Why not an equivalence?

Multiple Choice Question (MCQ): choose the one correct option.

On {1,2,3}\{1, 2, 3\}, R={(1,1),(2,2),(3,3),(1,2),(2,1),(2,3),(3,2)}R = \{(1,1),(2,2),(3,3),(1,2),(2,1),(2,3),(3,2)\}. Why is RR not an equivalence relation?

1
It is not reflexive.
2
It is not symmetric.
3
It is not transitive: (1,2),(2,3)∈R(1, 2), (2, 3) \in R but (1,3)∉R(1, 3) \notin R.
4
It is an equivalence relation.
Solution
Idea

Check every chain.

  • All three loops are present, so it is reflexive.
  • Every pair has its reverse, so it is symmetric.
  • The chain 1→2→31 \to 2 \to 3 needs (1,3)(1, 3), so it is not transitive.
  • Answer: option 3.
Revision overview
Identity & reflexiveI = {(a, a) | a ∈ A}
Reflexive: I ⊆ R
Example: a | b on positive ℕ
Symmetric(a, b) ∈ R iff (b, a) ∈ R
gcd(a, b) = 1, |a − b| = 2
Transitive(a,b), (b,c) ⇒ (a,c)
Divides; less than
Check every chain
Types of RelationsWeek 1 · Relations
Antisymmetrica ≠ b: never both ways
Less than; mother of
Not the opposite of symmetric
EquivalenceReflexive + symmetric + transitive
Same remainder mod 5
Clock: hours mod 12
PartitionsEquivalence splits a set
Groups = equivalence classes
mod 5 gives 5 classes
Revision: types of relations on one page
Next · Functions · Part 1 of 2Functions
09
Functions · Part 1 of 2

Functions

A function is the most important kind of relation in data science: a rule that turns each input into exactly one output. This topic defines functions, the sets around them (domain, codomain, range), and how a function is drawn as a graph.

9.1A rule to map inputs to outputs

  • Convert xx to x2x^2. The rule is x↦x2x \mapsto x^2.
  • Give the rule a name: sq(x)=x2\text{sq}(x) = x^2. The input xx is a parameter.
input 3input −3input 1.5sqrule: x ↦ x²output 9output 9output 2.25sq(x) = x²: the input x is a parameter of the rule
Figure 39. The function sq turns each input into its square

9.2Domain, codomain and range

A rule alone is not enough: we need to specify the input and output sets.

TermMeaningFor sq
Domainthe input setdomain(sq)=R\text{domain}(\text{sq}) = \mathbb{R}
Codomainthe output set of possible valuescodomain(sq)=R\text{codomain}(\text{sq}) = \mathbb{R}
Rangethe actual values that the output can takerange(sq)=R≥0={r∣r∈R, r≥0}\text{range}(\text{sq}) = \mathbb{R}_{\ge 0} = \{r \mid r \in \mathbb{R},\ r \ge 0\}
Notation

f:X→Yf : X \to Y means ff is a function from XX to YY: the domain of ff is XX and the codomain is YY. The range is

range(f)={y∣y∈Y, y=f(x) for some x∈X}\text{range}(f) = \{y \mid y \in Y,\ y = f(x) \text{ for some } x \in X\}

The range is always a subset of the codomain.

Domain X (inputs)Codomain Y (allowed outputs)Rangeoutputs that actually occur−220…40−1not an outputFor sq: domain = ℝ, codomain = ℝ, range = {r | r ∈ ℝ, r ≥ 0}
Figure 40. The range sits inside the codomain

9.3Functions as relations

We can associate a relation RfR_f with each function ff: the set of all (input, output) pairs.

Rsq={(x,y)∣x,y∈R, y=x2}Rf⊆domain(f)×range(f)R_{\text{sq}} = \{(x, y) \mid x, y \in \mathbb{R},\ y = x^2\} \qquad R_f \subseteq \text{domain}(f) \times \text{range}(f)

For RsqR_{\text{sq}} we also use the additional notation y=x2y = x^2. Not every relation comes from a function. RfR_f has two special properties:

Property 1
Defined on the entire domain

For each x∈domain(f)x \in \text{domain}(f), there is a pair (x,y)∈Rf(x, y) \in R_f. No input is left without an output.

Property 2
Single valued

For each x∈domain(f)x \in \text{domain}(f), there is exactly one y∈codomain(f)y \in \text{codomain}(f) with (x,y)∈Rf(x, y) \in R_f.

Definition: function

A function is a relation in which each element of XX is paired with exactly one element of YY. In a function there cannot be two pairs with the same first element.

XY1234abcdXY1234abcdFunctionNOT a function: 3 has two outputsevery input has exactly one arrowinput 3 has two arrows
Figure 41. Left: every input has exactly one arrow. Right: input 3 has two arrows

Drawing ff as a graph is plotting RfR_f: each pair (x,f(x))(x, f(x)) becomes a point.

−4−3−2−11234481216range(−3, 9)(3, 9)xyR_sq: every point(x, x²) plottedOutputs never gobelow 0
Figure 42. The graph of sq is the parabola y = x², the picture of R_sq
Vertical line test. Because a function gives exactly one output per input, a graph is the graph of a function exactly when every vertical line meets it at most once (and at least once, over the domain).

9.4Lines

f(x)=3.5x+5.7f(x) = 3.5x + 5.7 is a straight line. 3.5 is the slope and 5.7 is the intercept: the value where the line crosses the yy-axis, when x=0x = 0. Changing the slope and intercept produces different lines:

f(x)=3.5x−1.2f(x)=2x+5.7f(x)=−4.5x+2.5f(x) = 3.5x - 1.2 \qquad f(x) = 2x + 5.7 \qquad f(x) = -4.5x + 2.5
−3−2−1123−12−612185.72.5−1.2f(x) = 3.5x + 5.7f(x) = 3.5x − 1.2f(x) = 2x + 5.7f(x) = −4.5x + 2.5Same slope 3.5:parallel linesSame intercept 5.7:meet on the y-axisdots: where each linecrosses the y-axis (x = 0)
Figure 43. Changing slope and intercept moves and tilts the line
In all these cases

Domain =R= \mathbb{R}, and codomain == range =R= \mathbb{R}: every real number is the output for some input.

9.5More functions: the square root

Consider x↦xx \mapsto \sqrt{x}. Is this even a function? 52=(−5)2=255^2 = (-5)^2 = 25, so "25\sqrt{25}" gives two options, 5 and −5-5. A function must give exactly one output, so by convention we take the positive square root: 25=5\sqrt{25} = 5.

What is the domain? It depends on the codomain. Negative numbers do not have real square roots.

Codomain R\mathbb{R}
Domain is R≥0\mathbb{R}_{\ge 0}

Only x≥0x \ge 0 has a real square root, so the domain is [0,∞)[0, \infty).

Codomain C\mathbb{C}
Domain is R\mathbb{R}

If the codomain is the set C\mathbb{C} of complex numbers, every real number has a square root, e.g. −1\sqrt{-1}.

51015202530−6−4−2246(25, 5)(25, −5)xy√x: take the positive root (by convention)−√x is the other option, not used by √xNothing for x < 0 in ℝ
Figure 44. y = √x uses only the positive root and starts at x = 0
Example 21Domain of the square root

If the codomain is R\mathbb{R}, find the domain of f(x)=xf(x) = \sqrt{x}.

Solution
  1. x\sqrt{x} must be a real number. If x<0x < 0, no real rr has r2=xr^2 = x, because a real square is never negative.
  2. If x≥0x \ge 0, the positive root exists and is unique by convention.
  3. So x\sqrt{x} is well defined only if x≥0x \ge 0: the domain is [0,∞)[0, \infty).
Example 22Is it a function?

Let X={1,2,3,4}X = \{1, 2, 3, 4\}, Y={a,b,c,d}Y = \{a, b, c, d\}. Decide whether each relation is a function from XX to YY: F={(1,b),(2,c),(3,a),(4,c)}F = \{(1, b), (2, c), (3, a), (4, c)\}, G={(1,b),(2,c),(3,a),(3,d),(4,c)}G = \{(1, b), (2, c), (3, a), (3, d), (4, c)\}, H={(1,a),(2,b),(4,d)}H = \{(1, a), (2, b), (4, d)\}.

Solution
RelationDefined on all of X?Single valued?Function?
FFYes: 1, 2, 3, 4 all usedYesYes (2 and 4 sharing c is allowed)
GGYesNo: 3 maps to a and dNo
HHNo: 3 has no outputYesNo
Example 23Reading a line

For f(x)=3.5x+5.7f(x) = 3.5x + 5.7, find f(0)f(0), f(2)f(2) and the input xx with f(x)=0f(x) = 0.

Solution
  1. f(0)=3.5⋅0+5.7=5.7f(0) = 3.5 \cdot 0 + 5.7 = 5.7: the intercept, where the line crosses the yy-axis.
  2. f(2)=3.5⋅2+5.7=7+5.7=12.7f(2) = 3.5 \cdot 2 + 5.7 = 7 + 5.7 = 12.7.
  3. 3.5x+5.7=03.5x + 5.7 = 0 gives x=−5.73.5=−5735≈−1.63x = -\frac{5.7}{3.5} = -\frac{57}{35} \approx -1.63. Any real output is reachable, which is why range == codomain =R= \mathbb{R}.

9.6Going deeper: is it a function, and what are its sets?

  • Two checks for a function. (1) Every element of the domain has an arrow. (2) Each has exactly one. Several inputs may share one output (many-to-one is fine), but one input may not have two outputs.
  • Finding a natural domain. Remove inputs that break the rule: division by zero, or the square root of a negative number (when the codomain is R\mathbb{R}). So 1x\frac{1}{x} has domain R−{0}\mathbb{R} - \{0\}, and x−2\sqrt{x - 2} has domain [2,∞)[2, \infty).
  • Finding the range. Solve y=f(x)y = f(x) for xx and see which yy allow a solution in the domain. For f(x)=x2+3f(x) = x^2 + 3, x2≥0x^2 \ge 0 gives y≥3y \ge 3, so the range is [3,∞)[3, \infty).
  • Evaluating. Replace xx everywhere by the input: for f(x)=2x2−3f(x) = 2x^2 - 3, f(−2)=2⋅4−3=5f(-2) = 2 \cdot 4 - 3 = 5.
  • Lines. The slope of f(x)=mx+cf(x) = mx + c is the change in yy per unit of xx. Through two points: m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}. A line with m≠0m \neq 0 has range R\mathbb{R}.
  • How many functions? Each of the ∣X∣|X| inputs independently picks one of ∣Y∣|Y| outputs, so there are ∣Y∣∣X∣|Y|^{|X|} functions from XX to YY.

9.7Exam tips and common mistakes

Exam tips
  • State the domain, codomain and range as sets, not as words.
  • The range is a subset of the codomain, and often a proper subset.
  • To test a graph use the vertical line test; to test pairs use "one arrow per input".
Common mistakes
  • Assuming range equals codomain. For x2:R→Rx^2 : \mathbb{R} \to \mathbb{R} the range is only [0,∞)[0, \infty).
  • Calling a relation a function when one input has two outputs, or when an input has none.
  • Giving ±\pm for x\sqrt{x}. By convention it is the positive root.
  • Mixing up domain (inputs) and range (outputs).

Practice questions (graded-assignment style)

Q1Which is a function?

Multiple Choice Question (MCQ): choose the one correct option.

Let X={1,2,3}X = \{1, 2, 3\} and Y={a,b}Y = \{a, b\}. Which relation is a function from XX to YY?

1
{(1,a),(2,b)}\{(1, a), (2, b)\}
2
{(1,a),(1,b),(2,a),(3,b)}\{(1, a), (1, b), (2, a), (3, b)\}
3
{(1,a),(2,a),(3,b)}\{(1, a), (2, a), (3, b)\}
4
{(1,a),(2,b),(3,a),(3,b)}\{(1, a), (2, b), (3, a), (3, b)\}
Solution
Idea

Every input needs exactly one arrow.

  • Option 1: input 3 has no output.
  • Option 2: input 1 has two outputs.
  • Option 3: each of 1, 2, 3 has exactly one output (1 and 2 sharing a is allowed).
  • Option 4: input 3 has two outputs.
  • Answer: option 3.
Q2Evaluate

Numerical Answer Type (NAT).

If f(x)=2x2−3f(x) = 2x^2 - 3, find f(−2)f(-2).

Solution
Idea

Substitute and follow the order of operations.

  • (−2)2=4(-2)^2 = 4.
  • 2⋅4−3=8−3=52 \cdot 4 - 3 = 8 - 3 = 5.
  • Answer: 5
Q3Range and codomain

Multiple Select Question (MSQ): select all that apply.

Let f:R→Rf : \mathbb{R} \to \mathbb{R}, f(x)=x2+3f(x) = x^2 + 3. Choose the correct statements.

1
The range of ff is [3,∞)[3, \infty).
2
The range equals the codomain.
3
f(2)=f(−2)f(2) = f(-2).
4
The domain is R\mathbb{R}.
Solution
Idea

Since x2≥0x^2 \ge 0, the output is at least 3.

  • Option 1 is true.
  • Option 2 is false: for example 00 is in R\mathbb{R} but never an output.
  • Option 3 is true: both give 7.
  • Option 4 is true by the definition of f.
  • Answer: options 1, 3 and 4.
Q4Domain of a root

Multiple Choice Question (MCQ): choose the one correct option.

With codomain R\mathbb{R}, what is the domain of f(x)=x−2f(x) = \sqrt{x - 2}?

1
R\mathbb{R}
2
(2,∞)(2, \infty)
3
[2,∞)[2, \infty)
4
(−∞,2](-\infty, 2]
Solution
Idea

The expression under the root must be ≥0\ge 0.

  • x−2≥0x - 2 \ge 0 gives x≥2x \ge 2.
  • At x=2x = 2 the value is 0=0\sqrt{0} = 0, so 2 is included.
  • Answer: option 3.
Q5Count the functions

Numerical Answer Type (NAT).

How many functions are there from a 3-element set XX to a 2-element set YY?

Solution
Idea

Each input picks an output independently.

  • Each of 3 inputs has 2 choices: 2⋅2⋅2=23=82 \cdot 2 \cdot 2 = 2^3 = 8.
  • Answer: 8
Revision overview
A ruleMaps inputs to outputs
sq(x) = x²; x is a parameter
Three setsDomain: input set
Codomain: possible outputs
Range: outputs that occur ⊆ codomain
Function as relationR_f = {(x, f(x))}
Defined on the entire domain
Single valued: exactly one y
FunctionsWeek 1 · Functions
GraphsGraph of f = plot of R_f
y = x²: a parabola, range ≥ 0
Linesf(x) = 3.5x + 5.7
Slope 3.5, intercept 5.7
Domain = codomain = range = ℝ
Square rootPositive root by convention
Codomain ℝ: domain x ≥ 0
Codomain ℂ: domain ℝ
Revision: functions on one page
Next · Functions · Part 2 of 2Types of Functions
10
Functions · Part 2 of 2

Types of Functions

Functions are classified by how their arrows land in the codomain. Do different inputs always give different outputs? Is every possible output actually reached? The answers give injective, surjective and bijective functions, and bijections let us compare the sizes of sets without counting.

10.1Injective (one-one)

Definition: injective

ff is injective (one-one) if different inputs produce different outputs: if x1≠x2x_1 \neq x_2 then f(x1)≠f(x2)f(x_1) \neq f(x_2). Equivalently, each element of XX maps to a distinct element of YY.

To prove injectivity it is often easier to use the contrapositive: if f(x1)=f(x2)f(x_1) = f(x_2) then x1=x2x_1 = x_2.

Injective
f(x)=3x+5f(x) = 3x + 5

If 3x1+5=3x2+53x_1 + 5 = 3x_2 + 5 then x1=x2x_1 = x_2. So different inputs never share an output.

Not injective
f(x)=7x2f(x) = 7x^2

For any aa, f(a)=f(−a)f(a) = f(-a). For example f(2)=f(−2)=28f(2) = f(-2) = 28.

10.2Surjective (onto)

Definition: surjective

ff is surjective (onto) if the range is the codomain: for every y∈codomain(f)y \in \text{codomain}(f), there is an x∈domain(f)x \in \text{domain}(f) such that f(x)=yf(x) = y.

FunctionCodomainRangeSurjective?
f(x)=−7x+10f(x) = -7x + 10R\mathbb{R}R\mathbb{R} (solve x=10−y7x = \frac{10 - y}{7})Yes
f(x)=5x2+3f(x) = 5x^2 + 3R\mathbb{R}[3,∞)[3, \infty) since x2≥0x^2 \ge 0No
f(x)=7xf(x) = 7\sqrt{x}R\mathbb{R}[0,∞)[0, \infty)No
Surjectivity depends on the codomain you choose. f(x)=x2f(x) = x^2 is not onto R\mathbb{R}, but the same rule is onto [0,∞)[0, \infty). Injectivity, by contrast, does not depend on the codomain.

10.3Bijective (one-to-one correspondence)

Definition: bijective

ff is bijective if it is a 1-1 correspondence between domain and codomain:

  • Every x∈domain(f)x \in \text{domain}(f) maps to a distinct y∈codomain(f)y \in \text{codomain}(f).
  • Every y∈codomain(f)y \in \text{codomain}(f) has a unique pre-image x∈domain(f)x \in \text{domain}(f) such that y=f(x)y = f(x).
Injective, not surjective123abcdc has no pre-imageSurjective, not injective1234abcb is hit twiceBijective123abcperfect pairingNeither123abca hit twice, c missed
Figure 45. The four combinations of injective and surjective
Theorem

A function is bijective if and only if it is injective and surjective.

  1. Bijective ⇒\Rightarrow injective and surjective. This follows directly from the definition: distinct outputs is injectivity, and every yy having a pre-image is surjectivity.
  2. Injective and surjective ⇒\Rightarrow bijective. Injectivity guarantees that ff satisfies the first condition of a bijection (distinct outputs).
  3. Surjectivity says every y∈codomain(f)y \in \text{codomain}(f) has a pre-image. Injectivity guarantees this pre-image is unique, which is the second condition.
f : X → YDo two different inputsever share an output?NoinjectiveYesnot injectiveIs every element of Yan output? (range = Y)Is every element of Yan output? (range = Y)Bijectiveone-one and ontoInjective onlyone-one, not ontoSurjective onlyonto, not one-oneNeithernot one-one, not ontoYesNoYesNo
Figure 46. Two questions decide the type of any function

10.4Bijections and cardinality

For finite sets we can count the items. But what if we have two large sacks filled with marbles? Do we need to count the marbles in each sack? No: pull out marbles in pairs, one from each sack, and see whether both sacks become empty simultaneously. If they do, the pairing is a bijection between the marbles in the two sacks.

Sack 1Sack 2Pull out marbles in pairs, one from each sack.If both sacks become empty together, the sacks match one-to-one.That pairing is a bijection, so both sacks have the same number of marbles.
Figure 47. A bijection compares sizes without counting
Key idea

A bijection establishes that the domain and codomain have the same cardinality. This is how we compare the sizes of infinite sets.

For infinite sets. How many lines are there? Every (non-vertical) line y=mx+cy = mx + c is determined uniquely by the pair (m,c)(m, c), and vice versa. So the number of such lines is the same as the cardinality of R×R\mathbb{R} \times \mathbb{R}.

Also, for every pair of points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) there is a unique line through both points. Does this show that (R×R)×(R×R)=R2×R2(\mathbb{R} \times \mathbb{R}) \times (\mathbb{R} \times \mathbb{R}) = \mathbb{R}^2 \times \mathbb{R}^2 has the same cardinality as R×R\mathbb{R} \times \mathbb{R}? Not this way: the correspondence (pair of points →\to line) is not a bijection, because many pairs of points describe the same line.

xythe line y = 2x + 1unique↔mc(2, 1)the point (m, c) in ℝ × ℝpair 1 (green) and pair 2 (blue)give the same line: not a bijection
Figure 48. Lines match pairs (m, c) one-to-one, but not pairs of points
A careful reading. The argument above only shows that this particular correspondence is not a bijection, so it proves nothing either way about the two sizes. (In fact R2×R2\mathbb{R}^2 \times \mathbb{R}^2 and R×R\mathbb{R} \times \mathbb{R} do have the same cardinality, but that needs a different argument, beyond this course.) Do not read "No" as "they have different sizes".
Example 24Range and surjectivity of x²

Suppose f:R→Rf : \mathbb{R} \to \mathbb{R} is defined as f(x)=x2f(x) = x^2. Find the range of ff and check whether ff is surjective. Is it injective?

Solution
  1. A real square is never negative, and every y≥0y \ge 0 is reached by x=yx = \sqrt{y}. So the range is [0,∞)[0, \infty).
  2. The codomain is R\mathbb{R} but the range is [0,∞)[0, \infty). Since codomain ≠\neq range (for example −1-1 is never an output), ff is not surjective.
  3. f(3)=f(−3)=9f(3) = f(-3) = 9, so ff is not injective either. It is the "neither" case.
Example 25Proving a bijection

Show that f:R→Rf : \mathbb{R} \to \mathbb{R}, f(x)=3x+5f(x) = 3x + 5 is a bijection.

Solution
  1. Injective: suppose f(x1)=f(x2)f(x_1) = f(x_2). Then 3x1+5=3x2+53x_1 + 5 = 3x_2 + 5, so 3x1=3x23x_1 = 3x_2 and x1=x2x_1 = x_2. Equal outputs force equal inputs.
  2. Surjective: take any y∈Ry \in \mathbb{R}. Solve 3x+5=y3x + 5 = y: x=y−53x = \frac{y - 5}{3}, which is a real number. Check: f ⁣(y−53)=(y−5)+5=yf\!\left(\frac{y - 5}{3}\right) = (y - 5) + 5 = y.
  3. Injective and surjective, so by the theorem ff is bijective.
Example 26Classify these functions

All have domain and codomain R\mathbb{R} unless stated: 3x+53x + 5, 7x27x^2, −7x+10-7x + 10, 5x2+35x^2 + 3, and 7x7\sqrt{x} (domain [0,∞)[0, \infty)).

Solution
FunctionInjective?Surjective?Type
3x+53x + 5YesYesBijective
7x27x^2No: f(a)=f(−a)f(a) = f(-a)No: range [0,∞)[0, \infty)Neither
−7x+10-7x + 10Yes: a line with slope ≠0\neq 0YesBijective
5x2+35x^2 + 3No: f(1)=f(−1)=8f(1) = f(-1) = 8No: range [3,∞)[3, \infty)Neither
7x7\sqrt{x}Yes: bigger xx gives bigger x\sqrt{x}No: range [0,∞)[0, \infty)Injective only

10.5Summary

  • A function is given by a rule mapping inputs to outputs.
  • Define the domain, codomain and range.
  • Associate a relation RfR_f with each function ff.
  • Properties of functions: injective (one-one), surjective (onto).
  • Bijections: injective and surjective.
  • A bijection establishes that domain and codomain have the same cardinality.

10.6Going deeper: injective, surjective and the sizes of sets

  • Two questions. (1) Can two different inputs share an output? If never, ff is injective. (2) Is every codomain element hit? If yes, ff is surjective. Both yes means bijective.
  • Graph tests. If every horizontal line meets the graph at most once, ff is injective. If every horizontal line through the codomain meets it at least once, ff is surjective.
  • Finite sets and sizes. Injective needs ∣X∣≤∣Y∣|X| \le |Y|. Surjective needs ∣X∣≥∣Y∣|X| \ge |Y|. Bijective needs ∣X∣=∣Y∣|X| = |Y|. If ∣X∣=∣Y∣|X| = |Y| is finite, then injective, surjective and bijective all mean the same thing.
  • Repairing a function. Shrink the codomain to the range to make it onto, and restrict the domain to make it one-one. For example x2x^2 on R→R\mathbb{R} \to \mathbb{R} is neither, but x2x^2 on [0,∞)→[0,∞)[0, \infty) \to [0, \infty) is bijective.
  • Proof templates. Injective: assume f(x1)=f(x2)f(x_1) = f(x_2) and show x1=x2x_1 = x_2. Surjective: take any yy, solve for xx and check xx lies in the domain. To disprove, give one counterexample.
  • Infinite sets. The map n↦2nn \mapsto 2n is a bijection from N\mathbb{N} to the even naturals. So these two sets have the same cardinality, even though the evens form a proper subset.
  • Lines. f(x)=mx+cf(x) = mx + c with m≠0m \neq 0 is a bijection R→R\mathbb{R} \to \mathbb{R}, with inverse x=y−cmx = \frac{y - c}{m}.

10.7Composition and inverse of functions

A. Composition

If g:X→Yg : X \to Y and f:Y→Zf : Y \to Z, the composition f∘g:X→Zf \circ g : X \to Z is "first gg, then ff":

(f∘g)(x)=f(g(x))(f \circ g)(x) = f\big(g(x)\big)
  • The output of gg must be a legal input for ff: the codomain of gg must fit inside the domain of ff.
  • Order matters. For f(x)=2x+3f(x) = 2x + 3 and g(x)=x2g(x) = x^2: (f∘g)(x)=2x2+3(f \circ g)(x) = 2x^2 + 3 but (g∘f)(x)=(2x+3)2=4x2+12x+9(g \circ f)(x) = (2x + 3)^2 = 4x^2 + 12x + 9. At x=2x = 2: (f∘g)(2)=11(f \circ g)(2) = 11 while (g∘f)(2)=49(g \circ f)(2) = 49.
  • Composition is associative: h∘(g∘f)=(h∘g)∘fh \circ (g \circ f) = (h \circ g) \circ f. The identity function id⁡(x)=x\operatorname{id}(x) = x satisfies f∘id⁡=id⁡∘f=ff \circ \operatorname{id} = \operatorname{id} \circ f = f.
FactWhy
f,gf, g injective ⇒\Rightarrow f∘gf \circ g injectivef(g(x1))=f(g(x2))⇒g(x1)=g(x2)⇒x1=x2f(g(x_1)) = f(g(x_2)) \Rightarrow g(x_1) = g(x_2) \Rightarrow x_1 = x_2.
f,gf, g surjective ⇒\Rightarrow f∘gf \circ g surjectiveEvery zz is f(y)f(y) for some yy, and every yy is g(x)g(x) for some xx.
f∘gf \circ g injective ⇒\Rightarrow gg injectiveIf g(x1)=g(x2)g(x_1) = g(x_2) then f(g(x1))=f(g(x2))f(g(x_1)) = f(g(x_2)), so x1=x2x_1 = x_2. (The inner function.)
f∘gf \circ g surjective ⇒\Rightarrow ff surjectiveEvery zz is f(something)f(\text{something}). (The outer function.)

B. The inverse function

A function f:X→Yf : X \to Y has an inverse f−1:Y→Xf^{-1} : Y \to X exactly when ff is a bijection. Then f−1(f(x))=xf^{-1}(f(x)) = x for all x∈Xx \in X and f(f−1(y))=yf(f^{-1}(y)) = y for all y∈Yy \in Y. Injective is needed so each yy comes from only one xx; surjective is needed so every yy comes from some xx.

  • How to find it: write y=f(x)y = f(x), solve for xx in terms of yy, then rename. For f(x)=2x+3f(x) = 2x + 3: x=y−32x = \dfrac{y - 3}{2}, so f−1(y)=y−32f^{-1}(y) = \dfrac{y - 3}{2}.
  • f(x)=2x+1x−3f(x) = \dfrac{2x + 1}{x - 3} (for x≠3x \neq 3, onto R−{2}\mathbb{R} - \{2\}): y(x−3)=2x+1⇒x(y−2)=3y+1⇒x=3y+1y−2y(x - 3) = 2x + 1 \Rightarrow x(y - 2) = 3y + 1 \Rightarrow x = \dfrac{3y + 1}{y - 2}, so f−1(y)=3y+1y−2f^{-1}(y) = \dfrac{3y + 1}{y - 2}. Check: f(5)=112f(5) = \tfrac{11}{2} and f−1(112)=33/2+111/2−2=35/27/2=5f^{-1}(\tfrac{11}{2}) = \dfrac{33/2 + 1}{11/2 - 2} = \dfrac{35/2}{7/2} = 5 ✓.
  • f(x)=x2f(x) = x^2 on R\mathbb{R} has no inverse (not injective: f(2)=f(−2)f(2) = f(-2)). Restrict to [0,∞)→[0,∞)[0, \infty) \to [0, \infty) and it becomes a bijection with inverse y\sqrt{y}.
  • (f∘g)−1=g−1∘f−1(f \circ g)^{-1} = g^{-1} \circ f^{-1}: undo the last step first.

C. The inverse image is not the inverse function

For any function f:X→Yf : X \to Y and S⊆YS \subseteq Y, the inverse image f−1(S)={x∈X:f(x)∈S}f^{-1}(S) = \{x \in X : f(x) \in S\} is always defined, even when ff has no inverse function. For f(x)=x2f(x) = x^2 on R\mathbb{R}: f−1({4,9})={−3,−2,2,3}f^{-1}(\{4, 9\}) = \{-3, -2, 2, 3\}, which has 44 elements, while f−1({−1})=∅f^{-1}(\{-1\}) = \emptyset.

10.8Exam tips and common mistakes

Exam tips
  • For "classify the function" answer two questions in a table: injective? surjective?
  • Say which codomain you assume: surjectivity depends on it, injectivity does not.
  • For proofs, follow the templates; for disproofs, give one explicit counterexample.
Common mistakes
  • Calling x2:R→Rx^2 : \mathbb{R} \to \mathbb{R} onto. Negative numbers are never outputs.
  • Saying 7x7\sqrt{x} is bijective onto R\mathbb{R}. Its range is only [0,∞)[0, \infty).
  • Confusing the two words: injective is about distinct outputs, surjective is about covering the codomain.
  • Concluding "different sizes" from a map that is not a bijection (it only shows that map fails).

Practice questions (graded-assignment style)

Q1Classify x squared

Multiple Choice Question (MCQ): choose the one correct option.

The function f:R→Rf : \mathbb{R} \to \mathbb{R}, f(x)=x2f(x) = x^2 is

1
injective but not surjective
2
surjective but not injective
3
bijective
4
neither injective nor surjective
Solution
Idea

Check both questions.

  • Not injective: f(3)=f(−3)=9f(3) = f(-3) = 9.
  • Not surjective: the range is [0,∞)[0, \infty), so −1-1 is never an output.
  • Answer: option 4.
Q2Bijections

Multiple Select Question (MSQ): select all that apply.

Which of these functions R→R\mathbb{R} \to \mathbb{R} are bijections?

1
f(x)=2x−7f(x) = 2x - 7
2
f(x)=x2+1f(x) = x^2 + 1
3
f(x)=−x+4f(x) = -x + 4
4
f(x)=5x2f(x) = 5x^2
Solution
Idea

Lines with non-zero slope are bijections; parabolas are not.

  • 2x−72x - 7 and −x+4-x + 4 are lines with slope ≠0\neq 0, hence bijective.
  • x2+1x^2 + 1 and 5x25x^2 fail injectivity (f(a)=f(−a)f(a) = f(-a)) and surjectivity.
  • Answer: options 1 and 3.
Q3Sizes of sets

Multiple Choice Question (MCQ): choose the one correct option.

f:X→Yf : X \to Y with ∣X∣=3|X| = 3 and ∣Y∣=5|Y| = 5. Which statement is possible?

1
ff is surjective.
2
ff is injective.
3
ff is bijective.
4
None of these.
Solution
Idea

Compare the sizes.

  • Surjective needs ∣X∣≥∣Y∣|X| \ge |Y|, but 3<53 < 5. Bijective needs equal sizes.
  • Injective needs ∣X∣≤∣Y∣|X| \le |Y|, which holds, and such a function exists (map 3 elements to 3 different elements).
  • Answer: option 2.
Q4Pre-image

Numerical Answer Type (NAT).

For f(x)=3x+5f(x) = 3x + 5 on R\mathbb{R}, find the input xx with f(x)=14f(x) = 14.

Solution
Idea

Solve the equation, using that f is a bijection so the answer is unique.

  • 3x+5=143x + 5 = 14 gives 3x=93x = 9, so x=3x = 3.
  • Check: 3⋅3+5=143 \cdot 3 + 5 = 14.
  • Answer: 3
F1Composition at a point

Numerical Answer Type (NAT).

f(x)=2x+3f(x) = 2x + 3 and g(x)=x2g(x) = x^2. Find (f∘g)(2)(f \circ g)(2).

Solution
Idea

f∘gf \circ g means apply gg first.

  • g(2)=4g(2) = 4, then f(4)=2⋅4+3=11f(4) = 2 \cdot 4 + 3 = 11.
  • (The other order would give g(f(2))=g(7)=49g(f(2)) = g(7) = 49, a different number.)
  • Answer: 11
F2Finding an inverse and evaluating it

Numerical Answer Type (NAT).

f(x)=2x+1x−3f(x) = \dfrac{2x + 1}{x - 3} (defined for x≠3x \neq 3, taking every real value except 22). Find f−1(5)f^{-1}(5).

Solution
Idea

Solving y=f(x)y = f(x) for xx gives f−1f^{-1}. Alternatively, f−1(5)f^{-1}(5) is the xx with f(x)=5f(x) = 5.

  • 2x+1x−3=5⇒2x+1=5x−15⇒16=3x⇒x=163\dfrac{2x + 1}{x - 3} = 5 \Rightarrow 2x + 1 = 5x - 15 \Rightarrow 16 = 3x \Rightarrow x = \dfrac{16}{3}.
  • Check with the formula f−1(y)=3y+1y−2f^{-1}(y) = \dfrac{3y + 1}{y - 2}: 163\dfrac{16}{3} ✓. And f(163)=32/3+116/3−3=35/37/3=5f\left(\tfrac{16}{3}\right) = \dfrac{32/3 + 1}{16/3 - 3} = \dfrac{35/3}{7/3} = 5 ✓.
  • Answer: 16/3 (about 5.33)
F3Composition and injectivity or surjectivity

Multiple Select Question (MSQ): select all that apply.

ff and gg are functions such that f∘gf \circ g is defined. Choose the correct statements.

1
f∘g=g∘ff \circ g = g \circ f always.
2
If ff and gg are injective, then f∘gf \circ g is injective.
3
If f∘gf \circ g is injective, then gg is injective.
4
If f∘gf \circ g is surjective, then gg is surjective.
5
If ff and gg are bijections, then (f∘g)−1=g−1∘f−1(f \circ g)^{-1} = g^{-1} \circ f^{-1}.
Solution
Idea

The inner function gg carries injectivity; the outer function ff carries surjectivity.

  • 1 ✗ f(x)=2x+3f(x) = 2x + 3, g(x)=x2g(x) = x^2 give 1111 and 4949 at x=2x = 2.
  • 2 ✓ Injective maps compose to an injective map.
  • 3 ✓ g(x1)=g(x2)⇒f(g(x1))=f(g(x2))⇒x1=x2g(x_1) = g(x_2) \Rightarrow f(g(x_1)) = f(g(x_2)) \Rightarrow x_1 = x_2.
  • 4 ✗ Surjectivity of f∘gf \circ g forces ff to be surjective, not gg. Example: g:{1}→{1,2}g : \{1\} \to \{1, 2\}, g(1)=1g(1) = 1, and f:{1,2}→{7}f : \{1, 2\} \to \{7\}, f(1)=f(2)=7f(1) = f(2) = 7. Then f∘g:{1}→{7}f \circ g : \{1\} \to \{7\} is surjective but gg misses 22.
  • 5 ✓ Undo the last step first.
  • Answer: options 2, 3 and 5.
F4An inverse image

Numerical Answer Type (NAT).

f:R→Rf : \mathbb{R} \to \mathbb{R}, f(x)=x2f(x) = x^2. How many elements does f−1({4,9})f^{-1}(\{4, 9\}) have?

Solution
Idea

The inverse image of a set is every xx that ff sends into the set. It exists even though ff has no inverse function.

  • x2=4⇒x=±2x^2 = 4 \Rightarrow x = \pm 2 and x2=9⇒x=±3x^2 = 9 \Rightarrow x = \pm 3.
  • f−1({4,9})={−3,−2,2,3}f^{-1}(\{4, 9\}) = \{-3, -2, 2, 3\}, which has 4 elements.
  • Answer: 4
Revision overview
Injective (one-one)x₁ ≠ x₂ ⇒ f(x₁) ≠ f(x₂)
3x + 5 yes; 7x² no
Surjective (onto)Range = codomain
−7x + 10 yes
5x² + 3, 7√x no (codomain ℝ)
Bijective1-1 correspondence
Unique pre-image for every y
Bijective ⇔ injective + surjective
Types of FunctionsWeek 1 · Functions
CardinalityBijection ⇒ same cardinality
Marbles: pair them off
Lines y = mx + c ↔ ℝ × ℝ
Watch outPairs of points → lines is many-to-one
So it is not a bijection
Codomain choice changes "onto"
Revision: types of functions on one page
Next · All topicsWeek 1 Summary Sheet
11
All topics

Week 1 Summary Sheet

Everything from Week 1 on one sheet, for a last-minute revision.

Number system

Number system
  • N={0,1,2,… }\mathbb{N} = \{0, 1, 2, \dots\}, Z={…,−1,0,1,… }\mathbb{Z} = \{\dots, -1, 0, 1, \dots\}
  • Q={p/q:p,q∈Z, q≠0}\mathbb{Q} = \{p/q : p, q \in \mathbb{Z},\ q \neq 0\}; reduced form when gcd⁡(p,q)=1\gcd(p, q) = 1
  • R\mathbb{R} = rationals + irrationals (2,π,e\sqrt{2}, \pi, e); −1∈C\sqrt{-1} \in \mathbb{C}
  • N⊂Z⊂Q⊂R⊂C\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}
Arithmetic facts
  • m×nm \times n = repeated addition; mkm^k = repeated multiplication
  • a mod ba \bmod b = remainder; a∣b  ⟺  b mod a=0a \mid b \iff b \bmod a = 0
  • Prime: exactly two factors; 1 is not prime
  • Prime factorisation is unique: 126=2⋅32⋅7126 = 2 \cdot 3^2 \cdot 7
Sets
  • Unordered, no duplicates; ∣S∣|S| = cardinality
  • X⊆YX \subseteq Y: all of XX in YY; X=Y  ⟺  X⊆Y, Y⊆XX = Y \iff X \subseteq Y,\ Y \subseteq X
  • ∅⊆X\emptyset \subseteq X; nn elements give 2n2^n subsets
  • Comprehension: {transform∣generate, filter}\{\text{transform} \mid \text{generate},\ \text{filter}\}
Relations and functions
  • A×B={(a,b)∣a∈A, b∈B}A \times B = \{(a, b) \mid a \in A,\ b \in B\}; relation R⊆A×BR \subseteq A \times B
  • Equivalence = reflexive + symmetric + transitive; partitions the set
  • Function: each input has exactly one output; range ⊆ codomain
  • Bijective   ⟺  \iff injective + surjective

Set operations at a glance

OperationNotationContainsWith X={A,B,C,D}X = \{A, B, C, D\}, Y={A,D,E,F}Y = \{A, D, E, F\}
UnionX∪YX \cup Yelements in X or Y{A,B,C,D,E,F}\{A, B, C, D, E, F\}
IntersectionX∩YX \cap Yelements in both{A,D}\{A, D\}
DifferenceX−Y, X∖YX - Y,\ X \setminus Yin X, not in Y{B,C}\{B, C\}
ComplementX‾, Xc\overline{X},\ X^cin U, not in XU−XU - X
Countingn(X∪Y)n(X \cup Y)n(X)+n(Y)−n(X∩Y)n(X) + n(Y) - n(X \cap Y)4+4−2=64 + 4 - 2 = 6

Intervals

[a,b][a, b](a,b)(a, b)(a,b](a, b][a,b)[a, b)
Conditiona≤x≤ba \le x \le ba<x<ba < x < ba<x≤ba < x \le ba≤x<ba \le x < b
Nameclosedopenleft openright open

Relation properties and function types

Relation on S
PropertyTest
Reflexive(x,x)∈R(x, x) \in R for all x
Symmetric(a,b)⇒(b,a)(a, b) \Rightarrow (b, a)
Transitive(a,b),(b,c)⇒(a,c)(a, b), (b, c) \Rightarrow (a, c)
Antisymmetrica≠ba \neq b: not both ways
Function f:X→Yf : X \to Y
TypeTest
Injectivex1≠x2⇒f(x1)≠f(x2)x_1 \neq x_2 \Rightarrow f(x_1) \neq f(x_2)
Surjectiverange = codomain
Bijectiveboth
Domain of x\sqrt{x}[0,∞)[0, \infty) when codomain is R\mathbb{R}

Decision tree for function types

f : X → YDo two different inputsever share an output?NoinjectiveYesnot injectiveIs every element of Yan output? (range = Y)Is every element of Yan output? (range = Y)Bijectiveone-one and ontoInjective onlyone-one, not ontoSurjective onlyonto, not one-oneNeithernot one-one, not ontoYesNoYesNo
Figure 49. Classify any function with two questions
Five things to remember

1. N\mathbb{N} includes 0 in this course. 2. Rationals and reals are dense; integers are discrete. 3. A set with nn elements has 2n2^n subsets. 4. Check transitivity on every chain. 5. Whether a function is onto depends on the codomain you choose.

Exam tips: last-minute checklist

Do
  • N\mathbb{N} includes 0; 1 is not prime
  • Check divisions with a=bq+ra = bq + r
  • Say ∈\in for elements and ⊆\subseteq for sets
  • Count: subsets 2n2^n, pairs ∣A∣∣B∣|A||B|, relations 2∣A∣∣B∣2^{|A||B|}, functions ∣Y∣∣X∣|Y|^{|X|}
  • Check transitivity on every chain
  • State the codomain before deciding surjective
  • Draw the Venn diagram first
Do not
  • Call 16\sqrt{16} irrational
  • Add numerators and denominators separately
  • Treat ∅\emptyset and {∅}\{\emptyset\} as equal
  • Use a square bracket with ∞\infty
  • Say symmetric and antisymmetric are opposites
  • Call x2:R→Rx^2 : \mathbb{R} \to \mathbb{R} onto
  • Assume X−Y=Y−XX - Y = Y - X

Counting formulas

What to countFormula
Subsets of an nn-element set2n2^n (proper: 2n−12^n - 1)
Pairs in A×BA \times B∣A∣⋅∣B∣|A| \cdot |B|
Relations from AA to BB2∣A∣⋅∣B∣2^{|A| \cdot |B|}
Functions from XX to YY∣Y∣∣X∣|Y|^{|X|}
Union of two setsn(P)+n(B)−n(P∩B)n(P) + n(B) - n(P \cap B)
Classes of "same remainder mod nn"nn
Back to top