1. Introduction to set theory and to methodology and philosophy of
mathematics and computer programming
Function composition
An overview
by Jan Plaza
c 2017 Jan Plaza
Use under the Creative Commons Attribution 4.0 International License
Version of April 29, 2017
2. Definition. Let f and g be functions such that range(f) ⊆ domain(g).
The function composition of f and g , denoted g
func
◦ f ,
is the unique function that has the same domain as f,
and such that (g ◦ f)(x)=g(f(x)), for every x ∈ domain(f).
Note. “g ◦ f” is read “f composed with g” or “function composition of f and g”,
as if we were reading the expression “g ◦ f” from the right to the left.
While writing “f composed with g” in symbols, write from the right to the left.
Note. This definition does not tell what g
func
◦ f is when f or g is not a function
or when range(f) domain(g), and such cases are considered not iteresting.
Proposition. Let f and g be functions such that range(f) ⊆ domain(g),
i.e. such that the function composition g ◦ f is defined.
Then, (function composition) g
func
◦ f = (relation composition) g ◦ f .
Convention. Instead of
func
◦ we will write just ◦ . The context should tell whether the
relation composition or function composition is meant.
3. If f : X1 −→ Y1 and g : X2 −→ Y2 and Y1 ⊆ X2
then function composition g ◦ f is defined, and g ◦ f : X1 −→ Y2.
f
g
g ◦ f
X1 Y1
X2 Y2
4. Equivalently, if f : X −→ Y and g : Y −→ Z
then function composition g ◦ f is defined, and g ◦ f : X −→ Z.
f
g
g ◦ f
X
Y Z
6. Example
Let f : R −→ R where f(x)=2x.
Let g : R −→ R where g(x)=x + 1.
We have (f ◦ g)(x)=f(g(x))=2(x + 1) = 2x + 2.
We have (g ◦ f)(x)=g(f(x))=2x + 1.
Notice that f ◦ g=g ◦ f.
7. Example
Let f : R −→ R be defined as f(x) = sin x.
Let g : R 0 −→ R be defined as g(x) =
√
x.
1. Function composition g ◦ f is not defined
because range(f) = [−1, 1,] contains negative numbers, not in domain(g).
2. Relation composition g ◦ f is defined and results in a partial function on R;
g ◦ f : R −→ R such that
(g ◦ f)(x) =
√
sin x for x ∈ [2kπ, (2k + 1)π] where k ∈ Z.
3. Function composition f ◦ g is defined, and
it is the same as relation composition f ◦ g.
It results in a function f ◦ g : R 0 −→ R such that
(f ◦ g)(x) = sin(
√
x).
8. Fact
Let f, g be functions such that function composition g ◦ f is defined. Then:
1. domain(g ◦ f) = domain(f)
2. range(g ◦ f) ⊆ range(g)
Exercise
Let f, g be functions such that function composition g ◦ f is defined.
1. Disprove: domain(g ◦ f) = domain(g)
2. Disprove: range(g ◦ f) = range(g)