Skip to lesson content

Lesson 3 of 4

Relations and Functions · Lesson 3 of 4

Composition, Inverses and Connected Applications

“Follow functions through successive stages, reverse bijections, and apply the chapter ideas to connected problems.”

Learning Objectives

• Form compositions in the correct order and check that the stages are compatible. • Explain and verify inverse functions using both identity equations. • Connect invertibility with injectivity and surjectivity. • Prove equivalence results for intersected relations and equal-value relations. • Count finite bijections and relations by identifying forced pairs. • Test whether function addition preserves injectivity or surjectivity.

Composition and inverses

A function can be one stage of a longer process. Its output may become the input of a second function, or we may ask whether its output uniquely determines the original input. Composition describes the first situation, and inverse functions describe the second. Both depend on the domain and codomain information developed earlier.

Reading a composition from the inside outward

Imagine first converting an input into an intermediate value, then transforming that intermediate value again. The second stage must accept every value produced by the first. The notation records this order, even though the first function to act is written on the right.

Definition
Composition of functions

If f : A → B and g : B → C, their composition g ∘ f : A → C sends x to g(f(x)). Apply f first and then apply g.

Composition ruleLaTeX
The circle ∘ denotes composition. A is the original domain, B connects the stages, and C is the final codomain.

The displayed setup f : A → B and g : B → C guarantees compatibility. More generally, g ∘ f is defined on all of A whenever every output of f belongs to the domain of g. If only some outputs do, we must restrict the domain of the proposed composition. We cannot feed an output into a stage that does not accept it.

First f, then gxAf(x)Bg(f(x))Cfgg ∘ f : A → C
A composition through three sets— Follow x into f(x), then use that value as the input of g. The final output is g(f(x)).
Example — A composition from listed values

Problem
Let f : {2, 3, 4, 5} → {3, 4, 5, 9} have f(2) = 3, f(3) = 4, f(4) = f(5) = 5. Let g : {3, 4, 5, 9} → {7, 11, 15} have g(3) = g(4) = 7 and g(5) = g(9) = 11. Find g ∘ f.

  1. 1.For input 2, first use f(2) = 3, then g(3) = 7. Thus (g ∘ f)(2) = 7.
  2. 2.For input 3, f(3) = 4 and g(4) = 7. Thus (g ∘ f)(3) = 7.
  3. 3.For input 4, f(4) = 5 and g(5) = 11. For input 5, f(5) = 5 and g(5) = 11.
  4. 4.Therefore g ∘ f = {(2, 7), (3, 7), (4, 11), (5, 11)}. The composite codomain is {7, 11, 15}, while its range is {7, 11}.
Example — Order can change the answer

Problem
For f : ℝ → ℝ, f(x) = cos x, and g : ℝ → ℝ, g(x) = 3x², find both compositions and compare them.

  1. 1.To form g ∘ f, replace the input of g by f(x): g(f(x)) = 3(cos x)² = 3cos²x.
  2. 2.To form f ∘ g, replace the input of f by g(x): f(g(x)) = cos(3x²).
  3. 3.At x = 0, the first expression gives 3cos²0 = 3, while the second gives cos 0 = 1.
  4. 4.Since the functions differ at an allowed input, g ∘ f ≠ f ∘ g. Composition is not generally commutative.
Common mistake

g ∘ f is not the product gf. The expression g(f(x)) feeds one output into the other function, while g(x)f(x) multiplies two outputs from the same input. Also, “not generally commutative” does not mean the two orders can never agree; some particular functions do commute.

What it means to undo a function

To reverse a function, every required output must lead back to a unique input. A missed output would leave the reverse rule undefined, while a collision would give the reverse rule two choices. This is why both one-one and onto are needed.

Definition
Identity function

The identity I_X : X → X leaves every element unchanged: I_X(x) = x.

Definition
Inverse function

For f : X → Y, an inverse is a function g : Y → X satisfying g ∘ f = I_X and f ∘ g = I_Y. If it exists, it is denoted f⁻¹, and f is called invertible.

The two inverse checksLaTeX
The first equation restores each original input in X. The second restores each starting element of Y. Both directions, on the stated sets, are required.

An inverse does not merely undo selected outputs. It must be a function defined on the entire original codomain Y. Since a bijection gives each y exactly one preimage, we can define f⁻¹(y) to be that input. The resulting reverse rule returns every input correctly and reaches every original domain element.

Example — Why an inverse forces a bijection

Problem
Suppose f : X → Y has inverse g : Y → X. Prove that f is one-one and onto.

  1. 1.For injectivity, suppose f(x₁) = f(x₂). Apply g to both sides to get g(f(x₁)) = g(f(x₂)).
  2. 2.The identity condition g ∘ f = I_X turns this into x₁ = x₂. Thus f is one-one.
  3. 3.For surjectivity, choose arbitrary y ∈ Y and let x = g(y). Since g maps into X, x is an allowed input.
  4. 4.The identity condition f ∘ g = I_Y gives f(x) = f(g(y)) = y. Thus every y is reached and f is onto.

Conversely, if f is one-one and onto, every y has one and only one preimage x. Defining g(y) = x therefore gives a well-defined function Y → X. By construction, g(f(x)) = x and f(g(y)) = y. Hence f is invertible if and only if it is bijective. This also proves that the inverse is unique: a second inverse would have to assign the same unique preimage to each y.

Example — An inverse on a carefully chosen codomain

Problem
Let f : ℕ → Y, f(x) = 4x + 3, where Y = {4x + 3 : x ∈ ℕ}. Find and verify its inverse.

  1. 1.With ℕ = {1, 2, 3, …}, the codomain Y is {7, 11, 15, …}. Solve y = 4x + 3 for x: subtract 3 to get y − 3 = 4x, then divide by 4 to get x = (y − 3)/4.
  2. 2.Define g : Y → ℕ by g(y) = (y − 3)/4. For every y ∈ Y, its defining form y = 4n + 3 gives g(y) = n ∈ ℕ. Thus the reverse rule has the correct codomain.
  3. 3.For arbitrary x ∈ ℕ, g(f(x)) = (4x + 3 − 3)/4 = x, so g ∘ f = I_ℕ.
  4. 4.For arbitrary y ∈ Y, f(g(y)) = 4((y − 3)/4) + 3 = y − 3 + 3 = y, so f ∘ g = I_Y.
  5. 5.Both identity checks hold. Therefore f⁻¹(y) = (y − 3)/4 on Y. The choice of Y is essential; the same rule ℕ → ℕ would miss outputs and have no inverse on all of ℕ.
A bijection reverses every arrowf(x) = 4x + 312371115A finite sample of ℕ → Yf⁻¹(y) = (y − 3)/471115123The reverse sample Y → ℕ
Forward and inverse assignments— The displayed three pairs are a sample. Every element of Y has exactly one natural-number preimage.
Common mistake

f⁻¹ means the inverse function, not the reciprocal 1/f(x). For example, the inverse of f(x) = 4x + 3 is (x − 3)/4 on the appropriate set, while the reciprocal is 1/(4x + 3). Solving backward must also preserve the specified domain and codomain.

Connected applications

The remaining worked problems combine the chapter ideas in more demanding ways. We will keep the reasoning visible: membership in two relations, a shared value, or a forced pair is the starting information. From it we prove a general property or count exactly the possible objects.

Building equivalence relations from known ones

A new relation can be formed by requiring two existing conditions to hold at once, or by grouping inputs that share a function value. Both constructions can be understood through the three tests. The resulting classes make the connection between relations and functions concrete.

Example — Intersecting equivalence relations

Problem
If R₁ and R₂ are equivalence relations on A, prove that R₁ ∩ R₂ is an equivalence relation.

  1. 1.For every a ∈ A, (a, a) belongs to both R₁ and R₂, so it belongs to their intersection. This proves reflexivity.
  2. 2.If (a, b) belongs to the intersection, it belongs to both relations. Each is symmetric, so (b, a) belongs to both and therefore to the intersection.
  3. 3.If (a, b) and (b, c) belong to the intersection, both links lie in each relation. Transitivity in each gives (a, c) in both.
  4. 4.Thus (a, c) lies in R₁ ∩ R₂. All three properties hold. Membership in an intersection means both conditions must survive every proof step.
Example — Equal ratios without dividing by zero

Problem
On the set of ordered pairs of positive integers, define (x, y) R (u, v) exactly when xv = yu. Show equivalence.

  1. 1.Reflexivity follows from xy = yx, so (x, y) is related to itself.
  2. 2.If xv = yu, rewriting gives uy = vx. This is the condition for (u, v) R (x, y), proving symmetry.
  3. 3.Suppose xv = yu and ub = va. Multiply the first equality by b: xvb = yub. Replace ub by va using the second equality, obtaining xvb = yva.
  4. 4.Since v is a positive integer, it is nonzero. Cancel v to get xb = ya, the required condition for (x, y) R (a, b).
  5. 5.The relation is an equivalence relation. Each class groups pairs representing the same positive ratio, such as (1, 2), (2, 4) and (3, 6).
Example — Two descriptions of the same relation

Problem
On X = {1, 2, …, 9}, let R₁ relate x and y when x − y is divisible by 3. Let R₂ relate them when they both lie in one of {1, 4, 7}, {2, 5, 8}, {3, 6, 9}. Prove R₁ = R₂.

  1. 1.If (x, y) ∈ R₁, x and y have the same remainder on division by 3. They therefore lie together in exactly one of the three listed groups. Hence (x, y) ∈ R₂.
  2. 2.This proves R₁ ⊆ R₂.
  3. 3.Conversely, two elements of any one listed group differ by a multiple of 3. Thus (x, y) ∈ R₂ implies (x, y) ∈ R₁.
  4. 4.So R₂ ⊆ R₁ as well. The two inclusions prove equality of the relations.
Example — A relation induced by a function

Problem
For any f : X → Y, define a R b when f(a) = f(b). Show that R is an equivalence relation.

  1. 1.For every a ∈ X, f(a) = f(a), so the relation is reflexive.
  2. 2.If f(a) = f(b), equality reverses to f(b) = f(a). Thus the relation is symmetric.
  3. 3.If f(a) = f(b) and f(b) = f(c), equality gives f(a) = f(c). Thus the relation is transitive.
  4. 4.Hence R is an equivalence relation. The class [a] contains exactly the inputs that share the output f(a). For a one-one function, these classes are singletons; for x² on ℝ, [2] = {−2, 2}.

Set inclusion provides a useful contrast. On the power set P(X), the collection of all subsets of X, the relation A R B defined by A ⊆ B is reflexive and transitive. If X is nonempty, choose x ∈ X: ∅ ⊆ {x}, but {x} is not a subset of ∅. So this relation is not symmetric and is not an equivalence relation. “Is a subset of” differs from “is the same subset as”.

Counting by the structure that must be present

A count is reliable only when every permitted case is included and every forbidden case is excluded. For functions on a finite set, injectivity leads to arrangements without repetition. For relations, reflexivity, symmetry and transitivity force particular pairs, reducing the choices.

Example — Counting bijections on three elements

Problem
Find the number of one-one functions from A = {1, 2, 3} to itself.

  1. 1.There are three possible outputs for input 1.
  2. 2.After selecting that output, injectivity leaves two choices for input 2 and one for input 3.
  3. 3.The total is 3 × 2 × 1 = 3! = 6. Each assignment uses all three outputs, so each is also onto.
  4. 4.More generally, on {1, 2, …, n}, both the number of one-one self-maps and the number of onto self-maps are n!, because either property makes the function a permutation of the set.
Example — Three reflexive and transitive relations

Problem
On A = {1, 2, 3}, count the relations containing (1, 2) and (2, 3) that are reflexive and transitive but not symmetric.

  1. 1.Reflexivity forces D = {(1, 1), (2, 2), (3, 3)}. Transitivity of (1, 2) and (2, 3) forces (1, 3). The smallest allowed relation is R₀ = D ∪ {(1, 2), (2, 3), (1, 3)}.
  2. 2.R₀ is reflexive and transitive, but lacks reverse pairs, so it is not symmetric. This is the first relation.
  3. 3.Adding only (2, 1) gives a second valid relation. Every new two-link chain has its required shortcut already present.
  4. 4.Adding only (3, 2) gives a third valid relation for the same reason.
  5. 5.Adding (3, 1) creates the cycle 1 → 2 → 3 → 1; transitivity then forces both remaining reverse pairs. Adding both (2, 1) and (3, 2) also forces (3, 1). In either case the relation becomes universal and symmetric.
  6. 6.These exhaust the three optional reverse pairs. Exactly three relations satisfy all the conditions.
Example — Two equivalence relations with a required link

Problem
On A = {1, 2, 3}, count equivalence relations containing (1, 2) and (2, 1).

  1. 1.The required links put 1 and 2 in the same class. Reflexivity also forces all three diagonal pairs.
  2. 2.One possibility is the partition {{1, 2}, {3}}, giving D ∪ {(1, 2), (2, 1)}.
  3. 3.If any link joins 3 to 1 or 2, symmetry and transitivity place all three elements in one class. The relation becomes A × A.
  4. 4.The only other partition is therefore {{1, 2, 3}}. There are exactly two equivalence relations.

The partition viewpoint prevents overcounting: one equivalence relation corresponds to one partition. A required related pair forces its two entries into the same part. In contrast, a relation that is reflexive and symmetric but not transitive may have an incomplete group of links rather than a partition.

Adding functions need not preserve their properties

Function addition combines outputs from the same input, which is different from composition. A property of each summand need not survive the sum. To see why, we should look for a missed output or a newly created collision in the resulting rule.

Example — Two onto summands with a sum that is not onto

Problem
The identity I_ℕ : ℕ → ℕ is onto. Is I_ℕ + I_ℕ : ℕ → ℕ onto?

  1. 1.Every natural y is the output I_ℕ(y), so each identity summand is onto.
  2. 2.Their sum sends x to x + x = 2x.
  3. 3.Its range consists only of positive even integers. The natural number 3 would require x = 3/2, outside ℕ.
  4. 4.Thus the sum is not onto. Surjectivity of the summands does not guarantee surjectivity of their sum.
Example — Two injective summands with a collision in the sum

Problem
On [0, π/2], let f(x) = sin x and g(x) = cos x, both with codomain ℝ. Show that each is one-one but f + g is not.

  1. 1.On this interval, sin x is strictly increasing and cos x is strictly decreasing. Either behaviour means distinct inputs have distinct outputs, so both functions are one-one.
  2. 2.At x = 0, (f + g)(0) = sin 0 + cos 0 = 0 + 1 = 1.
  3. 3.At x = π/2, (f + g)(π/2) = 1 + 0 = 1.
  4. 4.The inputs 0 and π/2 are distinct but their sum outputs agree. Hence f + g is not one-one.

Working through mixed function questions

Some mixed problems introduce no new definition but demand more careful use of existing ones. A piecewise expression may need separate sign cases, and two different-looking formulas may agree on a small declared domain. We can handle both with the same insistence on allowed inputs and outputs.

Example — A bijection from ℝ to a bounded interval

Problem
Prove that f : ℝ → (−1, 1), f(x) = x/(1 + |x|), is bijective.

  1. 1.For x ≥ 0, f(x) = x/(1 + x), which lies in [0, 1). For x < 0, f(x) = x/(1 − x), which lies in (−1, 0). Thus every output lies in the declared interval.
  2. 2.If two nonnegative inputs have equal outputs, cross-multiplication gives x₁(1 + x₂) = x₂(1 + x₁), hence x₁ = x₂. For two negative inputs, x₁(1 − x₂) = x₂(1 − x₁) gives the same conclusion.
  3. 3.A negative input has a negative output, while a nonnegative input has a nonnegative output, so no collision occurs between the two cases. Therefore f is one-one.
  4. 4.For y ∈ [0, 1), solve y = x/(1 + x) to obtain x = y/(1 − y). The denominator is positive and x ≥ 0, so the correct branch applies.
  5. 5.For y ∈ (−1, 0), solve y = x/(1 − x) to obtain x = y/(1 + y). The denominator is positive and x < 0, so the correct branch applies.
  6. 6.Substitution in each branch gives f(x) = y. Every y ∈ (−1, 1) has an allowed real preimage, so f is onto and bijective.
Example — Different formulas can define equal functions

Problem
Let A = {−1, 0, 1, 2}, B = {−4, −2, 0, 2}, f(x) = x² − x, and g(x) = 2|x − 1/2| − 1, with both functions A → B. Are f and g equal?

  1. 1.At x = −1, f(−1) = 1 + 1 = 2 and g(−1) = 2(3/2) − 1 = 2.
  2. 2.At x = 0, f(0) = 0 and g(0) = 2(1/2) − 1 = 0. At x = 1, f(1) = 0 and g(1) = 2(1/2) − 1 = 0.
  3. 3.At x = 2, f(2) = 4 − 2 = 2 and g(2) = 2(3/2) − 1 = 2.
  4. 4.Their domain and codomain are the same, and their values agree at every domain element. Therefore f = g as functions A → B.
  5. 5.This does not assert equality of the formulas on all real inputs. At x = 1/2, outside A, the expressions give −1/4 and −1 respectively.
x in Af(x) = x² − xg(x) = 2|x − 1/2| − 1
−122
000
100
222

Check your understanding

Trace composition order carefully and keep both inverse checks in view. For counting questions, identify the forced structure before considering optional pairs. A single collision remains enough to disprove injectivity, even when the function is built from familiar pieces.

Quiz

Quick check

If f(x) = x + 1 and g(x) = 2x on ℝ, what is (g ∘ f)(3)?

Quick check

Which pair of equations verifies that g : Y → X is the inverse of f : X → Y?

Quick check

What is required for f : X → Y to be invertible on its whole codomain?

Quick check

If R₁ and R₂ are equivalence relations on the same set, which is guaranteed?

Quick check

How many onto functions map {1, 2, 3} to itself?

Quick check

For f : X → Y, a R b means f(a) = f(b). If f is one-one, its equivalence classes are:

Quick check

For f(x) = sin x and g(x) = cos x on [0, π/2], what disproves injectivity of f + g?

Quick check

For f(x) = x/(1 + |x|), which preimage gives output y = −1/2?

Practice Problems

Practice Problems
  1. Let f : ℝ → ℝ be f(x) = 2x − 1 and g : ℝ → ℝ be g(x) = x². Find both compositions and give a value where they differ.
  2. For f : ℝ → ℝ, f(x) = 5x − 7, derive the inverse rule and verify both compositions are identities.
  3. For f : [0, ∞) → [0, ∞), f(x) = x², verify that √x is its inverse. Explain why the same reverse rule is not an inverse for x² on ℝ → ℝ.
  4. Prove that the intersection of two equivalence relations is transitive by tracking membership in each relation separately.
  5. For f : {−2, −1, 0, 1, 2} → {0, 1, 4}, f(x) = x², list the equivalence classes for the rule f(a) = f(b).
  6. Count the onto functions from {1, 2, 3, 4} to itself and explain why the count is a factorial.
  7. On {1, 2, 3}, count reflexive and symmetric but not transitive relations containing (1, 2) and (1, 3). Explain which pair is forced by symmetry and which shortcut is missing.
  8. Prove that inclusion on P(X), for nonempty X, is reflexive and transitive but not symmetric.
  9. For f(x) = x/(1 + |x|), find the preimages of 3/4 and −3/4, checking the sign branch each time.
  10. Find a real input outside {−1, 0, 1, 2} where x² − x and 2|x − 1/2| − 1 differ. Explain why this does not contradict equality on the stated finite domain.

Key Takeaways

Key Takeaways

• In g ∘ f, apply f first and g second, after checking that the stages are compatible. • An inverse reverses the whole assignment and satisfies identities in both directions. • Invertibility is equivalent to bijectivity; inverse notation does not mean a reciprocal. • Intersections of equivalence relations and equal-function-value relations are equivalence relations. • Finite self-bijections are permutations, counted by n!; relation counts depend on forced pairs or partitions. • Adding functions need not preserve injectivity or surjectivity, and function equality is checked on the declared domain.