Sub topic 7
Domain: the allowed inputs
This chapter assumes you can already state the definition of a function (one output per input), read the notation f(x), evaluate f at a number, and read basic interval notation such as [2, 5). It also assumes you have seen the vertical line test. Here the focus is on the inputs: what the domain is, how to read it from each representation, and where learners usually go wrong.
What the domain is
The domain of a function is the set of all inputs for which the function is defined. Every input in the domain gets exactly one output. An input outside the domain gets no output, so the function says nothing about it.
The domain is part of the function, not a side note. The rule f(x) = x² can be paired with different domains, and each pairing is a different function:
- With domain all real numbers, f(2) = 4 and f(−2) = 4, so two inputs share one output.
- With domain [0, ∞), the inputs 2 and −2 are no longer both allowed, and each output comes from exactly one input.
When a problem gives only a formula, the convention is to use the largest set of real numbers for which the formula produces a real number. This is the implied domain. When a problem states a domain, the stated domain wins, even if the formula would accept more.
Reading the domain from a mapping or table
For a finite list of input-output pairs, the domain is the set of first entries. Write each input once, even if it appears in several rows.
| x | f(x) |
|---|---|
| −2 | 4 |
| −1 | 1 |
| 0 | 0 |
| 1 | 1 |
| 2 | 4 |
The domain is {−2, −1, 0, 1, 2}. The outputs are 4, 1, 0, 1, 4, so the range is {0, 1, 4}. Notice that the table has repeated outputs but no repeated inputs, which is what makes it a function.
The same idea works in code. This program first checks that the pairs form a function, then collects the first entries.
def is_function(pairs):
seen = {}
for x, y in pairs:
if x in seen and seen[x] != y:
return False
seen[x] = y
return True
def domain(pairs):
if not is_function(pairs):
raise ValueError("these pairs are not a function")
return sorted({x for x, _ in pairs})
table = [(-2, 4), (-1, 1), (0, 0), (1, 1), (2, 4)]
print(domain(table)) # [-2, -1, 0, 1, 2]If you pass pairs where one input has two outputs, the function raises an error. A relation like that has no single set of "allowed inputs with one answer each", so the question about its domain as a function does not apply.
Reading the domain from a graph
On a graph, the domain is every x-value where the graph has a point. A reliable method is to imagine squashing the whole graph straight down onto the x-axis. The part of the x-axis that gets covered is the domain.
Look at the ends and gaps of the graph:
| What you see | What it means for the domain | Notation at that end |
|---|---|---|
| Closed dot at x = a | a is included | square bracket |
| Open dot at x = a | a is excluded | parenthesis |
| Arrow pointing left or right | The graph continues without end | ∞ or −∞ with a parenthesis |
| Hole or break at x = a in the middle | a is excluded, the rest is included | split into a union |
Suppose a graph starts at a closed dot at (−2, 1), rises, and ends at an open dot at (3, 4). The squashed shadow on the x-axis runs from −2 to 3. The left end is included and the right end is not, so the domain is [−2, 3).
Suppose another graph is a curve on the left that ends at an open dot above x = 1, and another curve on the right that starts at a closed dot at x = 1 and runs off to the right. The x-value 1 is covered by the closed dot, so it is in the domain. Only the vertical position differs. The domain is all real numbers up to and including 1, then everything to the right, which merges into (−∞, ∞).
Always read the x-axis for the domain. The y-axis gives the range.
Reading the domain from an equation
For a formula, start by assuming the domain is all real numbers. Then remove every input that breaks the formula. Two things break a formula in the real numbers:
- Division by zero. Any x that makes a denominator zero is excluded.
- An even root of a negative number. Any x that makes the expression under a square root (or fourth root, and so on) negative is excluded.
The next chapter covers this in full. A short example shows the pattern. For f(x) = 1 / (x − 3), the denominator is zero when x = 3, so the domain is all real numbers except 3:
- Interval notation: (−∞, 3) ∪ (3, ∞)
- Set notation: {x : x ≠ 3}
Polynomials such as 2x + 3 or x² − 5x + 1 have no denominators and no roots, so their domain is all real numbers, written (−∞, ∞).
When the domain is stated
A problem may restrict the domain on purpose. Consider f(x) = 2x + 3 for 0 ≤ x ≤ 5. The formula alone accepts any real number, but the stated domain is [0, 5]. The input x = 7 is not in the domain, so f(7) is not defined for this function, even though 2(7) + 3 = 17 is easy to compute.
def f(x):
if not (0 <= x <= 5):
raise ValueError("x is outside the domain of f")
return 2 * x + 3
print(f(0)) # 3
print(f(5)) # 13The check at the top of the function is the domain. Calling f(7) raises an error, which matches the mathematical statement that 7 is not an allowed input. Treat a domain as a precondition on the input, and your code and your algebra will agree.
Writing domains in set and interval notation
Both notations describe the same sets. Interval notation is shorter. Set notation is more explicit, especially for exclusions.
| In words | Set notation | Interval notation |
|---|---|---|
| All real numbers | {x : x is real} | (−∞, ∞) |
| x is at least 2 | {x : x ≥ 2} | [2, ∞) |
| x is less than 5 | {x : x < 5} | (−∞, 5) |
| x is between −1 and 4, with 4 included | {x : −1 < x ≤ 4} | (−1, 4] |
| Everything except 5 | {x : x ≠ 5} | (−∞, 5) ∪ (5, ∞) |
Two rules cover most mistakes. Infinity is never reached, so it always gets a parenthesis. The symbol ∪ means "together with", and it joins separate pieces in increasing order from left to right.
You can also look at a domain through sampling. This code evaluates h(x) = x² at the integers from −3 to 3. The sampled domain is the list of inputs you chose. The outputs show the range of those samples.
def h(x):
return x ** 2
sample_domain = list(range(-3, 4))
print(sample_domain) # [-3, -2, -1, 0, 1, 2, 3]
print(sorted({h(x) for x in sample_domain})) # [0, 1, 4, 9]The real domain of h is all real numbers. The sample covers only seven of them. Sampling can suggest a domain, but it cannot prove one.
Common errors and edge cases
- Reading the wrong axis. The domain comes from x-values. If your answer for a graph is a set of heights, you have found the range.
- Simplifying before finding the domain. Take f(x) = (x² − 4) / (x − 2). It simplifies to x + 2 when x ≠ 2, but the original function is not defined at x = 2. The domain is (−∞, 2) ∪ (2, ∞). Find the domain from the original expression, not the simplified one.
- Excluding zero outputs. Only the problem inputs are excluded. For f(x) = x − 4, the output is 0 when x = 4, and that is fine. The input 4 stays in the domain.
- Excluding inputs that give negative outputs. A negative result is allowed. Negative numbers under an even root are the problem, not negative answers. For f(x) = x − 10, the input 1 gives −9, which is a valid output.
- Brackets on infinity. Writing [2, ∞] is incorrect. Use [2, ∞).
- Counting a repeated input twice. In a table, the input 3 appearing in two rows with the same output is still one element of the domain. If the two rows give different outputs, the table is not a function.
- Forgetting an endpoint's dot. On a graph, an open dot and a closed dot at the same x-value lead to different domains. Check each end before writing a bracket.
Exercise
A graph starts at a closed dot at (−4, 2), passes through (0, 5), and ends at an open dot at (6, 1). Write its domain in interval notation and in set notation.
Show answer
The x-values run from −4 (included) to 6 (excluded). Interval notation: [−4, 6). Set notation: {x : −4 ≤ x < 6}.
Exercise
Find the domain of f(x) = 5 / (x + 2) and write it in interval notation.
Show answer
The denominator is zero when x = −2, so −2 is excluded. The domain is (−∞, −2) ∪ (−2, ∞).
Exercise
Let g(x) = (x² − 9) / (x − 3). A classmate simplifies it to x + 3 and says the domain is all real numbers. What is the correct domain, and why is the classmate wrong?
Show answer
The original expression is undefined at x = 3, so the domain is (−∞, 3) ∪ (3, ∞). The simplified form x + 3 is only equal to g(x) when x ≠ 3, so using it for the domain hides the excluded input.
Exercise
A function is defined by the pairs (1, 4), (2, 7), (3, 4), (5, 9). Is it a function, and what is its domain?
Show answer
Yes. No input appears with two different outputs (the repeated output 4 is allowed). The domain is {1, 2, 3, 5}.