Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 37 ยท Getting Started

Number Sets and Interval Notation

Learn the number sets from natural numbers to reals, how to write intervals and unions, and how to test membership with runnable Python code.

Before you can describe where a function lives, you need a language for sets of numbers. Mathematicians group numbers into families and write ranges of values in a compact notation called interval notation. You will use this notation in every later lesson, especially when stating the domain and range of a function.

This lesson reviews the number sets, then teaches intervals, unions and how to read them on a number line.

The number sets

Each set contains the one before it.

Symbol Name Examples
โ„• Natural numbers 1, 2, 3, ... (some books include 0)
โ„ค Integers ..., -2, -1, 0, 1, 2, ...
โ„š Rational numbers 3/4, -5, 0.2, 1.333... (repeating)
โ„ Real numbers everything on the number line

A rational number is a number that can be written as a fraction p/q of two integers with q โ‰  0. A decimal that stops or repeats is rational. Numbers such as โˆš2 and ฯ€ are real but irrational: their decimals never stop and never repeat.

flowchart TB
R["Real numbers"] --> Q["Rational numbers"]
R --> I["Irrational numbers"]
Q --> Z["Integers"]
Z --> N["Natural numbers"]

Naturals sit inside integers, integers inside rationals, and rationals plus irrationals make the reals.

Python can test whether a number is exactly a fraction by using the fractions module.

Python Rational numbers as exact fractions

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Interval notation

An interval is all the real numbers between two endpoints. Round brackets mean the endpoint is not included. Square brackets mean it is included.

Interval Inequality Meaning
(a, b) a < x < b between a and b, ends excluded
[a, b] a โ‰ค x โ‰ค b between a and b, ends included
[a, b) a โ‰ค x < b includes a, excludes b
(a, โˆž) x > a everything above a
(-โˆž, b] x โ‰ค b everything up to and including b

Infinity is not a number, so it always gets a round bracket. The notation (-โˆž, โˆž) means all real numbers.

Reading and writing intervals

  • x โ‰ฅ 2 becomes [2, โˆž).
  • -1 < x โ‰ค 5 becomes (-1, 5].
  • x < -3 becomes (-โˆž, -3).

On a number line, draw a filled dot for an included endpoint and an open dot for an excluded one.

Unions and intersections

The union A โˆช B contains numbers that are in A or in B (or both). The intersection A โˆฉ B contains numbers in both.

Example: x < -1 or x โ‰ฅ 3 is written (-โˆž, -1) โˆช [3, โˆž). There is a gap between -1 and 3, so a single interval cannot describe it.

Example: x > 0 and x โ‰ค 4 is the intersection (0, โˆž) โˆฉ (-โˆž, 4] = (0, 4].

The excluded single point deserves a mention. All real numbers except 2 is (-โˆž, 2) โˆช (2, โˆž). You will see this exact pattern constantly when a function is undefined at one input.

Now build a small tool that tests whether a number belongs to an interval. It stores each interval as two endpoints and two flags for the brackets.

Python An interval membership checker

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Absolute value and distance

The absolute value |x| is the distance from x to 0, so it is never negative. More generally |x - a| is the distance between x and a.

  • |x| < 3 means x is within 3 units of 0: (-3, 3).
  • |x| > 3 means x is more than 3 units away: (-โˆž, -3) โˆช (3, โˆž).
  • |x - 2| โ‰ค 1 means x is within 1 of 2: [1, 3].

Distance language is useful because later, in the limits chapter, "close to" will be written exactly this way.

Python Distance from a point

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Always use a round bracket next to โˆž or -โˆž. Writing [2, โˆž] is a common mistake, because infinity is not a number you can reach.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which is the interval notation for x โ‰ฅ 2?

    2 is included, so a square bracket. Infinity always takes a round bracket.
  2. 2. Which number is irrational?

    โˆš2 cannot be written as a fraction of integers. The others are all rational.
  3. 3. What is the solution set of |x| > 3 in interval notation?

    Numbers more than 3 units from 0 are below -3 or above 3, which needs a union.
  4. 4. Which describes all real numbers except 2?

    Two open intervals leave out exactly 2. The second option includes 2.

Summary

  • The number sets nest: โ„• inside โ„ค inside โ„š inside โ„; irrational numbers are real but not rational.
  • Interval notation uses round brackets for excluded endpoints and square brackets for included ones.
  • Infinity always gets a round bracket.
  • Use โˆช for "or" and โˆฉ for "and"; |x - a| < r means within r of a.

Next: The Algebra Toolkit