Sub topic 6
Writing sets of numbers in interval notation
Domains and ranges are sets of real numbers, and you need a compact way to write them. This chapter covers interval notation, the standard shorthand, and how it relates to inequalities and set-builder notation. It assumes you can solve simple inequalities, plot points on a number line, and recognize square roots and fractions in expressions. Later chapters use this notation every time they state a domain or a range.
Three ways to write the same set
Take the numbers that are at least 2 and less than 5. You can describe them in three ways.
- Inequality:
2 ≤ x < 5 - Set-builder notation:
{x : 2 ≤ x < 5}, read "the set of all x such that x is at least 2 and less than 5." - Interval notation:
[2, 5)
Interval notation is the shortest. It lists the smallest number first, then a comma, then the largest number, and it wraps them in brackets or parentheses. The wrapping symbols say whether each endpoint belongs to the set.
Brackets and parentheses
An endpoint is a number at either end of an interval. An endpoint can be included or excluded.
- A square bracket
[or]means the endpoint is included. It matches≤or≥. - A parenthesis
(or)means the endpoint is excluded. It matches<or>.
On a number line, a bracket corresponds to a filled dot and a parenthesis to an open dot. The set [2, 5) includes 2, includes every number between 2 and 5, and stops just short of 5. So 2 is in the set, 4.999 is in the set, and 5 is not.
Infinity always gets a parenthesis
The symbol ∞ means "continues without end." It is not a real number, so no interval can include it as an endpoint. Write ( next to -∞ and ) next to ∞, with no exceptions.
x > 3becomes(3, ∞).x ≥ 3becomes[3, ∞). The 3 gets a bracket and the infinity still gets a parenthesis.x ≤ -1becomes(-∞, -1].
The set of all real numbers is (-∞, ∞).
A reference table
| Inequality | Interval notation | Set-builder notation | In words |
|---|---|---|---|
| `x > 3` | `(3, ∞)` | `{x : x > 3}` | greater than 3 |
| `x ≥ 3` | `[3, ∞)` | `{x : x ≥ 3}` | 3 or greater |
| `x < -1` | `(-∞, -1)` | `{x : x < -1}` | less than -1 |
| `-2 ≤ x < 5` | `[-2, 5)` | `{x : -2 ≤ x < 5}` | from -2, included, up to 5, excluded |
| `0 < x ≤ 10` | `(0, 10]` | `{x : 0 < x ≤ 10}` | above 0, up to and including 10 |
| all real numbers | `(-∞, ∞)` | `{x : x is a real number}` | every real number |
Rules for writing an interval
Follow these rules and you will avoid most notation errors.
- Write the smaller number first.
(5, 2)is not a valid interval. If you see the inequalityx < 5andx > 2, order the endpoints as(2, 5). - Use a comma between the endpoints. Do not use a dash. A dash would be confused with subtraction or a negative sign.
- Read left to right along the number line. The left endpoint is the lower bound and the right endpoint is the upper bound, even when both are negative:
[-8, -3]is correct because -8 is less than -3. - Mix symbols freely.
[2, 5)and(2, 5]are both valid. The two ends are decided separately.
Single points and the empty set
A single number such as 3 is written {3} in set notation. The interval [3, 3] also means just 3, but {3} is the usual form. An interval like (3, 3) contains nothing, so write it as ∅, the empty set. You rarely need either one, but a domain or range can occasionally be a single value. For example, the function f(x) = 7 has the range {7}.
Combining intervals with union
Some sets are not one unbroken stretch. The union symbol ∪ joins two or more intervals into one set. A number belongs to the union if it belongs to at least one of the pieces.
The condition x ≠ 4 means every real number except 4. It splits into two pieces, the numbers below 4 and the numbers above 4:
(-∞, 4) ∪ (4, ∞)
This pattern appears constantly in domains. A function with x - 4 in a denominator cannot accept 4, so its domain is exactly this set.
Follow these rules for unions.
- List the pieces from left to right along the number line.
- Do not write
∪between pieces that overlap or touch with no gap.[1, 3] ∪ [2, 5]is just[1, 5]. - Remember that a union means "or". The overlap of two sets, where both conditions hold at once, is the intersection, written
∩. For example,[1, 5] ∩ [3, 8]is[3, 5]. You mainly meet intersections when two restrictions apply together, such as a square root and a denominator in the same formula.
A point between two pieces needs care. (-∞, 4) ∪ (4, ∞) leaves out 4 because both parentheses touch 4. If you wrote (-∞, 4] ∪ (4, ∞), the number 4 would be included by the first piece, and the set would become all real numbers.
From a restriction to an interval: a worked example
Recall the function g(x) = sqrt(x - 2) / (x - 5). It has two restrictions.
- The square root needs
x - 2 ≥ 0, sox ≥ 2. This gives[2, ∞). - The denominator needs
x ≠ 5. This removes 5 from the set.
Start with [2, ∞) and remove 5. Because 5 lies inside [2, ∞), the set splits into the part below 5 and the part above 5:
[2, 5) ∪ (5, ∞)
The bracket on 2 stays, since 2 is allowed. The parenthesis next to 5 appears on both sides, since 5 is excluded.
Checking membership in code
You can model an interval in Python as four values: the lower bound, the upper bound, and whether each end is closed. The code below tests whether a number belongs to an interval or to a union of intervals. Python's math.inf stands in for ∞.
import math
def in_interval(x, low, high, low_closed, high_closed):
above = x >= low if low_closed else x > low
below = x <= high if high_closed else x < high
return above and below
def in_union(x, intervals):
return any(in_interval(x, *iv) for iv in intervals)
# [2, 5) ∪ (5, ∞), the domain of g(x) = sqrt(x - 2) / (x - 5)
domain_g = [
(2, 5, True, False),
(5, math.inf, False, False),
]
for value in [1.99, 2, 4.9, 5, 5.1, 100]:
print(value, in_union(value, domain_g))
# 1.99 False
# 2 True
# 4.9 True
# 5 False
# 5.1 True
# 100 TrueNotice that the False values at 1.99 and 5 match the two restrictions: 1.99 makes the square root undefined, and 5 makes the denominator zero.
Common errors
- Brackets on infinity.
[3, ∞]is wrong. Write[3, ∞). - Reversed endpoints.
(5, 2)is wrong. Write(2, 5). - Using the wrong symbol for strictness.
x < 5needs), not]. When a problem says "at most" or "at least", use brackets. When it says "less than" or "greater than", use parentheses. - Using a union where a single interval works.
(0, 3) ∪ [3, 6)has no gap, because 3 is covered by the second piece. It simplifies to(0, 6). - Forgetting that excluded points need a union. Writing
(-∞, ∞)for the domain of1 / (x - 4)is wrong because 4 must be removed. - Confusing an interval with an ordered pair.
(2, 5)can also mean the point with x = 2 and y = 5 on the coordinate plane. The context tells you which one is meant. Domains and ranges are always intervals.
Exercises
Exercise
Write the inequality -3 < x ≤ 7 in interval notation and in set-builder notation.
Show answer
Interval notation is (-3, 7], with a parenthesis at -3 because the inequality is strict there and a bracket at 7 because 7 is included. Set-builder notation is {x : -3 < x ≤ 7}.
Exercise
Write the set of all real numbers except 0 in interval notation.
Show answer
(-∞, 0) ∪ (0, ∞). The union has two pieces because 0 splits the number line, and both parentheses touch 0 to exclude it.
Exercise
A function has the domain x ≥ -1 with x ≠ 3. Write the domain in interval notation.
Show answer
[-1, 3) ∪ (3, ∞). Start with [-1, ∞), then remove 3. The bracket stays at -1 because -1 is allowed.
Exercise
What is wrong with each of these? (a) [4, ∞] (b) (9, 1) (c) (-∞, 2] ∪ (2, ∞) written as the domain of 1 / (x - 2).
Show answer
(a) Infinity cannot be included, so it should be [4, ∞). (b) The smaller number must come first, so the interval should be (1, 9). (c) The first piece includes 2, so the union covers every real number. For 1 / (x - 2) the domain must exclude 2, so it should be (-∞, 2) ∪ (2, ∞).