In short

If g: A \to B and f: B \to C, the composite f \circ g: A \to C is injective precisely when g is injective and f is injective on the range of g. The composite is surjective precisely when f is surjective. A composite can be injective even if f is not, and surjective even if g is not — the key is how the two functions interact, not their individual types alone.

Suppose your school assigns each student to a house (Agni, Vayu, Jal, Prithvi), and each house has a fixed jersey colour (red, blue, green, yellow). Student \to house \to colour gives a composite function from students to colours.

If two students are in different houses, they get different colours — the composite is injective. But what if two houses share a colour? Then students in those houses collide at the colour stage, even though they were separated at the house stage. And what if no house maps to green? Then green is unreachable — the composite is not surjective.

The question this article answers: when you chain two functions, which properties of the individual functions survive the chain, and which can break?

The setup

Throughout this article, g: A \to B and f: B \to C are functions, and the composite is f \circ g: A \to C, defined by (f \circ g)(x) = f(g(x)).

Composition chain: A maps to B via g, then B maps to C via fThree ovals labelled A, B, C from left to right. An arrow from A to B is labelled g. An arrow from B to C is labelled f. A curved arrow from A to C below is labelled f compose g. A B C g f f ∘ g
The composite $f \circ g$ sends each element of $A$ first through $g$ into $B$, then through $f$ into $C$.

When is f \circ g injective?

The main theorem

Injectivity of a composite

f \circ g is injective if and only if g is injective and f is injective on the range of g (that is, f restricted to g(A) is injective).

In practice, the cleanest sufficient condition is: if both f and g are injective, then f \circ g is injective.

Here is the proof. Suppose (f \circ g)(x_1) = (f \circ g)(x_2). This means f(g(x_1)) = f(g(x_2)). Since f is injective, g(x_1) = g(x_2). Since g is injective, x_1 = x_2. So equal outputs force equal inputs, and f \circ g is injective.

The converse direction is more nuanced. If f \circ g is injective, what can you say about f and g individually?

Claim 1: If f \circ g is injective, then g must be injective.

Proof: Suppose g(x_1) = g(x_2). Then f(g(x_1)) = f(g(x_2)), so (f \circ g)(x_1) = (f \circ g)(x_2). Since f \circ g is injective, x_1 = x_2. So g is injective.

Claim 2: If f \circ g is injective, f need not be injective (on all of B).

A concrete example makes this clear. Take A = \{1, 2\}, B = \{a, b, c\}, C = \{p, q\}. Define g(1) = a, g(2) = b. Define f(a) = p, f(b) = q, f(c) = p. The composite f \circ g sends 1 \mapsto p and 2 \mapsto q — injective. But f is not injective: f(a) = f(c) = p. The collision in f happens at c, which is outside the range of g, so the composite never encounters it.

Example where f compose g is injective but f alone is notThree ovals. A has elements 1 and 2. B has elements a, b, c. C has elements p and q. Arrows: 1 maps to a via g, 2 maps to b via g. Then a maps to p via f, b maps to q via f, c maps to p via f. The composite is injective (1 to p, 2 to q) even though f sends both a and c to p. A B C 1 2 a b c p q g (injective) f (not injective: f(a) = f(c))
The element $c$ in $B$ is outside the range of $g$. The collision $f(a) = f(c) = p$ does not affect the composite, because $g$ never sends anything to $c$. So $f \circ g$ is injective even though $f$ is not.

Summary for injectivity

What you know What you can conclude
g injective and f injective f \circ g injective
f \circ g injective g is injective (but f might not be)
g not injective f \circ g is not injective, no matter what f is

The last row follows because if g(x_1) = g(x_2) for some x_1 \neq x_2, then f(g(x_1)) = f(g(x_2)), so the composite has a collision too. A non-injective g poisons the composite — the collision at stage one carries through.

When is f \circ g surjective?

The main theorem

Surjectivity of a composite

f \circ g is surjective if and only if f is surjective and g hits enough of B so that f, restricted to g(A), still covers all of C. The cleanest sufficient condition: if both f and g are surjective, then f \circ g is surjective.

Proof: Take any c \in C. Since f is surjective, there exists b \in B with f(b) = c. Since g is surjective, there exists a \in A with g(a) = b. Then (f \circ g)(a) = f(g(a)) = f(b) = c. So every element of C is reached by the composite.

Now the converse questions.

Claim 3: If f \circ g is surjective, then f must be surjective.

Proof: Take any c \in C. Since f \circ g is surjective, there exists a \in A with f(g(a)) = c. Set b = g(a) \in B. Then f(b) = c. So every c \in C has a preimage under f.

Claim 4: If f \circ g is surjective, g need not be surjective.

Take A = \{1, 2, 3\}, B = \{a, b, c\}, C = \{p, q\}. Define g(1) = a, g(2) = a, g(3) = b. The range of g is \{a, b\} — missing c, so g is not surjective. Define f(a) = p, f(b) = q, f(c) = p. The composite sends 1 \mapsto p, 2 \mapsto p, 3 \mapsto q. Every element of C = \{p, q\} is hit — the composite is surjective even though g is not.

Example where f compose g is surjective but g alone is notThree ovals. A has 1, 2, 3. B has a, b, c. C has p, q. Arrows: 1 and 2 both map to a, 3 maps to b, so g misses c. Then a maps to p, b maps to q, c maps to p. The composite covers all of C even though g does not cover all of B. A B C 1 2 3 a b c p q g (not surjective: c missed) f (surjective onto C)
The function $g$ misses $c$, so it is not surjective. But $f$ maps $\{a, b\}$ onto all of $C$, so the composite $f \circ g$ still covers $C$. A surjective $f$ can compensate for a non-surjective $g$.

Summary for surjectivity

What you know What you can conclude
f surjective and g surjective f \circ g surjective
f \circ g surjective f is surjective (but g might not be)
f not surjective f \circ g is not surjective, no matter what g is

The last row holds because if some c \in C has no preimage under f, then certainly no element of A can reach c through f \circ g, since the composite must pass through f.

The full picture

Combining both results:

If both f and g are bijective, then f \circ g is bijective. (Injective + surjective gives bijective on each side; both properties transfer.)

If f \circ g is bijective, then g is injective and f is surjective. (From Claims 1 and 3 above. But g need not be surjective and f need not be injective.)

Summary diagram showing which properties transfer to and from the compositeTwo columns. Left column labelled 'if both f and g are...' shows arrows to the composite property. Right column labelled 'if f compose g is...' shows arrows back to f and g properties. Injective: g must be injective. Surjective: f must be surjective. both f, g have property f ∘ g has property f, g injective → f ∘ g injective f, g surjective → f ∘ g surjective f, g bijective → f ∘ g bijective f ∘ g injective → g injective f ∘ g surjective → f surjective f ∘ g bijective → g inj, f surj forward direction reverse direction
The forward direction (both components have a property implies the composite has it) is clean. The reverse direction (composite has a property implies something about the components) is asymmetric: injectivity traces back to $g$, surjectivity traces back to $f$.

The asymmetry makes sense if you think about the pipeline. Injectivity is about avoiding collisions. The first function g is where collisions can originate — if g merges two inputs, no amount of care from f can separate them again. Surjectivity is about covering the target. The last function f is the gatekeeper — if f cannot reach some element of C, no choice of g can fix that.

Two worked examples

Example 1: Algebraic functions on $\mathbb{R}$

Let g: \mathbb{R} \to \mathbb{R} be g(x) = 2x + 1 and f: \mathbb{R} \to \mathbb{R} be f(x) = x^2.

Step 1. Find the composite.

(f \circ g)(x) = f(g(x)) = f(2x + 1) = (2x + 1)^2

Why: apply g first, then feed the result into f. The composite is a quadratic.

Step 2. Is g injective? Suppose g(x_1) = g(x_2): 2x_1 + 1 = 2x_2 + 1, so x_1 = x_2. Yes, g is injective.

Why: a linear function with non-zero slope is always injective.

Step 3. Is f injective? f(1) = f(-1) = 1. No — f is not injective.

Why: squaring loses the sign, creating collisions between positive and negative inputs.

Step 4. Is f \circ g injective? (2x_1 + 1)^2 = (2x_2 + 1)^2 implies 2x_1 + 1 = \pm(2x_2 + 1). Taking x_1 = 0 gives f \circ g(0) = 1. Taking x_2 = -1 gives f \circ g(-1) = (-1)^2 = 1. Two distinct inputs, same output. So the composite is not injective.

Why: even though g is injective, f creates a collision between g(0) = 1 and g(-1) = -1, since f(1) = f(-1). The collision in f occurs within the range of g, so it survives into the composite.

Step 5. Is f \circ g surjective? The range of (2x+1)^2 is [0, \infty), not all of \mathbb{R}. For example, -3 is never an output. So the composite is not surjective. Since f is not surjective (f(x) = x^2 has range [0, \infty)), this aligns with our theorem: a non-surjective f means the composite cannot be surjective.

Result: f \circ g is neither injective nor surjective (many-one into).

Graph of (2x+1) squared showing the composite is many-one intoAn upward-opening parabola with vertex at (negative one half, 0). A horizontal dashed line at y equals 1 hits the parabola at x equals 0 and x equals negative 1, showing two inputs with the same output. x y −1 1 1 2 x = 0 x = −1 vertex (−½, 0) (2x + 1)²
The composite $(2x+1)^2$ is a parabola opening upward with vertex at $(-\tfrac{1}{2}, 0)$. The dashed line at $y = 1$ hits the curve at $x = 0$ and $x = -1$ — a collision. The curve never goes below $y = 0$ — not surjective onto $\mathbb{R}$.

The graph confirms both failures: the horizontal line at y = 1 hits two points (not injective), and no part of the curve dips below the x-axis (not surjective onto \mathbb{R}).

Example 2: Finite sets

Let A = \{1, 2, 3\}, B = \{a, b, c\}, C = \{p, q, r\}. Define:

g(1) = a, \quad g(2) = b, \quad g(3) = c
f(a) = p, \quad f(b) = q, \quad f(c) = r

Step 1. Compute the composite.

(f \circ g)(1) = p, \quad (f \circ g)(2) = q, \quad (f \circ g)(3) = r

Why: trace each element through both stages. 1 \to a \to p, 2 \to b \to q, 3 \to c \to r.

Step 2. Check injectivity of g. All three outputs a, b, c are distinct. g is injective.

Why: no element of B appears twice in the output list.

Step 3. Check injectivity of f. All three outputs p, q, r are distinct. f is injective.

Step 4. Check injectivity of f \circ g. The outputs p, q, r are all distinct. f \circ g is injective. This confirms the theorem: both injective implies composite injective.

Step 5. Check surjectivity. g hits \{a, b, c\} = B — surjective. f hits \{p, q, r\} = C — surjective. And f \circ g hits \{p, q, r\} = C — surjective.

Result: Both f and g are bijective, so f \circ g is bijective. The composite is a perfect one-to-one pairing between A and C.

Arrow diagram showing composition of two bijective functions gives a bijective compositeThree ovals with three elements each. A has 1, 2, 3. B has a, b, c. C has p, q, r. Arrows from g: 1 to a, 2 to b, 3 to c. Arrows from f: a to p, b to q, c to r. The composite arrows 1 to p, 2 to q, 3 to r form a perfect pairing. A B C 1 2 3 a b c p q r g (bijective) f (bijective)
Both $g$ and $f$ are bijections. The composite $f \circ g$ sends $1 \to p$, $2 \to q$, $3 \to r$ — also a bijection. Each element of $C$ is hit exactly once.

Now modify f to f(a) = p, f(b) = p, f(c) = r. The composite becomes (f \circ g)(1) = p, (f \circ g)(2) = p, (f \circ g)(3) = r — not injective (1 and 2 collide at p) and not surjective (q is never reached). Breaking f's injectivity created a collision; breaking f's surjectivity created a gap. Both failures propagate to the composite.

Common confusions

Going deeper

If the forward and reverse implications above are comfortable, and you can construct counterexamples for the false converses, you are ready for the next chapter on inverses. The rest of this section collects sharper statements.

Left-cancellative and right-cancellative

A function g: A \to B is called left-cancellative if f_1 \circ g = f_2 \circ g implies f_1 = f_2 for all functions f_1, f_2: B \to C. This holds if and only if g is injective. Intuitively: an injective g does not lose information, so you can tell f_1 and f_2 apart by their behaviour on the range of g.

A function f: B \to C is called right-cancellative if f \circ g_1 = f \circ g_2 implies g_1 = g_2 for all functions g_1, g_2: A \to B. This holds if and only if f is surjective... no, that is the wrong direction. Right-cancellative requires f to be injective. Left-cancellative for g requires g to be surjective when g appears on the right.

The precise statements: g is injective if and only if it is left-cancellative. f is surjective if and only if it is right-cancellative.

A counting perspective

For finite sets with |A| = m, |B| = n, |C| = k:

Interactive: building a composite

Pick arrow mappings for g and f in the diagram below. The composite arrows update automatically. Watch how collisions in g propagate, and how gaps in f's coverage create gaps in the composite.

Interactive composite function builderThree columns of dots representing sets A, B, C. Drag arrows from A to B (defining g) and from B to C (defining f). The resulting composite arrows from A to C are shown automatically, with labels indicating whether the composite is injective, surjective, both, or neither. A B C 1 2 3 a b c p q r drag arrows to define g and f
Build your own composite. Define $g$ by connecting dots from $A$ to $B$, and $f$ by connecting dots from $B$ to $C$. The composite arrows and classification update as you draw.

Where this leads next

You now know exactly when a composite inherits injectivity and surjectivity from its components — and what you can deduce about the components when the composite has these properties.