Sets, Number Systems, and Summation Formulas – CS 182 Study Notes
offline

Difficulty: Introductory | Prerequisites: Basic algebra.

Sets and summation formulas are utility topics in CS 182. Sets give you the language to talk about collections of objects (which underpins everything from database theory to probability), and closed-form sums let you evaluate loops and recurrences when analysing algorithm complexity. Neither is deep on its own, but both are tools you will reach for constantly in Big O analysis and proof problems.

TL;DR

Number systems nest inside each other (naturals inside integers inside rationals, and so on up to complex numbers), and subset notation lets you express those containment relationships precisely. Summation formulas give you closed-form expressions for common sums (arithmetic series, sums of squares, geometric series), which you will use constantly to evaluate the running time of loops in Big O analysis.


Key Terms

Set

An unordered collection of distinct elements. Think of it as a bag where duplicates are ignored and order does not matter.

Subset (A ⊆ B)

Every element of A is also an element of B. A can equal B and still be a subset. In simple terms, A fits entirely inside B.

Proper Subset (A ⊂ B)

A is a subset of B and A ≠ B. B has at least one element that A does not.

Natural Numbers (ℕ)

The counting numbers: 0, 1, 2, 3, ... (whether 0 is included depends on convention; CS 182 typically includes it).

Integers (ℤ)

All whole numbers, positive and negative: ..., −2, −1, 0, 1, 2, ...

Rational Numbers (ℚ)

Any number expressible as a fraction p/q where p, q are integers and q ≠ 0. Think of it as "anything you can write as a ratio."

Real Numbers (ℝ)

All numbers on the number line, including irrationals like √2 and π.

Imaginary Numbers (𝕀)

Numbers of the form bi where b is real and i = √(−1).

Complex Numbers (ℂ)

Numbers of the form a + bi where a and b are real. The superset that contains all the other number systems.

Geometric Series

A sum of the form ∑ ar^k. When |r| < 1, the infinite series converges to a/(1 − r). Think of it as repeated multiplication by a fixed ratio.

Arithmetic Series

A sum where consecutive terms differ by a constant. The classic example: 1 + 2 + ... + n = n(n+1)/2.


Core Content

Number System Hierarchy

The number sets nest as follows: ℕ ⊆ ℤ ⊆ ℚ ⊆ ℝ ⊆ ℂ, with 𝕀 (imaginary numbers) sitting alongside ℝ inside ℂ.

  • ℕ (Natural numbers): 0, 1, 2, 3, ...

  • ℤ (Integers): ..., −2, −1, 0, 1, 2, ...

  • ℚ (Rationals): any p/q with integer p, q and q ≠ 0

  • ℝ (Reals): all points on the number line

  • 𝕀 (Imaginary): bi where b is real

  • ℂ (Complex): a + bi where a, b are real

Subset Notation

  • A ⊆ B means A is a subset of B (A could equal B)

  • A ⊂ B means A is a proper subset of B (A ≠ B, so B has something A does not)

Summation Formulas

These are the closed-form expressions you need to know. They come up whenever you are evaluating the running time of nested loops or simplifying recurrences.

Geometric series (r ≠ 0):

∑(k=0 to n) ar^k = a(r^(n+1) − a) / (r − 1)

Sum of first n natural numbers:

∑(k=1 to n) k = n(n + 1) / 2

Sum of squares:

∑(k=1 to n) k² = n(n + 1)(2n + 1) / 6

Sum of cubes:

∑(k=1 to n) k³ = n²(n + 1)² / 4

Note: the sum of cubes equals the square of the sum of first n natural numbers. This identity is worth remembering.

Infinite geometric series (|x| < 1):

∑(k=0 to ∞) x^k = 1 / (1 − x)

Derivative of geometric series (|x| < 1):

∑(k=1 to ∞) kx^(k−1) = 1 / (1 − x)²

This last one is derived by differentiating the infinite geometric series term by term.


Common Misconceptions

  • Students confuse ⊆ (subset) with ⊂ (proper subset). A set is always a subset of itself (A ⊆ A is true), but never a proper subset of itself (A ⊂ A is false).

  • The infinite geometric series formula 1/(1 − x) only works when |x| < 1. Students sometimes apply it without checking the convergence condition, which gives nonsensical results.

  • When using the sum formulas, pay attention to whether the index starts at 0 or 1. The geometric series starts at k = 0; the arithmetic sum starts at k = 1. Getting this wrong shifts your answer.

  • Students sometimes forget that ℕ ⊂ ℤ ⊂ ℚ ⊂ ℝ is a strict nesting. Every natural number is an integer, but not every integer is a natural number. This matters when a proof requires you to specify which set a variable belongs to.


Why It Matters / Exam Flags

⚠️ The sum formula ∑ k = n(n+1)/2 is the single most-used identity in algorithm analysis. Know it cold.

⚠️ Geometric series closed forms appear in divide-and-conquer recurrence solutions. You will need the finite form for Big O proofs.

⚠️ Subset vs proper subset notation (⊆ vs ⊂) is a common source of lost marks on set-theory questions.

⚠️ The number hierarchy (ℕ ⊆ ℤ ⊆ ℚ ⊆ ℝ ⊆ ℂ) is tested as a quick knowledge check. Know which sets sit inside which.


Quick Self-Test

  1. True or false: ℤ ⊂ ℕ. Answer: False. It is the other way round: ℕ ⊂ ℤ.

  1. Fill in the blank: ∑(k=1 to n) k = ____ Answer: n(n + 1) / 2

  1. True or false: The infinite geometric series ∑ x^k converges for x = 1.5. Answer: False. It requires |x| < 1.

  1. What is the closed form of ∑(k=1 to n) k²? Answer: n(n + 1)(2n + 1) / 6

  1. True or false: A ⊆ A is always true. Answer: True. Every set is a subset of itself.


Practice Q&A

Q: Evaluate ∑(k=1 to 100) k using the closed-form formula.

A: 100 × 101 / 2 = 5050.

Q: A loop runs from i = 1 to n, and inside it another loop runs from j = 1 to i. Express the total number of iterations as a closed-form sum.

A: The total is ∑(i=1 to n) i = n(n + 1) / 2.

Q: Is ℚ a proper subset of ℝ? Explain.

A: Yes. Every rational number is a real number, but ℝ contains irrationals (like √2) that are not in ℚ. So ℚ ⊂ ℝ.

Q: Compute the infinite geometric sum ∑(k=0 to ∞) (1/3)^k.

A: Since |1/3| < 1, the sum converges to 1 / (1 − 1/3) = 1 / (2/3) = 3/2.

Q: What is the closed form of ∑(k=1 to n) k³?

A: n²(n + 1)² / 4, which is also [n(n + 1) / 2]², the square of the arithmetic sum.


Connections to Other Topics

The summation formulas connect directly to Big O analysis: when you see a loop iterating 1 + 2 + ... + n times, the closed form n(n+1)/2 tells you the complexity is O(n²). Geometric series appear when solving recurrences for divide-and-conquer algorithms (merge sort, binary search). Set notation and the number hierarchy come back in formal proofs and in the definitions of functions and relations later in the course.


Related Terms / Search Tags

Sets, subset, proper subset, number systems, natural numbers, integers, rationals, reals, complex numbers, imaginary numbers, number hierarchy, number classification, summation formulas, closed-form sums, arithmetic series, Gauss sum, sum of squares, sum of cubes, geometric series, infinite series, convergence, power series, ∑ notation, sigma notation, CS 182, Purdue, foundations of computer science