Composition of Functions
Definition 1.4.1. Let f: X ⟶ Y and g: Y ⟶ Z be two functions. Then the function g ∘ f: X ⟶ Z given by
(g ∘ f) (x) = g(f(x))
is called the composition of the function f and g. □
g ◦ f reads as g composed with f, or as f followed by g.
Example 1.4.2. Consider the functions f : ℤ ⟶ ℤ and g: ℚ ⟶ ℚ, given by f(x) = 2x/3 ∀ x ∈ ℤ and g(x) = x2 ∀ x ∈ ℚ. Observe that g ∘ f : ℤ ⟶ ℚ is given by (g ∘ f) (x) = g(f(x)) = g(2x/3) = 4x2/9 ∀ x ∈ ℤ. But f ∘ g is not defined as for example 1/4 ∈ ℚ, g(1/4) = 1/16 ∉ ℤ and hence f(1/16) makes no sense. The reason for this is that Im(g) ⊈ D(f). ■
Example 1.4.3. Consider the functions f : ℤ ⟶ ℤ and g: ℤ ⟶ ℤ, defined by f(n) = (−1)n, n ∈ ℤ and g(n) = 2n, n ∈ ℤ. Then g ∘ f: ℤ ⟶ ℤ is given by (g ∘ f)(n) = g(f(n)) = g((−1)n) = 2(−1)n, n ∈ ℤ, i.e. (g ∘ f)(n) = 2 or −2, according as n is even or odd. Observe that, here one may define as well (f ∘ g)(n) = f(g(n)) = f(2n) = (−1)2n, n ∈ ℤ, i.e. (f ∘ g)(n) = 1, ∀n ∈ ℤ. This example shows that g ∘ f ≠ f ∘ g in general, even when both are defined, i.e. composition of functions is noncommutative. ■
Exanoke 1.4.4. Let f(x) = x2 and g(x) = sin (x). The composite function g ∘ f is
h(x) = g[f(x)] = sin(x2)
Since g is well-defined over all ℝ, also h is. The function k = f ∘ g is also well defined by the relation
k(x) = f[g(x)] = [sin(x)]2 ■
A basic fact about functional composition is that it satisfies the associative law. First let us agree that two functions f and g are to be considered equal − in symbols f = g if they have the same domain and codomain and if f(g) = g(x) for all x.
Theorem 1.4.5. Let f: X ⟶ Y, g: U ⟶ V and h: R ⟶ S be functions such tha Im(h) is contained in U and Im(g) is contained in X. Then
f ∘ (g ∘ h) = (f ∘ g) ∘ h
Proof. First observe that the various composited in the formula make sense; this is is because of the assumptions about Im(h) and Im(g). Let x be an element of X. Then, by the definition of a compositive,
f ∘ (g ∘ h) = f((g ∘ g)(x)) = f(g(h(x))
In a similar manner we find that (f ∘ h) ∘ h(x) is also equal to this element. Therefore f ∘ (g ∘ h) = (f ∘ g) ∘ h, as claimed. □
Another basic result asserts that a function is unchanged when it is composed with an identity function.
Theorem 1.4.6. If f: X ⟶ Y is any function, then f ∘ 1X = f = 1Y ∘ f.
Proof. Left as an exercise. □