Lesson 2: Function Composition and Inverses
🎧 Listen to this lesson
A composite function feeds the output of one function into another: (f ∘ g)(x) = f(g(x)), read "f of g of x" — g acts first. An inverse function runs a function backwards, swapping inputs and outputs. Together they answer two of the most practical questions in mathematics: "what happens when processes are chained?" and "can this process be undone, and how?" This lesson builds both ideas algebraically, graphically and numerically.
Composition: order is everything
To form (f ∘ g)(x), substitute the entire formula of g into f. Composition is not commutative: (f ∘ g)(x) and (g ∘ f)(x) usually differ.
Worked Example 1 — both orders, three views. Let f(x) = 2x − 1 and g(x) = x^2 + 3.
(f ∘ g)(x) = f(x^2 + 3) = 2(x^2 + 3) − 1 = 2x^2 + 5
(g ∘ f)(x) = g(2x − 1) = (2x − 1)^2 + 3 = 4x^2 − 4x + 4
| x | (f ∘ g)(x) = 2x^2 + 5 | (g ∘ f)(x) = 4x^2 − 4x + 4 |
|---|---|---|
| −1 | 7 | 12 |
| 0 | 5 | 4 |
| 1 | 7 | 4 |
| 2 | 13 | 12 |
The table confirms the algebra: different formulas, different values. Graphically, (f ∘ g)(x) is a parabola with vertex (0, 5); (g ∘ f)(x) is a parabola with vertex where 4x^2 − 4x + 4 is minimised, at x = 1/2, value 3. A useful habit: evaluate a composite at one number by working from the inside out — (f ∘ g)(2) = f(g(2)) = f(7) = 13 ✓ matches the table.
The domain of a composite
An input must survive both stages: it must be legal for g, and its output g(x) must be legal for f.
Worked Example 2 — domain restrictions in a composite. Let f(x) = √x and g(x) = x − 4. Then (f ∘ g)(x) = √(x − 4), which needs x − 4 ≥ 0, so the domain is x ≥ 4. Reverse the order: (g ∘ f)(x) = √x − 4, defined for x ≥ 0. Same two functions, different domains — the order decides which restriction bites first. When you state a composite, the domain is part of the answer, not an afterthought.
Inverse functions
A function f has an inverse f⁻¹ exactly when f is one-to-one: every output comes from exactly one input, equivalently the graph passes the horizontal line test. The inverse swaps the roles of x and y, so the graph of f⁻¹ is the reflection of the graph of f in the line y = x, the domain of f⁻¹ is the range of f, and f⁻¹(f(x)) = x for every x in the domain. To find an inverse formula: write y = f(x), swap x and y, solve for y.
Worked Example 3 — inverting a rational function. Find the inverse of f(x) = (2x + 5)/(x + 3), x ≠ −3.
y = (2x + 5)/(x + 3)
Swap x and y: x = (2y + 5)/(y + 3)
Multiply: x(y + 3) = 2y + 5 → xy + 3x = 2y + 5
Collect y: xy − 2y = 5 − 3x → y(x − 2) = 5 − 3x
So: f⁻¹(x) = (5 − 3x)/(x − 2), x ≠ 2
Numerical check. f(1) = 7/4 = 1.75. Then f⁻¹(1.75) = (5 − 3(1.75))/(1.75 − 2) = (−0.25)/(−0.25) = 1 ✓ — the inverse returns the original input. Notice also that f never outputs 2 (its horizontal asymptote) and f⁻¹ excludes 2 from its domain: the range of f and the domain of f⁻¹ match, as promised.
Restricting a domain to create an inverse. f(x) = x^2 fails the horizontal line test, but on the restricted domain x ≥ 0 it is one-to-one, with inverse f⁻¹(x) = √x. This is the same partnership you met between squaring and square roots in Lesson 10: many "inverse pairs" in mathematics only exist after an honest domain restriction.
Modelling: chained processes and working backwards
A clothing shop applies two operations to a wholesale price p: first a 25% markup, M(p) = 1.25p, then a $10 promotional discount, D(p) = p − 10. The shelf price is the composite (D ∘ M)(p) = 1.25p − 10. Reversing the order gives (M ∘ D)(p) = 1.25(p − 10) = 1.25p − 12.50 — a different price, $2.50 cheaper for the customer, because the discount is also marked up in the second version. Composition order is a business decision, not a notational quirk.
Inverses answer "work backwards" questions. A taxi firm charges C(d) = 3.50 + 2.25d dollars for a ride of d miles. The inverse is d = (C − 3.50)/2.25. A passenger charged $25.75 travelled d = 22.25/2.25 ≈ 9.89 miles. Every "solve for the input" task — find the time from the amount of decay, the price from the revenue — is an inverse function in work clothes.
Common mistakes
- Composing in the wrong order. (f ∘ g)(3) is f(g(3)), not f(3)·g(3) and not g(f(3)). Start from the inside.
- Confusing the inverse with the reciprocal. For f(x) = 2x, the inverse is x/2; the reciprocal is 1/(2x). They agree nowhere except by accident.
- Forgetting to swap the domain. If f has domain x ≥ 0, then f⁻¹ has range y ≥ 0 — an inverse stated without its domain is half an answer.
- Claiming every function has an inverse. x^2, |x| and sin x on their full domains do not; a horizontal line meets their graphs twice.
- Checking an inverse by computing (f ∘ f⁻¹)(x) incorrectly. With messy fractions, verify numerically at one value, as in Worked Example 3 — a 20-second check that catches most algebra slips.
Exam Experience
1. If f(x) = x^2 − 2 and g(x) = 3x + 1, then (f ∘ g)(2) equals
- (A) 47
- (B) 7
- (C) 14
- (D) 49
Answer: (A). Work inside out: g(2) = 7, then f(7) = 49 − 2 = 47. Choice (B) is the reversed composite (g ∘ f)(2) = g(f(2)) = g(2) = 7; (C) is the product f(2)·g(2) = 2·7, confusing composition with multiplication; (D) forgets the −2 in f.
2. The inverse of f(x) = 5x − 3 is
- (A) (x − 3)/5
- (B) (x + 3)/5
- (C) 1/(5x − 3)
- (D) 3 − 5x
Answer: (B). y = 5x − 3 → swap → x = 5y − 3 → y = (x + 3)/5. Check: f(2) = 7 and (7 + 3)/5 = 2 ✓. Choice (C) is the reciprocal trap.
3. Let f(x) = √x and g(x) = x^2 − 9. The domain of (f ∘ g)(x) is
- (A) all real numbers
- (B) x ≥ 0
- (C) x ≤ −3 or x ≥ 3
- (D) x ≥ 3 only
Answer: (C). (f ∘ g)(x) = √(x^2 − 9) requires x^2 ≥ 9, i.e. |x| ≥ 3 — both branches, not just the positive one (D).
Constructed response. A gym charges a joining fee plus a monthly rate. The total cost after t months is C(t) = 40 + 25t dollars. (a) Find C⁻¹(t) and explain what it computes. (b) Maya has paid $315 in total. For how many months has she been a member? (c) A rival gym charges R(t) = 100 + 18t. Find the number of months at which the two gyms have cost the same in total, and state which gym is cheaper for a two-year membership.
Scoring guide. (a) 2 points: 1 for swapping and solving correctly, t = (C − 40)/25, i.e. C⁻¹(C) = (C − 40)/25; 1 for the interpretation: it gives the number of months of membership corresponding to a total amount paid. (b) 1 point: (315 − 40)/25 = 275/25 = 11 months. (c) 3 points: 1 for setting 40 + 25t = 100 + 18t; 1 for solving 7t = 60, t ≈ 8.57 months; 1 for the comparison with a conclusion: at t = 24, C = $640 and R = $532, so the rival is cheaper over two years.
Going deeper: three-stage chains and self-inverse functions
Compositions chain beyond two functions: (f ∘ g ∘ h)(x) = f(g(h(x))), evaluated from the innermost outward. Let f(x) = x + 2, g(x) = 3x, h(x) = x^2. Then (f ∘ g ∘ h)(2): h(2) = 4, g(4) = 12, f(12) = 14. Pipelines in computing are literally this: parse, then transform, then format — and a bug in any stage propagates through all later ones, which is why each stage is tested separately (Lesson 7 of the programming courses makes the same point about code).
Some functions are their own inverses: f(f(x)) = x. The reciprocal f(x) = 1/x is one; another is f(x) = (x + 1)/(x − 1) for x ≠ 1 — verify: f(f(x)) substitutes (x + 1)/(x − 1) into itself and simplifies back to x (the algebra is worth doing once by hand; the numerator and denominator each collapse by a factor of (x − 1)... precisely, f(f(x)) = ((x+1)/(x−1) + 1)/((x+1)/(x−1) − 1) = ((2x)/(x−1))/((2)/(x−1)) = x ✓). Graphically, a self-inverse function's graph is symmetric under reflection in y = x as its own mirror image — the graph is unchanged by the swap. Möbius transformations in complex analysis generalise this family.
One more domain refinement: the inverse of f(x) = √(x − 1) + 2 (domain x ≥ 1, range y ≥ 2) is found by swapping: x = √(y − 1) + 2 → √(y − 1) = x − 2 → y = (x − 2)^2 + 1, with domain x ≥ 2 inherited from f's range. Notice the inverse is a parabola piece — the right half of y = (x − 2)^2 + 1 — because a full parabola would not be one-to-one. Whenever an inverse involves a square, a restriction is silently riding along; state it or lose the mark.
🎬 Watch & Learn
Free video lessons on “Function Composition and Inverses” — pick a result below: