Sub topic 10
Finding an inverse step by step
This chapter assumes you can use function notation, solve linear and simple nonlinear equations for a variable, and read the graphs of lines, parabolas and square roots. You should also know what a one-to-one function is. A function that fails that test has no inverse until its domain is restricted. That fix gets its own chapter later.
The idea behind the method
A function f takes an input x and produces an output y. Its inverse, written f⁻¹, takes y back to x. Finding the inverse is therefore a matter of solving the equation y = f(x) for x. The result is a formula that starts from y and ends at x.
Once you have that formula, you rename the variables. The input of any function is conventionally called x, so you swap the letters at the end.
The algorithm
- Confirm that f is one-to-one on the domain you are using.
- Write the function as y = f(x).
- Solve this equation for x in terms of y.
- Rename the variables: write the result as y = f⁻¹(x), or write f⁻¹(y) = ...
- Swap the domain and range. The domain of f⁻¹ is the range of f. The range of f⁻¹ is the domain of f.
- Verify the answer by composition. The next chapter covers this check in detail.
Some textbooks swap x and y first and then solve for y. Both orders give the same result. Solving for x first is easier to reason about, because you can see each step undoing one operation of f.
Worked example 1: a linear function
Find the inverse of f(x) = 2x + 3.
Write y = 2x + 3. Subtract 3 from both sides to get y − 3 = 2x. Divide by 2 to get x = (y − 3) / 2.
Rename the variable: f⁻¹(x) = (x − 3) / 2.
Read the steps in terms of operations. The function f first multiplies by 2 and then adds 3. The inverse subtracts 3 and then divides by 2. The inverse performs the opposite operations in the opposite order. This pattern holds for any function built as a chain of simple steps.
def f(x):
return 2 * x + 3
def f_inv(y):
return (y - 3) / 2
for x in [-2, 0, 5]:
assert f_inv(f(x)) == x
assert f(f_inv(x)) == x
print(f_inv(f(5))) # 5.0Both assertions pass. The first checks that finv undoes f, and the second checks that f undoes finv.
Worked example 2: a rational function
Find the inverse of f(x) = (x + 1) / (x − 2), for x ≠ 2.
Write y = (x + 1) / (x − 2). Multiply both sides by (x − 2):
y(x − 2) = x + 1
Expand: yx − 2y = x + 1.
The variable x now appears on both sides, so collect all x terms on one side: yx − x = 2y + 1.
Factor out x: x(y − 1) = 2y + 1.
Divide by (y − 1): x = (2y + 1) / (y − 1).
Rename: f⁻¹(x) = (2x + 1) / (x − 1), for x ≠ 1.
The restriction x ≠ 1 is not an accident. The original function can never output 1, because (x + 1) / (x − 2) = 1 would require x + 1 = x − 2, which has no solution. So the range of f is all real numbers except 1, and that becomes the domain of f⁻¹.
When the variable appears more than once, the standard move is to gather every term containing it on one side and factor it out.
Worked example 3: a root function
Find the inverse of f(x) = √(x − 1) + 2.
The domain of f is x ≥ 1. Since √(x − 1) ≥ 0, the range is y ≥ 2.
Write y = √(x − 1) + 2. Subtract 2: y − 2 = √(x − 1). Square both sides: (y − 2)² = x − 1. Add 1: x = (y − 2)² + 1.
Rename: f⁻¹(x) = (x − 2)² + 1.
This formula is a parabola, and a parabola is not one-to-one over all real numbers. The inverse is only valid for x ≥ 2, which is the range of f. Without that restriction, the formula would also accept inputs like x = 0, which f never produces. The domain and range bookkeeping in step 5 is what keeps the answer correct.
import math
def f(x):
return math.sqrt(x - 1) + 2
def f_inv(x):
return (x - 2) ** 2 + 1
print(f(10)) # 5.0
print(f_inv(5.0)) # 10.0A diagram of the process
Common errors
- Skipping the one-to-one check. Solving y = x² for x gives x = ±√y. That is two outputs for one input, so it does not define a function. The check in step 1 catches this before you start.
- Dropping the domain information. An inverse formula alone is incomplete. In example 3, the formula (x − 2)² + 1 is only correct for x ≥ 2.
- Reversing the order of operations incorrectly. If f multiplies by 2 and then adds 3, the inverse must subtract 3 first. Dividing by 2 first gives (x / 2) − 3, which is wrong.
- Forgetting to rename. If you leave the answer as x = (y − 3) / 2, a reader may not see it as a function of its own input. State the final answer as f⁻¹(x) or f⁻¹(y) in one consistent variable.
- Losing a restriction in the algebra. Multiplying both sides by an expression, as in example 2, is safe only when that expression is nonzero. The domain of the original function guarantees that here.
- Mixing up f⁻¹ with 1/f. The superscript −1 means the inverse function, not a reciprocal. The next chapters return to this.
Checking your work quickly
A fast sanity check is to pick one input, apply f, and then apply your candidate inverse. If you do not get the input back, something is wrong. This is not a proof, because one value can pass by accident, but it catches most algebra slips.
def f(x):
return (x + 1) / (x - 2)
def f_inv(x):
return (2 * x + 1) / (x - 1)
x = 5
y = f(x) # 2.0
print(y)
print(f_inv(y)) # 5.0The full verification uses both compositions, f⁻¹(f(x)) = x and f(f⁻¹(x)) = x, for all x in the relevant domains. The next chapter covers that.
Summary table
| Function | Steps of f | Inverse | Domain of inverse |
|---|---|---|---|
| f(x) = 2x + 3 | multiply by 2, add 3 | (x − 3) / 2 | all real numbers |
| f(x) = (x + 1) / (x − 2) | rational, solve with factoring | (2x + 1) / (x − 1) | x ≠ 1 |
| f(x) = √(x − 1) + 2 | subtract 1, root, add 2 | (x − 2)² + 1 | x ≥ 2 |
Exercise
Find the inverse of f(x) = 5 − 3x. State the domain of the inverse.
Show answer
Write y = 5 − 3x. Subtract 5: y − 5 = −3x. Divide by −3: x = (5 − y) / 3. So f⁻¹(x) = (5 − x) / 3. The function is linear with a nonzero slope, so its range is all real numbers, and the inverse is defined for all real x.
Exercise
Find the inverse of g(x) = (2x) / (x + 1), for x ≠ −1. State which value is excluded from the domain of the inverse.
Show answer
Write y = 2x / (x + 1). Multiply: y(x + 1) = 2x, so yx + y = 2x. Collect x terms: y = 2x − yx = x(2 − y). So x = y / (2 − y). Therefore g⁻¹(x) = x / (2 − x). The value x = 2 is excluded, because g never outputs 2: 2x / (x + 1) = 2 would require 2x = 2x + 2, which is impossible.
Exercise
Find the inverse of h(x) = x² + 4 restricted to x ≥ 0. Give its domain.
Show answer
The restricted function has range y ≥ 4. Write y = x² + 4, so x² = y − 4. Since x ≥ 0, take the positive root: x = √(y − 4). Therefore h⁻¹(x) = √(x − 4), with domain x ≥ 4.