Skip to content

Function composition ​

Introduction ​

The composition of two functions f and g is a new function that is obtained by applying f to the output of g. The composition of f and g is denoted by f∘g and is defined by the formula

(f∘g)(x)=f(g(x)).

In other words, the composition of f and g is the function that first applies g to its input and then applies f to the result.

Order of composition ​

The composition of functions is not commutative, i.e., in general, f∘g≠g∘f. In other words, the order in which functions are composed matters.

Domains and ranges of composed functions ​

The domain of a composite function, such as f∘g, is dependent on the domain of g and the domain of f. The domain of f∘g is important because it tells us when we can apply a composite function and when we cannot.

The domain of a composite function f(g(x)) is the set of those inputs x in the domain of g for which g(x) is in the domain of f.

Details

Let us assume we know the domains of the functions f and g separately. We can write the composite function f∘g for an input x as f(g(x)). Using the picture below, we can see that x must be a member of the domain of g in order for the expression to be meaningful, because otherwise we cannot complete the inner function evaluation. However, we also see that g(x) must be a member of the domain of f, otherwise the second function evaluation in f(g(x)) cannot be completed, and the expression is still undefined. Thus the domain of f∘g consists of only those inputs in the domain of g that produce outputs from g belonging to the domain of f. Note that the domain of f composed with g is the set of all x such that x is in the domain of g and g(x) is in the domain of f.

Determining the domain of a composite function ​

To find the domain of a composite function, f∘g, you can follow these three steps:

  1. Find the domain of g.
  2. Find the domain of f.
  3. Find those inputs x in the domain of g for which g(x) is in the domain of f. That is, exclude those inputs x from the domain of g for which g(x) is not in the domain of f. The resulting set is the domain of f∘g.

Example 1 ​

Given functions

f(x)=x+1:(x≥−1)g(x)=x2−3x+1:(x∈R)

find f∘g, g∘f, and their domains.

Determining for f∘g ​

First, calculate the domain of f∘g:

Df∘g={ x∈Dg | g(x)∈Df }=={ x∈R | x2−3x+1≥−1 }=={ x∈R | x2−3x+2≥0 }=={ x∈R | (x−1)(x−2)≥0 }=={ x∈R | x∈(−∞;1]∪[2;∞) }==(−∞;1]∪[2;∞)

Since the domain of f∘g is not an empty set (Df∘g≠∅), then f∘g exists (∃f∘g).

Calculate f∘g:

(f∘g)(x)=f(g(x))=f(x2−3x+1)=x2−3x+1+1=x2−3x+2

Therefore

f∘g=x2−3x+2:(x∈(−∞;1]∪[2;∞))

Determining for g∘f ​

First, calculate the domain of g∘f:

Dg∘f={ x∈Df | f(x)∈Dg }=={ x∈[−1;∞) | x+1∈R }==[−1;∞)

Since the domain of g∘f is not an empty set (Dg∘f≠∅), then g∘f exists (∃g∘f).

Calculate g∘f:

(g∘f)(x)=g(f(x))=g(x+1)=(x+1)2−3x+1+1==x+1−3x+1+1=x−3x+1+2

Therefore

g∘f=x−3x+1+2:(x∈[−1;∞))

Example 2 ​

Given functions

f(x)=1x2−4:(x∈R∖{±2})g(x)=x−1:(x≥1)

find f∘g, g∘f, and their domains.

Determining for f∘g ​

First, calculate the domain of f∘g:

Df∘g={ x∈Dg | g(x)∈Df }=={ x∈[1;∞) | x−1≠±2 }=={ x∈[1;∞) | x−1≠4 }=={ x∈[1;∞) | x≠5 }==[1;5)∪(5;∞)⇔[1;∞)∖{5}

Since the domain of f∘g is not an empty set (Df∘g≠∅), then f∘g exists (∃f∘g).

Calculate f∘g:

(f∘g)(x)=f(g(x))=f(x−1)=1(x−1)2−4=1x−1−4=1x−5

Therefore

f∘g=1x−5:(x∈[1;∞)∖{5})

Determining for g∘f ​

First, calculate the domain of g∘f:

Dg∘f={ x∈Df | f(x)∈Dg }=={ x∈R∖{±2} | 1x2−4≥1 }=={ x∈R∖{±2} | 1x2−4−1≥0 }=={ x∈R∖{±2} | 1−x2+4x2−4≥0 }={ x∈R∖{±2} | 5−x2x2−4≥0 }

Sign table

x−∞−5−225+∞
5−x2--0+++++0--
x2−4++++0-0++++
5−x2x2−4--0+n\a-n\a+0--

Therefore

Dg∘f={ x∈R∖{±2} | x∈[−5;−2)∪(2;5] }==[−5;−2)∪(2;5]

Since the domain of g∘f is not an empty set (Dg∘f≠∅), then g∘f exists (∃g∘f).

Calculate g∘f:

(g∘f)(x)=g(f(x))=g(1x2−4)=1x2−4−1=1−x2+4x2−4=5−x2x2−4

Therefore

g∘f=5−x2x2−4:(x∈[−5;−2)∪(2;5])