Sub topic 1
Quick review: functions, domain and range
This chapter assumes you can evaluate a function such as f(x) = 2x + 3, solve a linear or simple quadratic equation, and read the graph of a line or parabola.
Prerequisites
You should know the following before reading:
- Function notation, where f(x) is the output of f for input x.
- The domain of a function is the set of inputs it accepts. The range is the set of outputs it produces.
- Solving simple equations for a variable.
Composing functions: feeding one output into another
The composition of f and g, written (f∘g)(x), means f(g(x)). Compute g first, then feed that result into f.
def f(x):
return 2 * x + 3
def g(x):
return x ** 2
def compose(outer, inner):
return lambda x: outer(inner(x))
f_after_g = compose(f, g) # (f∘g)(x) = 2x^2 + 3
print(f_after_g(4)) # g(4) = 16, then f(16) = 35Why the order of composition matters
Composition is not commutative. In general, (f∘g)(x) and (g∘f)(x) give different results. Using the same f and g:
| Expression | Meaning | Value at x = 4 |
|---|---|---|
| (f∘g)(4) | f(g(4)) = f(16) | 35 |
| (g∘f)(4) | g(f(4)) = g(11) | 121 |
Finding the domain of a composite function
The domain of (f∘g) contains every x that satisfies two conditions:
- x is in the domain of g.
- g(x) is in the domain of f.
For example, let f(x) = √x and g(x) = x − 4. Then (f∘g)(x) = √(x − 4). The input must satisfy x − 4 ≥ 0, so the domain is x ≥ 4.
Breaking a function into a chain of simpler ones
Decomposition means writing a function as a composition of simpler functions. Consider h(x) = √(x² + 1). Let g(x) = x² + 1 and f(x) = √x. Then h = f∘g.
> Tip: Look at the outermost operation first. It usually names the outer function.
Exercise
Let f(x) = 2x + 3 and g(x) = x². Find (g∘f)(4) and state the domain of (f∘g)(x).
Show answer
(g∘f)(4) = g(f(4)) = g(11) = 121. Since f and g are polynomials, the domain of (f∘g)(x) is all real numbers.