Sub topic 1
Quick review: functions, domain and range
Composite and inverse functions both depend on three ideas: what a function is, which inputs it accepts, and which outputs it produces. This chapter reviews those ideas so the later chapters can build on them.
Prerequisites
This chapter assumes you can already do the following:
- Read and write function notation such as f(x) = 2x + 3, and evaluate f(4).
- Solve linear equations and simple nonlinear equations (for example x² = 9 or 2x − 6 ≥ 0) for a variable.
- Recognize the graphs of lines, parabolas, and square roots.
- Read interval notation such as [1, ∞) and (−∞, 2) ∪ (2, ∞).
If any of these feel shaky, practice them first. The later chapters use them constantly.
What a function is
A function is a rule that assigns to each allowed input exactly one output. The phrase "exactly one" matters. If the same input could give two different outputs, the rule is not a function.
Three terms describe a function:
- The domain is the set of inputs the function accepts.
- The range is the set of outputs the function actually produces.
- The rule is the recipe that turns an input into an output.
In f(x) = 2x + 3, the rule is "double the input, then add 3." Any real number can be doubled and increased by 3, so the domain is all real numbers. Every real number is also an output for some input, so the range is all real numbers too.
Domain versus range
The domain describes what you may put in, and the range describes what comes out. Do not mix them up. Later chapters rely on this distinction, because an inverse function swaps the two: the range of f becomes the domain of its inverse.
Some courses also use the word codomain for the set of outputs a function is allowed to produce. The range is the part of the codomain that is actually reached. This tutorial uses "range" in the second sense, meaning only the outputs that really occur.
Finding the domain
Start by assuming the domain is all real numbers. Then remove any input that breaks the rule. At this level, only a few things can break a rule:
| Problem | Why it fails | Condition on x |
|---|---|---|
| Division by an expression | Dividing by zero is undefined | Denominator ≠ 0 |
| Even root, such as a square root | No real square root of a negative number | Expression under the root ≥ 0 |
| Logarithm (not needed in this tutorial) | Logarithm of zero or a negative is undefined | Argument > 0 |
| Polynomial | Nothing can break it | None, so the domain is all reals |
The second row is the one you will meet most often in this tutorial. The third row is listed only so the table is complete.
Worked example
Find the domain of f(x) = √(x + 4) / (x − 2).
- The square root needs x + 4 ≥ 0, so x ≥ −4.
- The denominator needs x − 2 ≠ 0, so x ≠ 2.
- Combine the two conditions. The value x = 2 lies inside [−4, ∞), so it must be removed from that interval.
The domain is [−4, 2) ∪ (2, ∞).
Always check each condition separately and then combine them. A common mistake is to stop after the first condition and forget that a second one also applies.
Finding the range
The range is usually harder to find than the domain. Three methods cover most cases:
- Use the graph. Read off which y-values the graph reaches.
- Use known shapes. A parabola that opens downward with vertex at height 4 never goes above 4.
- Solve for x. Set y = f(x), solve for x in terms of y, and see which y-values give a valid x.
Worked example
Find the range of h(x) = −x² + 4.
Because x² is never negative, −x² is never positive. The largest value of −x² is 0, reached at x = 0. So h(x) ≤ 4, and h takes every value from 4 downward. The range is (−∞, 4].
Compare this with g(x) = √(x − 1). The domain is x ≥ 1. The square root symbol means the principal (non-negative) root, so the output is never negative. The range is [0, ∞). The domain and range are different sets here, and that is typical.
Checking a domain with code
You can test whether an input is allowed by trying it and catching the error. The helper below is only a spot check. It cannot prove a domain, because it tests individual numbers rather than every real number.
import math
def f(x):
return math.sqrt(x + 4) / (x - 2)
def in_domain(func, x):
"""Return True if func(x) computes without a math error."""
try:
func(x)
return True
except (ValueError, ZeroDivisionError):
return False
for x in [-5, -4, 0, 2, 3]:
print(x, in_domain(f, x))Running this prints:
-5 False
-4 True
0 True
2 False
3 TrueThe results match the domain [−4, 2) ∪ (2, ∞) from the worked example:
- x = −5 fails because the square root receives −1, which raises a
ValueError. - x = −4 works because the square root receives 0, and the denominator −6 is not zero.
- x = 2 fails because the denominator is zero, which raises a
ZeroDivisionError.
Note that x = −4 is included in the domain. The condition is x + 4 ≥ 0, not x + 4 > 0, because the square root of 0 is a perfectly good real number.
The vertical line test
A graph represents a function if no vertical line crosses it more than once. A vertical line at x = a represents the input a. If it hits the graph twice, then a has two outputs, which breaks the "exactly one output" rule.
- The parabola y = x² passes the test. Each x gives one y.
- The sideways parabola x = y² fails the test. At x = 9, both y = 3 and y = −3 lie on the curve.
- A circle fails the test, because most vertical lines cross it twice.
The vertical line test checks whether a graph is a function at all. The next-but-one chapters introduce a different check, the horizontal line test, which asks whether a function can be undone. Keep the two tests separate in your mind. They look similar but answer different questions.
Evaluating functions carefully
Function notation means "replace x everywhere with the input." Parentheses protect the substitution. Take f(x) = x² − 3x.
- f(4) = 4² − 3(4) = 16 − 12 = 4.
- f(a + 1) = (a + 1)² − 3(a + 1) = a² + 2a + 1 − 3a − 3 = a² − a − 2.
The input can be an expression, not just a number. This skill is the foundation of composition. When you write f(g(x)), you evaluate f at the input g(x), which is just a more complicated expression.
Why these ideas matter next
Two facts from this chapter carry directly into the rest of the tutorial:
- Outputs become inputs. When one function feeds another, the outputs of the first must land inside the domain of the second. If they do not, the combination is undefined at those points.
- Domain and range trade places. An inverse function reverses the rule, so the old range becomes the new domain and the old domain becomes the new range.
Keep your domain-finding habits sharp. They will come up in nearly every chapter that follows.
Exercise
Find the domain of p(x) = √(2x − 6) / (x − 5), and find the range of q(x) = x² + 1. Write both in interval notation.
Show answer
For p, the square root needs 2x − 6 ≥ 0, so x ≥ 3. The denominator needs x ≠ 5. Since 5 lies inside [3, ∞), remove it. The domain is [3, 5) ∪ (5, ∞). For q, x² ≥ 0, so x² + 1 ≥ 1, and every value from 1 upward is reached (for example, y = 1 + t² for any t ≥ 0 gives x = t). The range is [1, ∞).
Exercise
Does the relation x² + y² = 25 define y as a function of x? Explain using the vertical line test, and say what happens if you keep only y ≥ 0.
Show answer
No. The graph is a circle of radius 5. The vertical line x = 3 crosses it at y = 4 and y = −4, so x = 3 has two outputs. If you keep only y ≥ 0, you get the upper semicircle y = √(25 − x²). Each x in [−5, 5] then has exactly one y, so this is a function with domain [−5, 5] and range [0, 5].