Composition reads right to left
g ∘ f applies f first. The notation matches g(f(x)), which is why it looks backwards until you read it as substitution.
(g ∘ f)(x) = g(f(x)) — right to left. Composition preserves injectivity and surjectivity, and an inverse function exists exactly when f is a bijection.
Core ideas
Composition is how functions are built out of simpler ones, and the inverse is the question of whether the building can be undone.
g ∘ f applies f first. The notation matches g(f(x)), which is why it looks backwards until you read it as substitution.
(h ∘ g) ∘ f = h ∘ (g ∘ f) always. f ∘ g = g ∘ f almost never.
Not injective means two inputs share an output, so the inverse could not choose. Not surjective means some output has no input, so the inverse would be undefined there.
The material
The definitions, what composition preserves, and the inverse theorem.
For f : A → B and g : B → C, the composition g ∘ f : A → C is defined by (g ∘ f)(a) = g(f(a)). It requires the codomain of f to be contained in the domain of g.
Order matters twice over. g ∘ f and f ∘ g are different functions when both are defined, and often only one of them is defined at all — the types have to line up.
(h ∘ g) ∘ f = h ∘ (g ∘ f) whenever the compositions are defined.
Both sides send a to h(g(f(a))). Two functions with the same domain, the same codomain and the same value everywhere are equal.
□
If f and g are both injective, so is g ∘ f. If both are surjective, so is g ∘ f. If both are bijective, so is g ∘ f.
Injective: suppose g(f(x)) = g(f(y)). Injectivity of g gives f(x) = f(y), and injectivity of f gives x = y.
Surjective: take c ∈ C. Surjectivity of g gives b ∈ B with g(b) = c; surjectivity of f gives a ∈ A with f(a) = b. Then (g ∘ f)(a) = c.
□
The converses are weaker and worth knowing. If g ∘ f is injective then f must be injective — but g need not be. If g ∘ f is surjective then g must be surjective — but f need not be. Each is a short argument and each catches a plausible false claim.
g : B → A is an inverse of f : A → B when g ∘ f = id_A and f ∘ g = id_B. When it exists it is unique and is written f⁻¹.
f : A → B has an inverse if and only if f is a bijection.
Suppose f is a bijection. For each b ∈ B, surjectivity gives at least one a with f(a) = b and injectivity gives at most one, so exactly one. Defining f⁻¹(b) to be that a is a legitimate function, and it satisfies both identities by construction.
Conversely, suppose g is an inverse. If f(x) = f(y) then applying g gives x = y, so f is injective. And for any b, f(g(b)) = b, so g(b) is a preimage of b and f is surjective.
□
Uniqueness follows quickly: if g and h are both inverses then g = g ∘ id = g ∘ (f ∘ h) = (g ∘ f) ∘ h = id ∘ h = h. The chain uses associativity, which is why associativity was worth stating.
f : ℝ → ℝ, f(x) = 3x − 5. Set y = 3x − 5 and solve: x = (y + 5)/3, so f⁻¹(y) = (y + 5)/3. Check: f(f⁻¹(y)) = 3((y+5)/3) − 5 = y. Both directions should be checked, because solving for x proves only one of them.
(g ∘ f)⁻¹ = f⁻¹ ∘ g⁻¹ when both inverses exist — the order reverses. Undoing "socks then shoes" is "shoes off, then socks".
Interactive
Built by hand, classified by counting
Method
Check the types, then work inside out.
g ∘ f needs f's outputs to be legal inputs for g. A type mismatch is not a subtlety; the composition does not exist.
(g ∘ f)(3) is g(f(3)). Compute f(3) first. Half of all composition errors are order errors.
No bijection, no inverse. Solving y = f(x) for x and finding two solutions or none is the same discovery arrived at slowly.
f⁻¹ ∘ f = id and f ∘ f⁻¹ = id. Solving for x naturally establishes one; the other is a separate substitution.
f(x) = 2x and g(x) = x + 3, both ℝ → ℝ.
The last two lines are the order-reversal law being tested rather than asserted. (g ∘ f)⁻¹ = f⁻¹ ∘ g⁻¹, and composing the inverses in the original order gives a different function entirely.
With f(x) = 3x + 1 and g(x) = x − 4 on ℝ, compute g ∘ f and (g ∘ f)⁻¹ directly, then check the answer equals f⁻¹ ∘ g⁻¹. If the two agree you have the order right.
Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.
No recommendations yet for this lesson.