Home > Math for DS > Topics > Topic 2
Topic 2 of 10

๐Ÿ”ข Topic 2: Rational Numbers

Topic 2/10 โญโญ Intermediate โฑ๏ธ ~20 min

๐ŸŽฏ Learning Objectives

  • Understand the definition and notation of rational numbers (โ„š)
  • Learn about non-unique representation of rational numbers
  • Master the concept of reduced form and greatest common divisor
  • Explore the density property of rational numbers
  • Understand why rational numbers have no "next" number

2.1 Definition

๐Ÿ“ Notation

โ„š (from "quotient" or "ratio")

๐Ÿ“š Definition

Rational Number: Any number that can be expressed as p/q where:

  • p, q โˆˆ โ„ค (both are integers)
  • q โ‰  0 (denominator cannot be zero)

๐Ÿ’ก Examples of Rational Numbers

Positive Fractions

3/5, 7/8, 22/7

Negative Fractions

-7/4, -15/23, -1/3

Integers as Rationals

5 = 5/1, -3 = -3/1, 0 = 0/1

Terminating Decimals

0.75 = 3/4, 0.125 = 1/8

๐Ÿ”— Relationship to Integers

Every integer is a rational number because any integer n can be written as n/1. Therefore: โ„ค โІ โ„š

2.2 Non-Unique Representation

๐Ÿ”‘ Key Property

Rational numbers do NOT have unique representations

๐Ÿ“Š Demonstration

3/5
6/10
9/15
30/50
-15/-25

All these fractions represent the same rational number!

๐Ÿค” Why This Happens

Multiplying both numerator and denominator by the same non-zero number gives an equivalent fraction:

$$\frac{p}{q} = \frac{p \times k}{q \times k} \text{ for any } k \neq 0$$

๐ŸŽฎ Interactive Example

Let's see how 2/3 can be represented in multiple ways:

2/3 ร— 2/2 = 4/6
2/3 ร— 5/5 = 10/15
2/3 ร— (-3)/(-3) = -6/-9

2.3 Reduced Form (Canonical Form)

๐Ÿ“š Definition

A rational number p/q is in reduced form when:

  • gcd(p, q) = 1 (p and q have no common factors other than 1)
  • This gives a unique representation

๐Ÿ’ก Example: Reducing 18/60

18/60
โ†’
Find gcd(18, 60)
โ†’
gcd = 6
โ†’
18รท6 / 60รท6
โ†’
3/10

18/60 = 3/10 (in reduced form)

โœจ Uniqueness

Once in reduced form, every rational number has exactly one representation (ignoring the sign placement).

2.4 Greatest Common Divisor (GCD)

๐Ÿ“š Definition

gcd(m, n) is the largest number that divides both m and n

Finding GCD using Prime Factorization

1

Find prime factorization of both numbers

2

Identify common prime factors

3

Multiply the common primes

๐Ÿ” Detailed Example: gcd(18, 60)

18
=
2 ร— 3 ร— 3
= 2ยน ร— 3ยฒ
60
=
2 ร— 2 ร— 3 ร— 5
= 2ยฒ ร— 3ยน ร— 5ยน
Common Prime Factors:
  • 2: min(1, 2) = 1, so we take 2ยน
  • 3: min(2, 1) = 1, so we take 3ยน
  • 5: min(0, 1) = 0, so we don't include 5

gcd(18, 60) = 2ยน ร— 3ยน = 6

๐Ÿ“ Note

There are more efficient algorithms (like the Euclidean algorithm) to find GCD, but prime factorization provides intuitive understanding.

2.5 Density of Rational Numbers

๐Ÿ›๏ธ Theorem

Rational numbers are dense

๐Ÿ“š Definition of Density

Between any two rational numbers, there exists another rational number

๐Ÿ” Proof Sketch

For any r < r', the average (r + r')/2 lies between them

r
(r + r')/2
r'

๐ŸŽฏ Implication

There is NO "next" rational number - unlike integers, we cannot find the immediate successor!

๐Ÿ’ก Example: Between 1/3 and 1/2

Step 1: Find the average
$$\frac{\frac{1}{3} + \frac{1}{2}}{2} = \frac{\frac{2+3}{6}}{2} = \frac{5/6}{2} = \frac{5}{12}$$

So 5/12 lies between 1/3 and 1/2

Step 2: We can continue infinitely!
  • Between 1/3 and 5/12: average = (1/3 + 5/12)/2 = 3/8
  • Between 5/12 and 1/2: average = (5/12 + 1/2)/2 = 11/24
  • Between 3/8 and 5/12: and so on...
๐Ÿ”„ Infinite Process

This process can continue forever, showing that there are infinitely many rational numbers between any two rationals!

๐Ÿ‘๏ธ Visual Representation

1/3
3/8
5/12
11/24
1/2

New rational numbers keep appearing between existing ones!

๐Ÿƒโ€โ™‚๏ธ Practice Problems

Problem 1: Reducing to Lowest Terms

Reduce the following fractions to their lowest terms:

(a) 24/36 (b) 45/75 (c) 48/64

Problem 2: Finding GCD

Find gcd(120, 180) using prime factorization.

Problem 3: Density Property

Find a rational number between 2/5 and 3/7.

๐Ÿ”‘ Key Takeaways

  • Rational numbers are fractions p/q where p, q โˆˆ โ„ค and q โ‰  0
  • Non-unique representation: Same rational can be written in infinitely many ways
  • Reduced form: Unique representation when gcd(p, q) = 1
  • GCD: Found using prime factorization or Euclidean algorithm
  • Density: Between any two rationals, there's always another rational
  • No "next" rational: Unlike integers, rationals have no immediate successor