Sub topic 14
The inverse of a composite: undo in reverse order
This chapter assumes you can compose two functions, find the inverse of a one-to-one function algebraically, and check an inverse by confirming that both compositions return x. You should also be comfortable with the identity function and with associativity of composition.
The idea: socks and shoes
You put on socks, then shoes. To undo that, you take off the shoes first, then the socks. Each step is undone by its own inverse, and the steps are undone in the opposite order.
A composite function works the same way. If h(x) = f(g(x)), then g acts first and f acts second. To recover x from h(x), you undo f first and then undo g.
The rule
If f and g are both one-to-one and the composite f∘g is defined, then:
(f∘g)⁻¹ = g⁻¹∘f⁻¹
The function that acted last is undone first.
Why it works
Recall that an inverse is defined by composing to the identity function, written id. The check is to compose g⁻¹∘f⁻¹ with f∘g and see whether you get id.
(g⁻¹∘f⁻¹)∘(f∘g) = g⁻¹∘(f⁻¹∘f)∘g = g⁻¹∘id∘g = g⁻¹∘g = id
The first equality regroups the chain, which is what associativity allows. The inner pair f⁻¹∘f collapses to the identity. That leaves g⁻¹∘g, which collapses too.
Composing in the other order gives (f∘g)∘(g⁻¹∘f⁻¹) = f∘(g∘g⁻¹)∘f⁻¹ = f∘f⁻¹ = id. Both compositions return the input, so g⁻¹∘f⁻¹ is the inverse of f∘g.
Only the nested order g⁻¹ inside f⁻¹ makes the middle terms meet and cancel. In the other order, f⁻¹∘g⁻¹∘f∘g, the g⁻¹ sits next to f, and nothing cancels.
Worked example
Let f(x) = 2x + 3 and g(x) = x³. Then h(x) = f(g(x)) = 2x³ + 3.
Method 1: solve for the inverse directly.
- Write y = 2x³ + 3.
- Subtract 3: y − 3 = 2x³.
- Divide by 2: (y − 3)/2 = x³.
- Take the real cube root: x = ∛((y − 3)/2).
So h⁻¹(y) = ∛((y − 3)/2).
Method 2: use the rule.
- f⁻¹(y) = (y − 3)/2
- g⁻¹(y) = ∛y
- h⁻¹(y) = g⁻¹(f⁻¹(y)) = ∛((y − 3)/2)
Both methods give the same function. The rule's advantage is that you never solve one large equation. You invert each simple piece and chain the results.
The code below checks the rule numerically. It also shows what happens if you use the wrong order.
import math
def f(x):
return 2 * x + 3
def g(x):
return x ** 3
def f_inv(y):
return (y - 3) / 2
def g_inv(y):
# Real cube root that also works for negative inputs.
return math.copysign(abs(y) ** (1 / 3), y)
def h(x):
return f(g(x))
def h_inv(y):
return g_inv(f_inv(y)) # undo f first, then g
for x in [-2, -0.5, 0, 1, 2, 5]:
assert math.isclose(h_inv(h(x)), x, abs_tol=1e-9)
assert math.isclose(h(h_inv(x)), x, abs_tol=1e-9)
def wrong_inv(y):
return f_inv(g_inv(y)) # wrong order
print(h(2)) # 19
print(h_inv(19)) # 2.0
print(round(wrong_inv(19), 4)) # -0.1658, not 2Python's ** with a fractional exponent returns a complex number for a negative base. The copysign helper avoids that by taking the cube root of the absolute value and restoring the sign.
Peeling a function layer by layer
For a longer chain, list the operations in the order they happen, then reverse the list and invert each step. Take h(x) = 2(x − 1)³ + 5.
| Forward step | Operation on the running value | Undo step (apply in this order) |
|---|---|---|
| 1 | subtract 1 | 4. add 1 |
| 2 | cube | 3. take the cube root |
| 3 | multiply by 2 | 2. divide by 2 |
| 4 | add 5 | 1. subtract 5 |
Reading the right column from 1 to 4 gives h⁻¹(y) = ∛((y − 5)/2) + 1. As a check, h(2) = 2(1)³ + 5 = 7. Then h⁻¹(7) = ∛(2/2) + 1 = 1 + 1 = 2.
This is the rule applied to four functions at once. Associativity lets you extend it to any length:
(f∘g∘k)⁻¹ = k⁻¹∘g⁻¹∘f⁻¹
Domain and range of the inverse composite
The domain of (f∘g)⁻¹ is the range of f∘g. The range of (f∘g)⁻¹ is the domain of f∘g. Ignoring this is a common source of wrong answers, because a formula can look valid on inputs where the original function never produces an output.
Take g(x) = √x with domain x ≥ 0, and f(x) = 1/(x + 1). Then h(x) = 1/(√x + 1).
- The domain of h is x ≥ 0.
- At x = 0, h = 1. As x grows, h shrinks toward 0 without reaching it. The range is 0 < y ≤ 1.
- f⁻¹(y) = 1/y − 1.
- g⁻¹(y) = y², which is valid only for y ≥ 0, because √x never outputs a negative number.
The inverse is h⁻¹(y) = (1/y − 1)², but only for 0 < y ≤ 1. Check y = 1/2: 1/y − 1 = 1, squared is 1, and h(1) = 1/(1 + 1) = 1/2. ✓
When a piece is not one-to-one
The rule requires each piece to be invertible. If g(x) = x² on all real numbers, it fails the horizontal line test, and g⁻¹ does not exist. You can still invert a composite that contains g if you restrict g's domain first (a technique covered earlier in this tutorial). The domain restriction carries through to the composite.
For example, h(x) = (x − 1)² + 4 on x ≥ 1 is the composite of "subtract 1" (call it k), then "square" restricted to inputs ≥ 0, then "add 4". The restriction x ≥ 1 ensures that x − 1 ≥ 0, so the squaring step sees only non-negative inputs. Undoing in reverse order gives h⁻¹(y) = √(y − 4) + 1, with domain y ≥ 4.
If the restriction were x ≤ 1, the square-root step would need a minus sign: h⁻¹(y) = 1 − √(y − 4). The choice of branch is made at the squaring step, and it determines the range of the inverse.
Common mistakes
- Keeping the original order. Writing (f∘g)⁻¹ = f⁻¹∘g⁻¹ is the main error. The two orders agree only in special cases where the functions happen to commute, such as f(x) = x + 1 and g(x) = x + 2.
- Inverting only part of the chain. In h(x) = 2x³ + 3, if you invert the cube and forget the "add 3" and "multiply by 2", the result is not an inverse. Count the operations in the forward direction and make sure each one has a partner.
- Forgetting that the middle must match. To compose g⁻¹∘f⁻¹, the output of f⁻¹ must lie in the domain of g⁻¹. This holds automatically when f∘g is defined and both pieces are invertible, but check it when restricting domains by hand.
- Confusing the inverse with the reciprocal. (f∘g)⁻¹ means the inverse function. It does not mean 1/(f(g(x))). The next chapter covers this notation issue in detail.
Quick checklist
- Confirm that f and g are both one-to-one on the relevant domains.
- Find f⁻¹ and g⁻¹ separately.
- Compose them in reverse: g⁻¹ after f⁻¹.
- State the domain of the result as the range of f∘g.
- Verify with (f∘g)⁻¹(f(g(x))) = x for a few values, including a negative one if the domain allows it.
Exercise
Let f(x) = 3x − 4 and g(x) = x³ + 1. Find (f∘g)⁻¹(y) in two ways: by solving y = f(g(x)) directly, and by composing g⁻¹ with f⁻¹. Do the results agree?
Show answer
First, f(g(x)) = 3(x³ + 1) − 4 = 3x³ − 1. Solve y = 3x³ − 1: x³ = (y + 1)/3, so x = ∛((y + 1)/3). Second, f⁻¹(y) = (y + 4)/3 and g⁻¹(y) = ∛(y − 1). Then g⁻¹(f⁻¹(y)) = ∛((y + 4)/3 − 1) = ∛((y + 1)/3). The results agree.
Exercise
Let f(x) = x + 1 and g(x) = 2x. Evaluate (f∘g)⁻¹(5), g⁻¹(f⁻¹(5)), and f⁻¹(g⁻¹(5)). Which two match, and why?
Show answer
f∘g(x) = 2x + 1, so its inverse is (y − 1)/2, and (f∘g)⁻¹(5) = 2. Also f⁻¹(5) = 4 and g⁻¹(4) = 2, so g⁻¹(f⁻¹(5)) = 2. In the other order, g⁻¹(5) = 2.5 and f⁻¹(2.5) = 1.5. The first two match because the rule says (f∘g)⁻¹ = g⁻¹∘f⁻¹. The wrong order gives 1.5 because f and g do not commute.
Exercise
Let h(x) = 1/(√x + 1) with domain x ≥ 0. Give h⁻¹(y) and its domain.
Show answer
Undo the steps in reverse: the last step is the reciprocal, so first compute 1/y; then subtract 1; then square. So h⁻¹(y) = (1/y − 1)². The range of h is 0 < y ≤ 1, so the domain of h⁻¹ is 0 < y ≤ 1.